Skip to content

Commit

Permalink
Merge pull request #127 from jingyuanliang/lint
Browse files Browse the repository at this point in the history
Fix lint failures, including setting nolint:errcheck on test
  • Loading branch information
k8s-ci-robot authored Feb 7, 2024
2 parents a8c6a6f + e1d2e6c commit a311e53
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
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

0 comments on commit a311e53

Please sign in to comment.