Skip to content

Commit

Permalink
Make clusterctl support for cert-manager more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Jun 8, 2021
1 parent 369c3ca commit 477fd77
Show file tree
Hide file tree
Showing 18 changed files with 734 additions and 26,897 deletions.
22 changes: 22 additions & 0 deletions cmd/clusterctl/api/v1alpha3/annotations.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
Copyright 2021 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha3

const (
// CertManagerVersionAnnotation reports the cert manager version installed by clusterctl.
CertManagerVersionAnnotation = "cert-manager.clusterctl.cluster.x-k8s.io/version"
)
7 changes: 4 additions & 3 deletions cmd/clusterctl/api/v1alpha3/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const (
// ClusterctlCoreLabelInventoryValue define the value for ClusterctlCoreLabelName to be used for inventory objects.
ClusterctlCoreLabelInventoryValue = "inventory"

// ClusterctlCoreLabelCertManagerValue define the value for ClusterctlCoreLabelName to be used for cert-manager objects.
ClusterctlCoreLabelCertManagerValue = "cert-manager"

// ClusterctlMoveLabelName can be set on CRDs that providers wish to move but that are not part of a Cluster.
ClusterctlMoveLabelName = "clusterctl.cluster.x-k8s.io/move"

Expand All @@ -41,15 +44,13 @@ const (
// it's not meant to be used to describe each instance of a particular provider.
func ManifestLabel(name string, providerType ProviderType) string {
switch providerType {
case CoreProviderType:
return name
case BootstrapProviderType:
return fmt.Sprintf("bootstrap-%s", name)
case ControlPlaneProviderType:
return fmt.Sprintf("control-plane-%s", name)
case InfrastructureProviderType:
return fmt.Sprintf("infrastructure-%s", name)
default:
return fmt.Sprintf("unknown-type-%s", name)
return name
}
}
28 changes: 20 additions & 8 deletions cmd/clusterctl/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ func (f fakeClusterClient) Proxy() cluster.Proxy {
return f.fakeProxy
}

func (f *fakeClusterClient) CertManager() (cluster.CertManagerClient, error) {
return f.certManager, nil
func (f *fakeClusterClient) CertManager() cluster.CertManagerClient {
return f.certManager
}

func (f fakeClusterClient) ProviderComponents() cluster.ComponentsClient {
Expand Down Expand Up @@ -355,6 +355,10 @@ type fakeConfigClient struct {

var _ config.Client = &fakeConfigClient{}

func (f fakeConfigClient) CertManager() config.CertManagerClient {
return f.internalclient.CertManager()
}

func (f fakeConfigClient) Providers() config.ProvidersClient {
return f.internalclient.Providers()
}
Expand Down Expand Up @@ -522,13 +526,12 @@ type fakeComponentClient struct {
processor yaml.Processor
}

func (f *fakeComponentClient) Get(options repository.ComponentsOptions) (repository.Components, error) {
if options.Version == "" {
options.Version = f.fakeRepository.DefaultVersion()
}
path := f.fakeRepository.ComponentsPath()
func (f *fakeComponentClient) Raw(options repository.ComponentsOptions) ([]byte, error) {
return f.getRawBytes(&options)
}

content, err := f.fakeRepository.GetFile(options.Version, path)
func (f *fakeComponentClient) Get(options repository.ComponentsOptions) (repository.Components, error) {
content, err := f.getRawBytes(&options)
if err != nil {
return nil, err
}
Expand All @@ -543,3 +546,12 @@ func (f *fakeComponentClient) Get(options repository.ComponentsOptions) (reposit
},
)
}

func (f *fakeComponentClient) getRawBytes(options *repository.ComponentsOptions) ([]byte, error) {
if options.Version == "" {
options.Version = f.fakeRepository.DefaultVersion()
}
path := f.fakeRepository.ComponentsPath()

return f.fakeRepository.GetFile(options.Version, path)
}
Loading

0 comments on commit 477fd77

Please sign in to comment.