Skip to content

Commit

Permalink
Fix golanglint
Browse files Browse the repository at this point in the history
Signed-off-by: lou-lan <[email protected]>
  • Loading branch information
lou-lan committed Aug 16, 2024
1 parent af97564 commit 6eb557d
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pkg/controller/webhook/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func validateEgressPolicy(ctx context.Context, client client.Client, req webhook
}

// denied when both PodSelector and PodSubnet are empty
if egp.Spec.AppliedTo.PodSubnet == nil || len(egp.Spec.AppliedTo.PodSubnet) == 0 {
if len(egp.Spec.AppliedTo.PodSubnet) == 0 {
if egp.Spec.AppliedTo.PodSelector == nil || (len(egp.Spec.AppliedTo.PodSelector.MatchLabels) == 0 && len(egp.Spec.AppliedTo.PodSelector.MatchExpressions) == 0) {
return webhook.Denied("invalid EgressPolicy, spec.appliedTo field requires at least one of spec.appliedTo.podSubnet, .spec.appliedTo.podSelector.matchLabels or .spec.appliedTo.podSelector.matchExpressions to be specified.")
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/iptables/restore_buffer.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func (b *RestoreInputBuilder) WriteForwardReference(chainName string) {
// write the actual rules and will cause a panic if there is no open transaction.
func (b *RestoreInputBuilder) WriteLine(line string) {
b.maybeWriteTransactionOpener()
b.writeFormattedLine(line)
b.writeFormattedLine("%s", line)
}

// GetBytesAndReset returns the contents of the buffer and, as a side effect, resets the buffer. For performance,
Expand Down
2 changes: 1 addition & 1 deletion pkg/iptables/testutils/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func (d *restoreCmd) Run() error {
}
rest := strings.Join(parts[2:], " ")
if chains[chainName] == nil {
panic(fmt.Sprintf("Append to unknown chain: " + chainName))
panic(fmt.Sprintf("Append to unknown chain: %s", chainName))
}
chains[chainName] = append(chains[chainName], rest)
d.Dataplane.ChainMods.Add(chainMod{name: chainName, ruleNum: len(chains[chainName])})
Expand Down
3 changes: 1 addition & 2 deletions test/e2e/common/ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func CreateDaemonSet(ctx context.Context, cli client.Client, name string, image
case <-ctx.Done():
_ = DeleteObj(context.Background(), cli, res)
log.Log("create DaemonSet time out")
return nil, fmt.Errorf(log.Save())
return nil, fmt.Errorf("%s", log.Save())
default:
err := cli.Get(ctx, types.NamespacedName{Namespace: res.Namespace, Name: res.Name}, res)
if err != nil {
Expand All @@ -72,7 +72,6 @@ func CreateDaemonSet(ctx context.Context, cli client.Client, name string, image
return res, nil
}

log.Log("--------")
log.Log(fmt.Sprintf("CurrentNumberScheduled=%v\nDesiredNumberScheduled=%v\nNumberAvailable=%v", a, b, c))

nodes := new(corev1.NodeList)
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/common/egw.go
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ func DeleteEgressGateway(ctx context.Context, cli client.Client, egw *egressv1.E
select {
case <-ctx.Done():
log.Log("check delete egress gateway object timeout")
return fmt.Errorf(log.Save())
return fmt.Errorf("%s", log.Save())
default:
err = cli.Get(ctx, types.NamespacedName{Name: egw.Name}, egw)
if apierrors.IsNotFound(err) {
Expand Down

0 comments on commit 6eb557d

Please sign in to comment.