Merge pull request #31132 from joemicky/main

refactor: replace []byte(fmt.Sprintf) with fmt.Appendf
pull/12708/merge
Matt Farina 2 weeks ago committed by GitHub
commit 3726d01c5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -733,12 +733,12 @@ func Create(name, dir string) (string, error) {
{ {
// Chart.yaml // Chart.yaml
path: filepath.Join(cdir, ChartfileName), path: filepath.Join(cdir, ChartfileName),
content: []byte(fmt.Sprintf(defaultChartfile, name)), content: fmt.Appendf(nil, defaultChartfile, name),
}, },
{ {
// values.yaml // values.yaml
path: filepath.Join(cdir, ValuesfileName), path: filepath.Join(cdir, ValuesfileName),
content: []byte(fmt.Sprintf(defaultValues, name)), content: fmt.Appendf(nil, defaultValues, name),
}, },
{ {
// .helmignore // .helmignore

@ -733,12 +733,12 @@ func Create(name, dir string) (string, error) {
{ {
// Chart.yaml // Chart.yaml
path: filepath.Join(cdir, ChartfileName), path: filepath.Join(cdir, ChartfileName),
content: []byte(fmt.Sprintf(defaultChartfile, name)), content: fmt.Appendf(nil, defaultChartfile, name),
}, },
{ {
// values.yaml // values.yaml
path: filepath.Join(cdir, ValuesfileName), path: filepath.Join(cdir, ValuesfileName),
content: []byte(fmt.Sprintf(defaultValues, name)), content: fmt.Appendf(nil, defaultValues, name),
}, },
{ {
// .helmignore // .helmignore

@ -121,7 +121,7 @@ func setup(suite *TestSuite, tlsEnabled, insecure bool) *registry.Registry {
pwBytes, err := bcrypt.GenerateFromPassword([]byte(testPassword), bcrypt.DefaultCost) pwBytes, err := bcrypt.GenerateFromPassword([]byte(testPassword), bcrypt.DefaultCost)
suite.Nil(err, "no error generating bcrypt password for test htpasswd file") suite.Nil(err, "no error generating bcrypt password for test htpasswd file")
htpasswdPath := filepath.Join(suite.WorkspaceDir, testHtpasswdFileBasename) htpasswdPath := filepath.Join(suite.WorkspaceDir, testHtpasswdFileBasename)
err = os.WriteFile(htpasswdPath, []byte(fmt.Sprintf("%s:%s\n", testUsername, string(pwBytes))), 0644) err = os.WriteFile(htpasswdPath, fmt.Appendf(nil, "%s:%s\n", testUsername, string(pwBytes)), 0644)
suite.Nil(err, "no error creating test htpasswd file") suite.Nil(err, "no error creating test htpasswd file")
// Registry config // Registry config

@ -169,7 +169,7 @@ func NewOCIServer(t *testing.T, dir string) (*OCIServer, error) {
t.Fatal("error generating bcrypt password for test htpasswd file") t.Fatal("error generating bcrypt password for test htpasswd file")
} }
htpasswdPath := filepath.Join(dir, testHtpasswdFileBasename) htpasswdPath := filepath.Join(dir, testHtpasswdFileBasename)
err = os.WriteFile(htpasswdPath, []byte(fmt.Sprintf("%s:%s\n", testUsername, string(pwBytes))), 0o644) err = os.WriteFile(htpasswdPath, fmt.Appendf(nil, "%s:%s\n", testUsername, string(pwBytes)), 0o644)
if err != nil { if err != nil {
t.Fatalf("error creating test htpasswd file") t.Fatalf("error creating test htpasswd file")
} }

Loading…
Cancel
Save