Fix other linters on modified lines

This commit is contained in:
Katrina Verey
2022-08-10 18:50:28 -04:00
parent f6b72077c8
commit 55a37de686
10 changed files with 19 additions and 11 deletions

View File

@@ -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 {

View File

@@ -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)
}

View File

@@ -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()
}

View File

@@ -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()
}

View File

@@ -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()
}

View File

@@ -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.