Skip to content

Commit

Permalink
Update capi 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 8, 2024
1 parent 16bc6e1 commit 26005dc
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ spec:
- capg
- capz
type: string
required:
- clusterName
- namespace
- provider
type: object
clusterManagers:
items:
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
k8s.io/kube-openapi v0.0.0-20240703190633-0aa61b46e8c2
k8s.io/kubectl v0.30.1
k8s.io/utils v0.0.0-20240502163921-fe8a2dddb1d0
kmodules.xyz/client-go v0.30.16
kmodules.xyz/client-go v0.30.21
kmodules.xyz/fake-apiserver v0.0.1
kmodules.xyz/resource-metadata v0.18.14-0.20240925020608-73a6d2bd1a4e
kubepack.dev/lib-app v0.0.23-0.20240924113256-e97763847fe2
Expand Down Expand Up @@ -237,8 +237,8 @@ require (
gocloud.dev v0.26.0 // indirect
golang.org/x/crypto v0.27.0 // indirect
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/net v0.29.0 // indirect
golang.org/x/oauth2 v0.22.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.25.0 // indirect
golang.org/x/term v0.24.0 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1195,8 +1195,8 @@ golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su
golang.org/x/net v0.0.0-20220401154927-543a649e0bdd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
Expand All @@ -1217,8 +1217,8 @@ golang.org/x/oauth2 v0.0.0-20211005180243-6b3c2da341f1/go.mod h1:KelEdhl1UZF7XfJ
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A=
golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc=
golang.org/x/oauth2 v0.21.0 h1:tsimM75w1tF/uws5rbeHzIWxEqElMehnc+iW793zsZs=
golang.org/x/oauth2 v0.21.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA=
golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -1694,8 +1694,8 @@ kmodules.xyz/apiversion v0.2.0 h1:vAQYqZFm4xu4pbB1cAdHbFEPES6EQkcR4wc06xdTOWk=
kmodules.xyz/apiversion v0.2.0/go.mod h1:oPX8g8LvlPdPX3Yc5YvCzJHQnw3YF/X4/jdW0b1am80=
kmodules.xyz/apply v0.29.0 h1:0OXGfE2IPuvXHk6uI9zp6KCYdBibx8mK4PEl0g3LZ44=
kmodules.xyz/apply v0.29.0/go.mod h1:bwToXErB+DC7/EEWjQVARCSbJBjGx5hIEuV1n0tC73g=
kmodules.xyz/client-go v0.30.16 h1:ph4R2r4+x2eqIyjiSeCksWUnRoniRugA5+thldOdK70=
kmodules.xyz/client-go v0.30.16/go.mod h1:e8SI8ZW7BiJSQTp+RP5IscYXZbKrr5rTSCIyaVo4bLY=
kmodules.xyz/client-go v0.30.21 h1:Uye+aPmqgcO4qb1GeIgQEVZ9q5XK/9V3Xu+Vglj3L/0=
kmodules.xyz/client-go v0.30.21/go.mod h1:CAu+JlA8RVGtj6LQHu0Q1w2mnFUajuti49c7T1AvGdM=
kmodules.xyz/fake-apiserver v0.0.1 h1:OcL9kvVOSqh0pG8KhU72BWrlAE9j9+L0WJ7qNiXXpz8=
kmodules.xyz/fake-apiserver v0.0.1/go.mod h1:1kKm0V/WAKoSBbOpuzKrsfM5ydr/BXYWwZsNo4y4OvY=
kmodules.xyz/go-containerregistry v0.0.12 h1:Tl32QGmSqRVm9PUEb/f3dgDeu9zW5fVzt3qmAFIE37I=
Expand Down
4 changes: 2 additions & 2 deletions vendor/golang.org/x/net/LICENSE

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

4 changes: 2 additions & 2 deletions vendor/golang.org/x/oauth2/LICENSE

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

30 changes: 14 additions & 16 deletions vendor/kmodules.xyz/client-go/api/v1/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,21 @@ import (
"strings"
)

// +kubebuilder:validation:Enum=Aws;Azure;DigitalOcean;GoogleCloud;Linode;Packet;Scaleway;Vultr;BareMetal;KIND;Generic;Private
// +kubebuilder:validation:Enum=AKS;DigitalOcean;EKS;Exoscale;Generic;GKE;Linode;Packet;Rancher;Scaleway;Vultr
type HostingProvider string

const (
HostingProviderAWS HostingProvider = "Aws"
HostingProviderAzure HostingProvider = "Azure"
HostingProviderAKS HostingProvider = "AKS"
HostingProviderDigitalOcean HostingProvider = "DigitalOcean"
HostingProviderGoogleCloud HostingProvider = "GoogleCloud"
HostingProviderEKS HostingProvider = "EKS"
HostingProviderExoscale HostingProvider = "Exoscale"
HostingProviderGeneric HostingProvider = "Generic"
HostingProviderGKE HostingProvider = "GKE"
HostingProviderLinode HostingProvider = "Linode"
HostingProviderPacket HostingProvider = "Packet"
HostingProviderRancher HostingProvider = "Rancher"
HostingProviderScaleway HostingProvider = "Scaleway"
HostingProviderVultr HostingProvider = "Vultr"
HostingProviderBareMetal HostingProvider = "BareMetal"
HostingProviderKIND HostingProvider = "KIND"
HostingProviderGeneric HostingProvider = "Generic"
HostingProviderPrivate HostingProvider = "Private"
)

const (
Expand Down Expand Up @@ -153,9 +151,9 @@ func (cm ClusterManager) String() string {
}

type CAPIClusterInfo struct {
Provider CAPIProvider `json:"provider,omitempty"`
Namespace string `json:"namespace,omitempty"`
ClusterName string `json:"clusterName,omitempty"`
Provider CAPIProvider `json:"provider"`
Namespace string `json:"namespace"`
ClusterName string `json:"clusterName"`
}

// ClusterInfo used in ace-installer
Expand All @@ -164,15 +162,15 @@ type ClusterInfo struct {
Name string `json:"name"`
ClusterManagers []string `json:"clusterManagers"`
// +optional
CAPI CAPIClusterInfo `json:"capi"`
CAPI *CAPIClusterInfo `json:"capi"`
}

// +kubebuilder:validation:Enum=capa;capg;capz
type CAPIProvider string

const (
CAPIProviderDisabled CAPIProvider = ""
CAPIProviderCAPA CAPIProvider = "capa"
CAPIProviderCAPG CAPIProvider = "capg"
CAPIProviderCAPZ CAPIProvider = "capz"
CAPIProviderCAPA CAPIProvider = "capa"
CAPIProviderCAPG CAPIProvider = "capg"
CAPIProviderCAPZ CAPIProvider = "capz"
CAPIProviderCAPH CAPIProvider = "caph"
)

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

6 changes: 3 additions & 3 deletions vendor/kmodules.xyz/client-go/cluster/detector.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ func DetectProvider(cfg *rest.Config, mapper meta.RESTMapper) (kmapi.HostingProv

for _, host := range crt.DNSNames {
if strings.HasSuffix(host, eksDomain) {
return kmapi.HostingProviderAWS, nil
return kmapi.HostingProviderEKS, nil
} else if strings.HasSuffix(host, aksDomain) {
return kmapi.HostingProviderAzure, nil
return kmapi.HostingProviderAKS, nil
} else if strings.HasSuffix(host, doDomain) {
return kmapi.HostingProviderDigitalOcean, nil
} else if strings.HasSuffix(host, exoscaleDomain) {
Expand All @@ -108,7 +108,7 @@ func DetectProvider(cfg *rest.Config, mapper meta.RESTMapper) (kmapi.HostingProv
Group: "networking.gke.io",
Kind: "Network",
}); err == nil {
return kmapi.HostingProviderGoogleCloud, nil
return kmapi.HostingProviderGKE, nil
}

return "", nil
Expand Down
5 changes: 3 additions & 2 deletions vendor/kmodules.xyz/client-go/cluster/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"crypto/hmac"
"crypto/sha256"
"encoding/json"
"errors"
"fmt"

kmapi "kmodules.xyz/client-go/api/v1"
Expand All @@ -34,6 +33,7 @@ import (
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
)

Expand Down Expand Up @@ -170,7 +170,8 @@ func DetectCAPICluster(kc client.Client) (*kmapi.CAPIClusterInfo, error) {
} else if err != nil {
return nil, err
} else if len(list.Items) > 1 {
return nil, errors.New("multiple CAPI cluster object found")
klog.Warningln("multiple CAPI cluster object found")
return nil, nil
}

obj := list.Items[0].UnstructuredContent()
Expand Down
4 changes: 2 additions & 2 deletions vendor/kmodules.xyz/client-go/cluster/ocm.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func IsOpenClusterHub(mapper meta.RESTMapper) bool {

func IsOpenClusterSpoke(mapper meta.RESTMapper) bool {
if _, err := mapper.RESTMappings(schema.GroupKind{
Group: "work.open-cluster-management.io",
Kind: "AppliedManifestWork",
Group: "operator.open-cluster-management.io",
Kind: "Klusterlet",
}); err == nil {
return true
}
Expand Down
6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1091,7 +1091,7 @@ golang.org/x/crypto/scrypt
golang.org/x/exp/constraints
golang.org/x/exp/maps
golang.org/x/exp/slices
# golang.org/x/net v0.27.0
# golang.org/x/net v0.29.0
## explicit; go 1.18
golang.org/x/net/html
golang.org/x/net/html/atom
Expand All @@ -1106,7 +1106,7 @@ golang.org/x/net/proxy
golang.org/x/net/publicsuffix
golang.org/x/net/trace
golang.org/x/net/websocket
# golang.org/x/oauth2 v0.21.0
# golang.org/x/oauth2 v0.22.0
## explicit; go 1.18
golang.org/x/oauth2
golang.org/x/oauth2/authhandler
Expand Down Expand Up @@ -1913,7 +1913,7 @@ kmodules.xyz/apiversion
# kmodules.xyz/apply v0.29.0
## explicit; go 1.21.5
kmodules.xyz/apply
# kmodules.xyz/client-go v0.30.16
# kmodules.xyz/client-go v0.30.21
## explicit; go 1.22.0
kmodules.xyz/client-go
kmodules.xyz/client-go/api/v1
Expand Down

0 comments on commit 26005dc

Please sign in to comment.