mirror of
https://github.com/kyverno/kyverno.git
synced 2025-03-28 10:28:36 +00:00
fix: use go 1.21 new packages (#8452)
Signed-off-by: Charles-Edouard Brétéché <charles.edouard@nirmata.com>
This commit is contained in:
parent
33dbdc9c5b
commit
fb90d0935d
16 changed files with 36 additions and 51 deletions
|
@ -1,15 +1,15 @@
|
|||
package function
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"fmt"
|
||||
"io"
|
||||
"slices"
|
||||
|
||||
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/command"
|
||||
"github.com/kyverno/kyverno/pkg/config"
|
||||
"github.com/kyverno/kyverno/pkg/engine/jmespath"
|
||||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/exp/slices"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
|
@ -29,7 +29,7 @@ func Command() *cobra.Command {
|
|||
func printFunctions(out io.Writer, names ...string) {
|
||||
functions := jmespath.GetFunctions(config.NewDefaultConfiguration(false))
|
||||
slices.SortFunc(functions, func(a, b jmespath.FunctionEntry) int {
|
||||
return datautils.Compare(a.String(), b.String())
|
||||
return cmp.Compare(a.String(), b.String())
|
||||
})
|
||||
namesSet := sets.New(names...)
|
||||
for _, function := range functions {
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package fix
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
"github.com/kyverno/kyverno/cmd/cli/kubectl-kyverno/apis/v1alpha1"
|
||||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
"golang.org/x/exp/slices"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
||||
|
@ -83,35 +83,35 @@ func FixTest(test v1alpha1.Test, compress bool) (v1alpha1.Test, []string, error)
|
|||
}
|
||||
}
|
||||
slices.SortFunc(results, func(a, b v1alpha1.TestResult) int {
|
||||
if x := datautils.Compare(a.Policy, b.Policy); x != 0 {
|
||||
if x := cmp.Compare(a.Policy, b.Policy); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.Rule, b.Rule); x != 0 {
|
||||
if x := cmp.Compare(a.Rule, b.Rule); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.Result, b.Result); x != 0 {
|
||||
if x := cmp.Compare(a.Result, b.Result); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.Kind, b.Kind); x != 0 {
|
||||
if x := cmp.Compare(a.Kind, b.Kind); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.PatchedResource, b.PatchedResource); x != 0 {
|
||||
if x := cmp.Compare(a.PatchedResource, b.PatchedResource); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.GeneratedResource, b.GeneratedResource); x != 0 {
|
||||
if x := cmp.Compare(a.GeneratedResource, b.GeneratedResource); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.CloneSourceResource, b.CloneSourceResource); x != 0 {
|
||||
if x := cmp.Compare(a.CloneSourceResource, b.CloneSourceResource); x != 0 {
|
||||
return x
|
||||
}
|
||||
slices.Sort(a.Resources)
|
||||
slices.Sort(b.Resources)
|
||||
if x := datautils.Compare(len(a.Resources), len(b.Resources)); x != 0 {
|
||||
if x := cmp.Compare(len(a.Resources), len(b.Resources)); x != 0 {
|
||||
return x
|
||||
}
|
||||
if len(a.Resources) == len(b.Resources) {
|
||||
for i := range a.Resources {
|
||||
if x := datautils.Compare(a.Resources[i], b.Resources[i]); x != 0 {
|
||||
if x := cmp.Compare(a.Resources[i], b.Resources[i]); x != 0 {
|
||||
return x
|
||||
}
|
||||
}
|
||||
|
|
2
go.mod
2
go.mod
|
@ -65,7 +65,6 @@ require (
|
|||
go.uber.org/multierr v1.11.0
|
||||
go.uber.org/zap v1.26.0
|
||||
golang.org/x/crypto v0.13.0
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9
|
||||
golang.org/x/text v0.13.0
|
||||
gomodules.xyz/jsonpatch/v2 v2.4.0
|
||||
google.golang.org/grpc v1.58.1
|
||||
|
@ -376,6 +375,7 @@ require (
|
|||
go.uber.org/atomic v1.11.0 // indirect
|
||||
go4.org/intern v0.0.0-20230525184215-6c62f75575cb // indirect
|
||||
go4.org/unsafe/assume-no-moving-gc v0.0.0-20230525183740-e7c30c78aeb2 // indirect
|
||||
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
|
||||
golang.org/x/mod v0.12.0 // indirect
|
||||
golang.org/x/net v0.15.0 // indirect
|
||||
golang.org/x/oauth2 v0.12.0 // indirect
|
||||
|
|
|
@ -2,12 +2,12 @@ package autogen
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/kyverno/kyverno/api/kyverno"
|
||||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
|
||||
"golang.org/x/exp/slices"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -27,7 +28,6 @@ import (
|
|||
engineutils "github.com/kyverno/kyverno/pkg/utils/engine"
|
||||
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
|
||||
"github.com/pkg/errors"
|
||||
"golang.org/x/exp/slices"
|
||||
admissionv1 "k8s.io/api/admission/v1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package config
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"golang.org/x/exp/slices"
|
||||
corev1 "k8s.io/api/core/v1"
|
||||
)
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package resource
|
|||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -16,7 +17,6 @@ import (
|
|||
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
|
||||
reportutils "github.com/kyverno/kyverno/pkg/utils/report"
|
||||
"github.com/kyverno/kyverno/pkg/validatingadmissionpolicy"
|
||||
"golang.org/x/exp/slices"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
|
|
@ -2,10 +2,10 @@ package validatingadmissionpolicygenerate
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
|
||||
"golang.org/x/exp/slices"
|
||||
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
|
||||
"k8s.io/api/admissionregistration/v1alpha1"
|
||||
)
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package webhook
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
"github.com/kyverno/kyverno/api/kyverno"
|
||||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
"golang.org/x/exp/slices"
|
||||
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
|
@ -46,11 +46,11 @@ func (wh *webhook) buildRulesWithOperations(ops ...admissionregistrationv1.Opera
|
|||
})
|
||||
}
|
||||
less := func(a []string, b []string) (int, bool) {
|
||||
if x := datautils.Compare(len(a), len(b)); x != 0 {
|
||||
if x := cmp.Compare(len(a), len(b)); x != 0 {
|
||||
return x, true
|
||||
}
|
||||
for i := range a {
|
||||
if x := datautils.Compare(a[i], b[i]); x != 0 {
|
||||
if x := cmp.Compare(a[i], b[i]); x != 0 {
|
||||
return x, true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,11 +2,11 @@ package jsonutils
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// ActionData represents data available for action on current element
|
||||
|
|
|
@ -2,13 +2,13 @@ package utils
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
kyvernov1beta1 "github.com/kyverno/kyverno/api/kyverno/v1beta1"
|
||||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
matchutils "github.com/kyverno/kyverno/pkg/utils/match"
|
||||
"github.com/kyverno/kyverno/pkg/utils/wildcard"
|
||||
"golang.org/x/exp/slices"
|
||||
authenticationv1 "k8s.io/api/authentication/v1"
|
||||
rbacv1 "k8s.io/api/rbac/v1"
|
||||
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
|
||||
|
|
|
@ -3,6 +3,7 @@ package openapi
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -11,7 +12,6 @@ import (
|
|||
openapiv2 "github.com/google/gnostic-models/openapiv2"
|
||||
"github.com/kyverno/kyverno/data"
|
||||
"github.com/kyverno/kyverno/pkg/logging"
|
||||
"golang.org/x/exp/slices"
|
||||
"gopkg.in/yaml.v3"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
package data
|
||||
|
||||
import (
|
||||
"golang.org/x/exp/constraints"
|
||||
)
|
||||
|
||||
func Compare[T constraints.Ordered](a, b T) int {
|
||||
if a < b {
|
||||
return -1
|
||||
}
|
||||
if a > b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
|
@ -1,6 +1,8 @@
|
|||
package report
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
@ -11,29 +13,27 @@ import (
|
|||
kyvernov1alpha2 "github.com/kyverno/kyverno/api/kyverno/v1alpha2"
|
||||
policyreportv1alpha2 "github.com/kyverno/kyverno/api/policyreport/v1alpha2"
|
||||
engineapi "github.com/kyverno/kyverno/pkg/engine/api"
|
||||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
"golang.org/x/exp/slices"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
func SortReportResults(results []policyreportv1alpha2.PolicyReportResult) {
|
||||
slices.SortFunc(results, func(a policyreportv1alpha2.PolicyReportResult, b policyreportv1alpha2.PolicyReportResult) int {
|
||||
if x := datautils.Compare(a.Policy, b.Policy); x != 0 {
|
||||
if x := cmp.Compare(a.Policy, b.Policy); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(a.Rule, b.Rule); x != 0 {
|
||||
if x := cmp.Compare(a.Rule, b.Rule); x != 0 {
|
||||
return x
|
||||
}
|
||||
if x := datautils.Compare(len(a.Resources), len(b.Resources)); x != 0 {
|
||||
if x := cmp.Compare(len(a.Resources), len(b.Resources)); x != 0 {
|
||||
return x
|
||||
}
|
||||
for i := range a.Resources {
|
||||
if x := datautils.Compare(a.Resources[i].UID, b.Resources[i].UID); x != 0 {
|
||||
if x := cmp.Compare(a.Resources[i].UID, b.Resources[i].UID); x != 0 {
|
||||
return x
|
||||
}
|
||||
}
|
||||
return datautils.Compare(a.Timestamp.String(), b.Timestamp.String())
|
||||
return cmp.Compare(a.Timestamp.String(), b.Timestamp.String())
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package policy
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"slices"
|
||||
|
||||
kyvernov1 "github.com/kyverno/kyverno/api/kyverno/v1"
|
||||
"github.com/kyverno/kyverno/pkg/clients/dclient"
|
||||
|
@ -10,7 +11,6 @@ import (
|
|||
"github.com/kyverno/kyverno/pkg/policy/generate"
|
||||
"github.com/kyverno/kyverno/pkg/policy/mutate"
|
||||
"github.com/kyverno/kyverno/pkg/policy/validate"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
// Validation provides methods to validate a rule
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"fmt"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"slices"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
|
@ -28,7 +29,6 @@ import (
|
|||
datautils "github.com/kyverno/kyverno/pkg/utils/data"
|
||||
kubeutils "github.com/kyverno/kyverno/pkg/utils/kube"
|
||||
"github.com/kyverno/kyverno/pkg/utils/wildcard"
|
||||
"golang.org/x/exp/slices"
|
||||
"k8s.io/apiextensions-apiserver/pkg/apis/apiextensions"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/util/sets"
|
||||
|
|
Loading…
Add table
Reference in a new issue