From 005400c606525c4c3e8e1b1a95a419361a7fc1b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Mon, 23 May 2022 16:14:52 +0200 Subject: [PATCH] chore: enable nosprintfhostport linter (#3989) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché Co-authored-by: Prateek Pandey --- .golangci.yml | 1 + pkg/autogen/rule.go | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 08b2f8809d..ec9d97791e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -28,6 +28,7 @@ linters: - misspell - noctx - nolintlint + - nosprintfhostport - paralleltest - staticcheck - structcheck diff --git a/pkg/autogen/rule.go b/pkg/autogen/rule.go index e886a64c65..4c4d1e322a 100644 --- a/pkg/autogen/rule.go +++ b/pkg/autogen/rule.go @@ -171,9 +171,7 @@ func generateRule(name string, rule *kyvernov1.Rule, tplKey, shift string, kinds } if len(rule.Validation.ForEachValidation) > 0 && rule.Validation.ForEachValidation != nil { newForeachValidate := make([]kyvernov1.ForEachValidation, len(rule.Validation.ForEachValidation)) - for i, foreach := range rule.Validation.ForEachValidation { - newForeachValidate[i] = foreach - } + copy(newForeachValidate, rule.Validation.ForEachValidation) rule.Validation = kyvernov1.Validation{ Message: variables.FindAndShiftReferences(logger, rule.Validation.Message, shift, "pattern"), ForEachValidation: newForeachValidate,