mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 17:34:21 +00:00
Fix other linters on modified lines
This commit is contained in:
@@ -102,6 +102,9 @@ linters-settings:
|
||||
arguments:
|
||||
- [ "ID", "API", "JSON" ] # AllowList
|
||||
- [ ] # DenyList
|
||||
gomnd:
|
||||
ignored-functions:
|
||||
- os.WriteFile
|
||||
gomoddirectives:
|
||||
replace-local: true
|
||||
gosec:
|
||||
|
||||
@@ -210,7 +210,7 @@ func (p *HelmChartInflationGeneratorPlugin) writeValuesBytes(
|
||||
return "", fmt.Errorf("cannot create tmp dir to write helm values")
|
||||
}
|
||||
path := filepath.Join(p.tmpDir, p.Name+"-kustomize-values.yaml")
|
||||
return path, os.WriteFile(path, b, 0644)
|
||||
return path, errors.Wrap(os.WriteFile(path, b, 0644), "failed to write values file")
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) cleanup() {
|
||||
|
||||
@@ -55,8 +55,9 @@ func (r *InitRunner) runE(c *cobra.Command, args []string) error {
|
||||
return errors.Errorf("directory already initialized with a Krmfile")
|
||||
}
|
||||
|
||||
return os.WriteFile(filename, []byte(strings.TrimSpace(`
|
||||
err := os.WriteFile(filename, []byte(strings.TrimSpace(`
|
||||
apiVersion: config.k8s.io/v1alpha1
|
||||
kind: Krmfile
|
||||
`)), 0600)
|
||||
return errors.Wrap(err)
|
||||
}
|
||||
|
||||
@@ -125,7 +125,10 @@ func (fsOnDisk) ReadDir(name string) ([]string, error) {
|
||||
}
|
||||
|
||||
// ReadFile delegates to os.ReadFile.
|
||||
func (fsOnDisk) ReadFile(name string) ([]byte, error) { return os.ReadFile(name) }
|
||||
func (fsOnDisk) ReadFile(name string) ([]byte, error) {
|
||||
//nolint:wrapcheck
|
||||
return os.ReadFile(name)
|
||||
}
|
||||
|
||||
// WriteFile delegates to os.WriteFile with read/write permissions.
|
||||
func (fsOnDisk) WriteFile(name string, c []byte) error {
|
||||
|
||||
@@ -100,5 +100,6 @@ func (l parser) readFile(path string) ([]byte, error) {
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
return io.ReadAll(f)
|
||||
content, err := io.ReadAll(f)
|
||||
return content, errors.Wrap(err)
|
||||
}
|
||||
|
||||
@@ -281,7 +281,7 @@ func TestAdd_Filter2(t *testing.T) {
|
||||
path := filepath.Join(os.TempDir(), "resourcefile")
|
||||
|
||||
// write initial resourcefile to temp path
|
||||
err := os.WriteFile(path, []byte(resourcefile), 0666)
|
||||
err := os.WriteFile(path, []byte(resourcefile), 0644)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -342,7 +342,7 @@ func TestAddUpdateSubstitution(t *testing.T) {
|
||||
path := filepath.Join(os.TempDir(), "resourcefile")
|
||||
|
||||
// write initial resourcefile to temp path
|
||||
err := os.WriteFile(path, []byte(resourcefile), 0666)
|
||||
err := os.WriteFile(path, []byte(resourcefile), 0644)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ func TestDelete_Filter2(t *testing.T) {
|
||||
path := filepath.Join(os.TempDir(), "resourcefile2")
|
||||
|
||||
// write initial resourcefile to temp path
|
||||
err := os.WriteFile(path, []byte(resourcefile2), 0666)
|
||||
err := os.WriteFile(path, []byte(resourcefile2), 0644)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestDeleterCreator_Delete(t *testing.T) {
|
||||
}
|
||||
defer os.Remove(openAPI.Name())
|
||||
// write openapi to temp dir
|
||||
err = os.WriteFile(openAPI.Name(), []byte(openAPIFile), 0666)
|
||||
err = os.WriteFile(openAPI.Name(), []byte(openAPIFile), 0644)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
@@ -59,7 +59,7 @@ func TestDeleterCreator_Delete(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
defer os.Remove(resource.Name())
|
||||
err = os.WriteFile(resource.Name(), []byte(resourceFile), 0666)
|
||||
err = os.WriteFile(resource.Name(), []byte(resourceFile), 0644)
|
||||
if !assert.NoError(t, err) {
|
||||
t.FailNow()
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ func WriteFile(node *RNode, path string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return os.WriteFile(path, []byte(out), 0600)
|
||||
return errors.WrapPrefixf(os.WriteFile(path, []byte(out), 0600), "writing RNode to file")
|
||||
}
|
||||
|
||||
// UpdateFile reads the file at path, applies the filter to it, and write the result back.
|
||||
|
||||
@@ -215,7 +215,7 @@ func (p *HelmChartInflationGeneratorPlugin) writeValuesBytes(
|
||||
return "", fmt.Errorf("cannot create tmp dir to write helm values")
|
||||
}
|
||||
path := filepath.Join(p.tmpDir, p.Name+"-kustomize-values.yaml")
|
||||
return path, os.WriteFile(path, b, 0644)
|
||||
return path, errors.Wrap(os.WriteFile(path, b, 0644), "failed to write values file")
|
||||
}
|
||||
|
||||
func (p *HelmChartInflationGeneratorPlugin) cleanup() {
|
||||
|
||||
Reference in New Issue
Block a user