Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lint failures, including setting nolint:errcheck on test #127

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions cmd/ip-masq-agent/ip-masq-agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,9 @@ func validateCIDR(cidr string) error {

func (m *MasqDaemon) syncMasqRules() error {
// make sure our custom chain for non-masquerade exists
m.iptables.EnsureChain(utiliptables.TableNAT, masqChain)
if _, err := m.iptables.EnsureChain(utiliptables.TableNAT, masqChain); err != nil {
return err
}

// ensure that any non-local in POSTROUTING jumps to masqChain
if err := m.ensurePostroutingJump(); err != nil {
Expand Down Expand Up @@ -311,8 +313,7 @@ func (m *MasqDaemon) syncMasqRulesIPv6() error {

if isIPv6Enabled {
// make sure our custom chain for ipv6 non-masquerade exists
_, err := m.ip6tables.EnsureChain(utiliptables.TableNAT, masqChain)
if err != nil {
if _, err := m.ip6tables.EnsureChain(utiliptables.TableNAT, masqChain); err != nil {
return err
}
// ensure that any non-local in POSTROUTING jumps to masqChain
Expand Down
9 changes: 5 additions & 4 deletions cmd/ip-masq-agent/ip-masq-agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

//nolint:errcheck
package main

import (
Expand Down Expand Up @@ -358,8 +359,8 @@ COMMIT
}
buf := bytes.NewBuffer(nil)
fipt.SaveInto("nat", buf)
if string(buf.Bytes()) != string(tt.want) {
t.Errorf("syncMasqRules wrote %q, want %q", string(buf.Bytes()), tt.want)
if buf.String() != tt.want {
t.Errorf("syncMasqRules wrote %q, want %q", buf.String(), tt.want)
}
})
}
Expand Down Expand Up @@ -432,8 +433,8 @@ COMMIT
}
buf := bytes.NewBuffer(nil)
fipt6.SaveInto("nat", buf)
if string(buf.Bytes()) != tt.want {
t.Errorf("syncMasqRulesIPv6 wrote %q, want %q", string(buf.Bytes()), tt.want)
if buf.String() != tt.want {
t.Errorf("syncMasqRulesIPv6 wrote %q, want %q", buf.String(), tt.want)
}
})
}
Expand Down
3 changes: 1 addition & 2 deletions cmd/ip-masq-agent/testing/fakefs/fakefs.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package fakefs

import (
"errors"
"io/ioutil"
"os"
"time"
)
Expand All @@ -35,7 +34,7 @@ func (DefaultFS) Stat(name string) (os.FileInfo, error) {
return os.Stat(name)
}
func (DefaultFS) ReadFile(name string) ([]byte, error) {
return ioutil.ReadFile(name)
return os.ReadFile(name)
}

// StringFS returns the string as the contents of the file
Expand Down