Skip to content

Commit

Permalink
Merge pull request #342 from Danil-Grigorev/rancher-credentials-mapping
Browse files Browse the repository at this point in the history
✨Implement initial rancher credentials mapping
  • Loading branch information
richardcase committed Jan 17, 2024
2 parents 7ff0769 + b128d78 commit 2627ed4
Show file tree
Hide file tree
Showing 20 changed files with 1,130 additions and 588 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ CLUSTERCTL_VER := v1.4.6
CLUSTERCTL_BIN := clusterctl
CLUSTERCTL := $(TOOLS_BIN_DIR)/$(CLUSTERCTL_BIN)-$(CLUSTERCTL_VER)

GOLANGCI_LINT_VER := v1.53.3
GOLANGCI_LINT_VER := v1.55.2
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN))

Expand Down
26 changes: 0 additions & 26 deletions api/v1alpha1/capiprovider_conditions.go

This file was deleted.

80 changes: 80 additions & 0 deletions api/v1alpha1/capiprovider_wrapper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/*
Copyright © 2023 - 2024 SUSE LLC
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 v1alpha1

import (
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

var _ operatorv1.GenericProvider = &CAPIProvider{}

// GetConditions returns the Conditions field from the CAPIProvider status.
func (b *CAPIProvider) GetConditions() clusterv1.Conditions {
return b.Status.Conditions
}

// SetConditions updates the Conditions field in the CAPIProvider status.
func (b *CAPIProvider) SetConditions(conditions clusterv1.Conditions) {
b.Status.Conditions = conditions
}

// GetSpec returns the Spec field in the CAPIProvider status.
func (b *CAPIProvider) GetSpec() operatorv1.ProviderSpec {
return b.Spec.ProviderSpec
}

// SetSpec updates the Spec field in the CAPIProvider status.
func (b *CAPIProvider) SetSpec(in operatorv1.ProviderSpec) {
b.Spec.ProviderSpec = in
}

// GetStatus returns the Status.ProviderStatus field in the CAPIProvider status.
func (b *CAPIProvider) GetStatus() operatorv1.ProviderStatus {
return b.Status.ProviderStatus
}

// SetStatus updates the Status.ProviderStatus field in the CAPIProvider status.
func (b *CAPIProvider) SetStatus(in operatorv1.ProviderStatus) {
b.Status.ProviderStatus = in
}

// GetType returns the type of the CAPIProvider.
func (b *CAPIProvider) GetType() string {
return "capiprovider"
}

// GetItems returns the list of GenericProviders for CAPIProviderList.
func (b *CAPIProviderList) GetItems() []operatorv1.GenericProvider {
providers := []operatorv1.GenericProvider{}

for index := range b.Items {
providers = append(providers, &b.Items[index])
}

return providers
}

// SetVariables updates the Variables field in the CAPIProvider status.
func (b *CAPIProvider) SetVariables(v map[string]string) {
b.Status.Variables = v
}

// SetPhase updates the Phase field in the CAPIProvider status.
func (b *CAPIProvider) SetPhase(p Phase) {
b.Status.Phase = p
}
30 changes: 30 additions & 0 deletions api/v1alpha1/conditions_consts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright © 2023 - 2024 SUSE LLC
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 v1alpha1

import clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

const (
// RancherCredentialsSecretCondition provides information on Rancher credentials secret mapping result.
RancherCredentialsSecretCondition clusterv1.ConditionType = "RancherCredentialsSecretMapped"

// RancherCredentialKeyMissing notifies about missing credential secret key required for provider during credentials mapping.
RancherCredentialKeyMissing = "RancherCredentialKeyMissing"

// RancherCredentialSourceMissing occures when a source credential secret is missing.
RancherCredentialSourceMissing = "RancherCredentialSourceMissing"
)
40 changes: 33 additions & 7 deletions api/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,44 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

// Providers is a list of registered CAPI Operator resources satisfying Provider interface.
Providers = []operatorv1.GenericProvider{
&operatorv1.CoreProvider{},
&operatorv1.BootstrapProvider{},
&operatorv1.ControlPlaneProvider{},
&operatorv1.InfrastructureProvider{},
&operatorv1.AddonProvider{},
&operatorv1.IPAMProvider{},
}

// ProviderLists is a list of registered CAPI Operator resources satisfying ProviderList interface.
ProviderLists = []operatorv1.GenericProviderList{
&operatorv1.CoreProviderList{},
&operatorv1.BootstrapProviderList{},
&operatorv1.ControlPlaneProviderList{},
&operatorv1.InfrastructureProviderList{},
&operatorv1.AddonProviderList{},
&operatorv1.IPAMProviderList{},
}
)

// AddKnownTypes adds the list of known types to api.Scheme.
func AddKnownTypes(scheme *runtime.Scheme) {
scheme.AddKnownTypes(GroupVersion, &CAPIProvider{}, &CAPIProviderList{})
scheme.AddKnownTypes(operatorv1.GroupVersion,
&operatorv1.CoreProvider{}, &operatorv1.CoreProviderList{},
&operatorv1.BootstrapProvider{}, &operatorv1.BootstrapProviderList{},
&operatorv1.ControlPlaneProvider{}, &operatorv1.ControlPlaneProviderList{},
&operatorv1.InfrastructureProvider{}, &operatorv1.InfrastructureProviderList{},
&operatorv1.AddonProvider{}, &operatorv1.AddonProviderList{},
)

for _, provider := range Providers {
if provider, ok := provider.(runtime.Object); ok {
scheme.AddKnownTypes(operatorv1.GroupVersion, provider)
}
}

for _, providerList := range ProviderLists {
if providerList, ok := providerList.(runtime.Object); ok {
scheme.AddKnownTypes(operatorv1.GroupVersion, providerList)
}
}

metav1.AddToGroupVersion(scheme, GroupVersion)
metav1.AddToGroupVersion(scheme, operatorv1.GroupVersion)
}
2 changes: 2 additions & 0 deletions api/v1alpha1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ const (
Bootstrap Type = "bootstrap"
// Addon is the name for the addon CAPI Provider.
Addon Type = "addon"
// IPAM is the name for the addon for IPAM CAPI Provider.
IPAM Type = "ipam"
)

// ToKind converts ProviderType to CAPI Operator provider object kind.
Expand Down
2 changes: 1 addition & 1 deletion charts/rancher-turtles/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ keywords:
- provisioning
dependencies:
- name: cluster-api-operator
version: v0.6.0
version: v0.8.1
repository: https://kubernetes-sigs.github.io/cluster-api-operator
condition: cluster-api-operator.enabled
annotations:
Expand Down
61 changes: 29 additions & 32 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,41 @@ require (
github.com/pkg/errors v0.9.1
github.com/spf13/pflag v1.0.5
golang.org/x/text v0.14.0
k8s.io/api v0.27.7
k8s.io/apiextensions-apiserver v0.27.7
k8s.io/apimachinery v0.27.7
k8s.io/client-go v0.27.7
k8s.io/component-base v0.27.7
k8s.io/klog/v2 v2.90.1
k8s.io/api v0.28.5
k8s.io/apiextensions-apiserver v0.28.5
k8s.io/apimachinery v0.28.5
k8s.io/client-go v0.28.5
k8s.io/component-base v0.28.5
k8s.io/klog/v2 v2.100.1
k8s.io/utils v0.0.0-20230726121419-3b25d923346b
sigs.k8s.io/cluster-api v1.5.3
sigs.k8s.io/cluster-api-operator v0.7.0
sigs.k8s.io/controller-runtime v0.15.3
sigs.k8s.io/cluster-api v1.6.0
sigs.k8s.io/cluster-api-operator v0.8.1
sigs.k8s.io/controller-runtime v0.16.3
)

require (
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/blang/semver/v4 v4.0.0 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.2 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/evanphx/json-patch/v5 v5.7.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.3 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/gobuffalo/flect v1.0.2 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/huandu/xstrings v1.4.0 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/josharian/intern v1.0.0 // indirect
Expand All @@ -54,31 +53,29 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/prometheus/client_golang v1.16.0 // indirect
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/prometheus/client_golang v1.17.0 // indirect
github.com/prometheus/client_model v0.4.1-0.20230718164431-9a2bf3000d16 // indirect
github.com/prometheus/common v0.44.0 // indirect
github.com/prometheus/procfs v0.11.1 // indirect
github.com/stretchr/testify v1.8.3 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
go.uber.org/multierr v1.11.0 // indirect
go.uber.org/zap v1.25.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.18.0 // indirect
golang.org/x/oauth2 v0.11.0 // indirect
golang.org/x/sys v0.14.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.15.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20230711160842-782d3b101e98 // indirect
google.golang.org/protobuf v1.31.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiserver v0.27.7 // indirect
k8s.io/cluster-bootstrap v0.27.2 // indirect
k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect
k8s.io/apiserver v0.28.5 // indirect
k8s.io/cluster-bootstrap v0.28.4 // indirect
k8s.io/kube-openapi v0.0.0-20230717233707-2695361300d9 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
Expand Down
Loading

0 comments on commit 2627ed4

Please sign in to comment.