Skip to content

Commit

Permalink
Update deps
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Jun 14, 2024
1 parent 500b3be commit 4fb6a3f
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 58 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ require (
k8s.io/apimachinery v0.30.1
k8s.io/client-go v0.30.1
k8s.io/klog/v2 v2.120.1
kmodules.xyz/client-go v0.30.3
kmodules.xyz/resource-metadata v0.18.7
kmodules.xyz/client-go v0.30.5
kmodules.xyz/resource-metadata v0.18.8-0.20240614001230-063fb3a89196
sigs.k8s.io/controller-runtime v0.18.4
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -343,14 +343,14 @@ k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCf
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/client-go v0.30.3 h1:EkXdi2KFn3JCSlumybyW8n+ng+pToSaJvBQWEMKgZEs=
kmodules.xyz/client-go v0.30.3/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/go-containerregistry v0.0.12 h1:Tl32QGmSqRVm9PUEb/f3dgDeu9zW5fVzt3qmAFIE37I=
kmodules.xyz/go-containerregistry v0.0.12/go.mod h1:KgeNg0hDsgeda+qc0NzWk0iVRdF0+ZIg/oRzGoYh78I=
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.7 h1:urw+jeENAS4sIwz7FDp/8Kjs1VD1PYTKUVZGjsyhQ+M=
kmodules.xyz/resource-metadata v0.18.7/go.mod h1:sbczSLNVdWlbmwFW/niMbx03+yeU9qnxO24lpklti/A=
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=
sigs.k8s.io/cli-utils v0.34.0 h1:zCUitt54f0/MYj/ajVFnG6XSXMhpZ72O/3RewIchW8w=
Expand Down
29 changes: 16 additions & 13 deletions vendor/kmodules.xyz/client-go/cluster/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (
cu "kmodules.xyz/client-go/client"

core "k8s.io/api/core/v1"
kerr "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/api/meta"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
Expand All @@ -46,25 +47,27 @@ func ClusterUID(c client.Reader) (string, error) {
}

func ClusterMetadata(c client.Reader) (*kmapi.ClusterMetadata, error) {
var cm core.ConfigMap
err := c.Get(context.TODO(), client.ObjectKey{Name: kmapi.AceInfoConfigMapName, Namespace: metav1.NamespacePublic}, &cm)
var ns core.Namespace
err := c.Get(context.TODO(), client.ObjectKey{Name: metav1.NamespaceSystem}, &ns)
if err != nil {
return nil, err
}
result, err := ClusterMetadataForConfigMap(&cm)
if err == nil {
return result, nil
}

var ns core.Namespace
err = c.Get(context.TODO(), client.ObjectKey{Name: metav1.NamespaceSystem}, &ns)
if err != nil {
var cm core.ConfigMap
err = c.Get(context.TODO(), client.ObjectKey{Name: kmapi.AceInfoConfigMapName, Namespace: metav1.NamespacePublic}, &cm)
if err == nil {
result, err := ClusterMetadataFromConfigMap(&cm, string(ns.UID))
if err == nil {
return result, nil
}
} else if !kerr.IsNotFound(err) {
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)
}
Expand All @@ -81,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)
}
Expand All @@ -101,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"]
Expand Down
19 changes: 11 additions & 8 deletions vendor/kmodules.xyz/client-go/tools/clusterid/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
kmapi "kmodules.xyz/client-go/api/v1"
clustermeta "kmodules.xyz/client-go/cluster"

kerr "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/kubernetes"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
Expand All @@ -36,18 +37,20 @@ func ClusterUID(client corev1.NamespaceInterface) (string, error) {
}

func ClusterMetadata(client kubernetes.Interface) (*kmapi.ClusterMetadata, error) {
cm, err := client.CoreV1().ConfigMaps(metav1.NamespacePublic).Get(context.TODO(), kmapi.AceInfoConfigMapName, metav1.GetOptions{})
ns, err := client.CoreV1().Namespaces().Get(context.TODO(), metav1.NamespaceSystem, metav1.GetOptions{})
if err != nil {
return nil, err
}
result, err := clustermeta.ClusterMetadataForConfigMap(cm)
if err == nil {
return result, nil
}

ns, err := client.CoreV1().Namespaces().Get(context.TODO(), metav1.NamespaceSystem, metav1.GetOptions{})
if err != nil {
cm, err := client.CoreV1().ConfigMaps(metav1.NamespacePublic).Get(context.TODO(), kmapi.AceInfoConfigMapName, metav1.GetOptions{})
if err == nil {
result, err := clustermeta.ClusterMetadataFromConfigMap(cm, string(ns.UID))
if err == nil {
return result, nil
}
} else if !kerr.IsNotFound(err) {
return nil, err
}
return clustermeta.LegacyClusterMetadataForNamespace(ns)

return clustermeta.LegacyClusterMetadataFromNamespace(ns)
}
46 changes: 17 additions & 29 deletions vendor/kmodules.xyz/resource-metadata/pkg/identity/b3.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,16 @@ import (
"path"

kmapi "kmodules.xyz/client-go/api/v1"
clustermeta "kmodules.xyz/client-go/cluster"
identityapi "kmodules.xyz/resource-metadata/apis/identity/v1alpha1"

"go.bytebuilders.dev/license-verifier/info"
"gomodules.xyz/sync"
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/json"
"sigs.k8s.io/controller-runtime/pkg/client"
)

type Client struct {
Expand All @@ -41,14 +42,15 @@ type Client struct {
caCert []byte
client *http.Client

clusterUID string
kc client.Reader
}

func NewClient(baseURL, token string, caCert []byte, clusterUID string) (*Client, error) {
func NewClient(baseURL, token string, caCert []byte, kc client.Reader) (*Client, error) {
c := &Client{
baseURL: baseURL,
token: token,
caCert: caCert,
kc: kc,
}
if len(caCert) == 0 {
c.client = http.DefaultClient
Expand Down Expand Up @@ -152,31 +154,17 @@ func (c *Client) GetToken() (string, error) {

const SelfName = "self"

var (
identity *identityapi.ClusterIdentity
once sync.Once
idError error
creationTimestamp = metav1.Now()
)

func (c *Client) GetIdentity() (*identityapi.ClusterIdentity, error) {
once.Do(func() error {
var md *kmapi.ClusterMetadata
md, idError = c.Identify(c.clusterUID)
if idError != nil {
return idError
}
identity = &identityapi.ClusterIdentity{
ObjectMeta: metav1.ObjectMeta{
UID: types.UID("cid-" + c.clusterUID),
Name: SelfName,
CreationTimestamp: creationTimestamp,
Generation: 1,
},
Status: *md,
}
idError = nil
return idError
})
return identity, idError
md, err := clustermeta.ClusterMetadata(c.kc)
if err != nil {
return nil, err
}
return &identityapi.ClusterIdentity{
ObjectMeta: metav1.ObjectMeta{
UID: types.UID("cid-" + md.UID),
Name: SelfName,
Generation: 1,
},
Status: *md,
}, nil
}
4 changes: 2 additions & 2 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ k8s.io/utils/trace
# kmodules.xyz/apiversion v0.2.0
## explicit; go 1.14
kmodules.xyz/apiversion
# kmodules.xyz/client-go v0.30.3
# kmodules.xyz/client-go v0.30.5
## explicit; go 1.22.0
kmodules.xyz/client-go
kmodules.xyz/client-go/api/v1
Expand All @@ -892,7 +892,7 @@ kmodules.xyz/go-containerregistry/name
## explicit; go 1.22.0
kmodules.xyz/offshoot-api/api/v1
kmodules.xyz/offshoot-api/api/v2
# kmodules.xyz/resource-metadata v0.18.7
# kmodules.xyz/resource-metadata v0.18.8-0.20240614001230-063fb3a89196
## explicit; go 1.22.1
kmodules.xyz/resource-metadata/apis/core/v1alpha1
kmodules.xyz/resource-metadata/apis/identity/v1alpha1
Expand Down

0 comments on commit 4fb6a3f

Please sign in to comment.