Skip to content

Commit

Permalink
Update ocm mode detection
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Oct 10, 2024
1 parent 8ae58df commit a8ceede
Show file tree
Hide file tree
Showing 9 changed files with 928 additions and 179 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ 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.24
kmodules.xyz/client-go v0.30.26
kmodules.xyz/custom-resources v0.30.0
kmodules.xyz/go-containerregistry v0.0.12
kmodules.xyz/monitoring-agent-api v0.30.2-0.20241001043315-b98120efea48
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,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.24 h1:kX0heBha1M0rfXm7p6V+Ul4It9HLzXM4PGUnZT7GWUg=
kmodules.xyz/client-go v0.30.24/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM=
kmodules.xyz/client-go v0.30.26 h1:cPoNid/Eq38EwznsZ27gu2AEXOjqcshn+/7kjlaaQNQ=
kmodules.xyz/client-go v0.30.26/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM=
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=
Expand Down
4 changes: 4 additions & 0 deletions vendor/kmodules.xyz/client-go/api/v1/certificates.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ type CertificateSpec struct {
Duration *metav1.Duration `json:"duration,omitempty" protobuf:"bytes,5,opt,name=duration"`

// Certificate renew before expiration duration
//
// Deprecated use `ReconfigureTLS` type OpsRequest instead.
//
// +deprecated
// +optional
RenewBefore *metav1.Duration `json:"renewBefore,omitempty" protobuf:"bytes,6,opt,name=renewBefore"`

Expand Down
22 changes: 11 additions & 11 deletions vendor/kmodules.xyz/client-go/api/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ type ClusterMetadata struct {
Name string `json:"name,omitempty" protobuf:"bytes,2,opt,name=name"`
DisplayName string `json:"displayName,omitempty" protobuf:"bytes,3,opt,name=displayName"`
Provider HostingProvider `json:"provider,omitempty" protobuf:"bytes,4,opt,name=provider,casttype=HostingProvider"`
OwnerID string `json:"ownerID,omitempty"`
OwnerType string `json:"ownerType,omitempty"`
APIEndpoint string `json:"apiEndpoint,omitempty"`
CABundle string `json:"caBundle,omitempty"`
OwnerID string `json:"ownerID,omitempty" protobuf:"bytes,5,opt,name=ownerID"`
OwnerType string `json:"ownerType,omitempty" protobuf:"bytes,6,opt,name=ownerType"`
APIEndpoint string `json:"apiEndpoint,omitempty" protobuf:"bytes,7,opt,name=apiEndpoint"`
CABundle string `json:"caBundle,omitempty" protobuf:"bytes,8,opt,name=caBundle"`
}

func (md ClusterMetadata) State() string {
Expand Down Expand Up @@ -151,18 +151,18 @@ func (cm ClusterManager) String() string {
}

type CAPIClusterInfo struct {
Provider CAPIProvider `json:"provider"`
Namespace string `json:"namespace"`
ClusterName string `json:"clusterName"`
Provider CAPIProvider `json:"provider" protobuf:"bytes,1,opt,name=provider,casttype=CAPIProvider"`
Namespace string `json:"namespace" protobuf:"bytes,2,opt,name=namespace"`
ClusterName string `json:"clusterName" protobuf:"bytes,3,opt,name=clusterName"`
}

// ClusterInfo used in ace-installer
type ClusterInfo struct {
UID string `json:"uid"`
Name string `json:"name"`
ClusterManagers []string `json:"clusterManagers"`
UID string `json:"uid" protobuf:"bytes,1,opt,name=uid"`
Name string `json:"name" protobuf:"bytes,2,opt,name=name"`
ClusterManagers []string `json:"clusterManagers" protobuf:"bytes,3,rep,name=clusterManagers"`
// +optional
CAPI *CAPIClusterInfo `json:"capi"`
CAPI *CAPIClusterInfo `json:"capi" protobuf:"bytes,4,opt,name=capi"`
}

// +kubebuilder:validation:Enum=capa;capg;capz
Expand Down
1,021 changes: 866 additions & 155 deletions vendor/kmodules.xyz/client-go/api/v1/generated.pb.go

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions vendor/kmodules.xyz/client-go/api/v1/generated.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/kmodules.xyz/client-go/cluster/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ func DetectClusterManager(kc client.Client, mappers ...meta.RESTMapper) kmapi.Cl
if IsOpenClusterHub(mapper) {
result |= kmapi.ClusterManagerOCMHub
}
if IsOpenClusterSpoke(mapper) {
if IsOpenClusterSpoke(kc) {
result |= kmapi.ClusterManagerOCMSpoke
}
if IsOpenClusterMulticlusterControlplane(mapper) {
Expand Down
18 changes: 10 additions & 8 deletions vendor/kmodules.xyz/client-go/cluster/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ limitations under the License.
package cluster

import (
"context"

"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/client"
)

func IsOpenClusterHub(mapper meta.RESTMapper) bool {
Expand All @@ -31,14 +35,12 @@ func IsOpenClusterHub(mapper meta.RESTMapper) bool {
return false
}

func IsOpenClusterSpoke(mapper meta.RESTMapper) bool {
if _, err := mapper.RESTMappings(schema.GroupKind{
Group: "operator.open-cluster-management.io",
Kind: "Klusterlet",
}); err == nil {
return true
}
return false
func IsOpenClusterSpoke(kc client.Client) bool {
var list unstructured.UnstructuredList
list.SetAPIVersion("operator.open-cluster-management.io/v1")
list.SetKind("Klusterlet")
err := kc.List(context.TODO(), &list)
return err == nil && len(list.Items) > 0
}

func IsOpenClusterMulticlusterControlplane(mapper meta.RESTMapper) bool {
Expand Down
2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2006,7 +2006,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.24
# kmodules.xyz/client-go v0.30.26
## explicit; go 1.22.0
kmodules.xyz/client-go
kmodules.xyz/client-go/api/v1
Expand Down

0 comments on commit a8ceede

Please sign in to comment.