diff --git a/go.mod b/go.mod index 6e88d1079..6d79f6bef 100644 --- a/go.mod +++ b/go.mod @@ -44,11 +44,11 @@ require ( k8s.io/kube-state-metrics/v2 v2.12.0 kmodules.xyz/apiversion v0.2.0 kmodules.xyz/authorizer v0.29.1 - kmodules.xyz/client-go v0.30.4 + kmodules.xyz/client-go v0.30.5 kmodules.xyz/custom-resources v0.30.0 kmodules.xyz/go-containerregistry v0.0.12 kmodules.xyz/monitoring-agent-api v0.29.0 - kmodules.xyz/resource-metadata v0.18.8-0.20240612015959-9832ca0a2adb + kmodules.xyz/resource-metadata v0.18.8-0.20240614001230-063fb3a89196 kmodules.xyz/resource-metrics v0.30.1 kmodules.xyz/resource-metrics/utils v0.30.1 kmodules.xyz/sets v0.29.0 diff --git a/go.sum b/go.sum index 4f01cb754..c3eaae0e4 100644 --- a/go.sum +++ b/go.sum @@ -904,8 +904,8 @@ kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk= kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80= kmodules.xyz/authorizer v0.29.1 h1:uByGGoryKbZcfiEAhjcK/Y345I9mygNQP7DVpkMbNQQ= kmodules.xyz/authorizer v0.29.1/go.mod h1:kZRhclL8twzyt2bQuJQJbpYww2sc+qFr8I5PPoq/sWY= -kmodules.xyz/client-go v0.30.4 h1:lfCNkSUvd4HkQnW94nm65AgwMt1UppqPffqXH0NPh2w= -kmodules.xyz/client-go v0.30.4/go.mod h1:ekDSUC0UFLI0Jq3A62myW7VG8TYLBqCwMjqWJM1SrqU= +kmodules.xyz/client-go v0.30.5 h1:Zgi25FXK52Y4Pe2Ei43oZ6QLgk+x0XXukmw1gtOx9Bs= +kmodules.xyz/client-go v0.30.5/go.mod h1:XL3PDQIXG4s3xNRL2SSxIvi8b2WyMGpn26dFnOBz0j4= kmodules.xyz/crd-schema-fuzz v0.29.1 h1:zJTlWYOrT5dsVVHW8HGcnR/vaWfxQfNh11QwTtkYpcs= kmodules.xyz/crd-schema-fuzz v0.29.1/go.mod h1:n708z9YQqLMP2KNLQVgBcRJw1QpSWLvpNCEi+KJDOYE= kmodules.xyz/custom-resources v0.30.0 h1:vR3CbseHMLwR4GvtcJJuRuwIV8voKqFqNii27rMcm1o= @@ -916,8 +916,8 @@ kmodules.xyz/monitoring-agent-api v0.29.0 h1:gpFl6OZrlMLb/ySMHdREI9EwGtnJ91oZBn9 kmodules.xyz/monitoring-agent-api v0.29.0/go.mod h1:iNbvaMTgVFOI5q2LJtGK91j4Dmjv4ZRiRdasGmWLKQI= kmodules.xyz/offshoot-api v0.29.4 h1:WQV2BIUIoVKKiqZNmZ4gAy367jEdwBhEl3dFCLZM1qA= kmodules.xyz/offshoot-api v0.29.4/go.mod h1:e+NQ0s4gW/YTPWBWEfdISZcmk+tlTq8IjvP5SLdqvko= -kmodules.xyz/resource-metadata v0.18.8-0.20240612015959-9832ca0a2adb h1:4iHgeGV4lO/d60fd0V13DqPqnJ3XgepsCDOIaYmxytg= -kmodules.xyz/resource-metadata v0.18.8-0.20240612015959-9832ca0a2adb/go.mod h1:iWMQ1teVvqqHygN79A+UlhuY2QDamIqzO94yXBHdYrY= +kmodules.xyz/resource-metadata v0.18.8-0.20240614001230-063fb3a89196 h1:eoZfQGKevjUl0A1Xvry3STD1uufj1Na9IquZVJ44rvo= +kmodules.xyz/resource-metadata v0.18.8-0.20240614001230-063fb3a89196/go.mod h1:sfb7uQ6H/XvL/AWqRZCBhRf+gO+NB3vmyPOoD6LVEys= kmodules.xyz/resource-metrics v0.30.1 h1:o7mVY8ZwSe5iEILy1eMG4EPZCli7mXZCkgQONjoY9uU= kmodules.xyz/resource-metrics v0.30.1/go.mod h1:UYcQQLN+3o8rNPQJwJa2D9bt5ihJCeo5bCDuQ4O3MPY= kmodules.xyz/resource-metrics/utils v0.30.1 h1:iRnAKNMMdAi7QYjMQrK9W3vNMhSC21RWNx9yS3qlpTA= diff --git a/vendor/kmodules.xyz/client-go/cluster/lib.go b/vendor/kmodules.xyz/client-go/cluster/lib.go index ea59b5f4b..77980ad07 100644 --- a/vendor/kmodules.xyz/client-go/cluster/lib.go +++ b/vendor/kmodules.xyz/client-go/cluster/lib.go @@ -47,10 +47,16 @@ func ClusterUID(c client.Reader) (string, error) { } func ClusterMetadata(c client.Reader) (*kmapi.ClusterMetadata, error) { + var ns core.Namespace + err := c.Get(context.TODO(), client.ObjectKey{Name: metav1.NamespaceSystem}, &ns) + if err != nil { + return nil, err + } + var cm core.ConfigMap - err := c.Get(context.TODO(), client.ObjectKey{Name: kmapi.AceInfoConfigMapName, Namespace: metav1.NamespacePublic}, &cm) + err = c.Get(context.TODO(), client.ObjectKey{Name: kmapi.AceInfoConfigMapName, Namespace: metav1.NamespacePublic}, &cm) if err == nil { - result, err := ClusterMetadataForConfigMap(&cm) + result, err := ClusterMetadataFromConfigMap(&cm, string(ns.UID)) if err == nil { return result, nil } @@ -58,15 +64,10 @@ func ClusterMetadata(c client.Reader) (*kmapi.ClusterMetadata, error) { return nil, err } - var ns core.Namespace - err = c.Get(context.TODO(), client.ObjectKey{Name: metav1.NamespaceSystem}, &ns) - if err != nil { - return nil, err - } - return LegacyClusterMetadataForNamespace(&ns) + return LegacyClusterMetadataFromNamespace(&ns) } -func LegacyClusterMetadataForNamespace(ns *core.Namespace) (*kmapi.ClusterMetadata, error) { +func LegacyClusterMetadataFromNamespace(ns *core.Namespace) (*kmapi.ClusterMetadata, error) { if ns.Name != metav1.NamespaceSystem { return nil, fmt.Errorf("expected namespace %s, found namespace %s", metav1.NamespaceSystem, ns.Name) } @@ -83,7 +84,7 @@ func LegacyClusterMetadataForNamespace(ns *core.Namespace) (*kmapi.ClusterMetada return md, nil } -func ClusterMetadataForConfigMap(cm *core.ConfigMap) (*kmapi.ClusterMetadata, error) { +func ClusterMetadataFromConfigMap(cm *core.ConfigMap, clusterUIDVerifier string) (*kmapi.ClusterMetadata, error) { if cm.Name != kmapi.AceInfoConfigMapName || cm.Namespace != metav1.NamespacePublic { return nil, fmt.Errorf("expected configmap %s/%s, found %s/%s", metav1.NamespacePublic, kmapi.AceInfoConfigMapName, cm.Namespace, cm.Name) } @@ -103,7 +104,7 @@ func ClusterMetadataForConfigMap(cm *core.ConfigMap) (*kmapi.ClusterMetadata, er if err != nil { return nil, err } - hasher := hmac.New(sha256.New, []byte(md.UID)) + hasher := hmac.New(sha256.New, []byte(clusterUIDVerifier)) hasher.Write(data) messageMAC := hasher.Sum(nil) expectedMAC := cm.BinaryData["mac"] diff --git a/vendor/kmodules.xyz/client-go/tools/clusterid/lib.go b/vendor/kmodules.xyz/client-go/tools/clusterid/lib.go index 5d0e58174..c262aee53 100644 --- a/vendor/kmodules.xyz/client-go/tools/clusterid/lib.go +++ b/vendor/kmodules.xyz/client-go/tools/clusterid/lib.go @@ -37,9 +37,14 @@ func ClusterUID(client corev1.NamespaceInterface) (string, error) { } func ClusterMetadata(client kubernetes.Interface) (*kmapi.ClusterMetadata, error) { + ns, err := client.CoreV1().Namespaces().Get(context.TODO(), metav1.NamespaceSystem, metav1.GetOptions{}) + if err != nil { + return nil, err + } + cm, err := client.CoreV1().ConfigMaps(metav1.NamespacePublic).Get(context.TODO(), kmapi.AceInfoConfigMapName, metav1.GetOptions{}) if err == nil { - result, err := clustermeta.ClusterMetadataForConfigMap(cm) + result, err := clustermeta.ClusterMetadataFromConfigMap(cm, string(ns.UID)) if err == nil { return result, nil } @@ -47,9 +52,5 @@ func ClusterMetadata(client kubernetes.Interface) (*kmapi.ClusterMetadata, error return nil, err } - ns, err := client.CoreV1().Namespaces().Get(context.TODO(), metav1.NamespaceSystem, metav1.GetOptions{}) - if err != nil { - return nil, err - } - return clustermeta.LegacyClusterMetadataForNamespace(ns) + return clustermeta.LegacyClusterMetadataFromNamespace(ns) } diff --git a/vendor/modules.txt b/vendor/modules.txt index cddd511aa..b751fae54 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1925,7 +1925,7 @@ kmodules.xyz/authorizer/apiserver kmodules.xyz/authorizer/rbac kmodules.xyz/authorizer/rbac/helpers kmodules.xyz/authorizer/rbac/validation -# kmodules.xyz/client-go v0.30.4 +# kmodules.xyz/client-go v0.30.5 ## explicit; go 1.22.0 kmodules.xyz/client-go kmodules.xyz/client-go/api/v1 @@ -1959,7 +1959,7 @@ kmodules.xyz/monitoring-agent-api/client ## explicit; go 1.22.0 kmodules.xyz/offshoot-api/api/v1 kmodules.xyz/offshoot-api/api/v2 -# kmodules.xyz/resource-metadata v0.18.8-0.20240612015959-9832ca0a2adb +# kmodules.xyz/resource-metadata v0.18.8-0.20240614001230-063fb3a89196 ## explicit; go 1.22.1 kmodules.xyz/resource-metadata/apis/core/install kmodules.xyz/resource-metadata/apis/core/v1alpha1