Skip to content

Commit

Permalink
Update code to use API interface for generic provider
Browse files Browse the repository at this point in the history
Signed-off-by: Danil Grigorev <[email protected]>
  • Loading branch information
Danil-Grigorev committed Dec 1, 2023
1 parent bb170cc commit e87edf3
Show file tree
Hide file tree
Showing 20 changed files with 503 additions and 1,144 deletions.
4 changes: 2 additions & 2 deletions cmd/plugin/cmd/upgrade_plan.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"github.com/spf13/cobra"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"

"sigs.k8s.io/cluster-api-operator/internal/controller/genericprovider"
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
)

type upgradePlanOptions struct {
Expand All @@ -50,7 +50,7 @@ type upgradePlan struct {

// upgradeItem defines a possible upgrade target for a provider in the management cluster.
type upgradeItem struct {
genericprovider.GenericProvider
operatorv1.GenericProvider
NextVersion string
}

Expand Down
42 changes: 42 additions & 0 deletions controllers/alias.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
Copyright 2023 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 controllers

import (
"k8s.io/client-go/rest"
"sigs.k8s.io/cluster-api-operator/api/v1alpha2"
providercontroller "sigs.k8s.io/cluster-api-operator/internal/controller"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
)

type GenericProviderReconciler struct {
Provider v1alpha2.GenericProvider
ProviderList v1alpha2.GenericProviderList
Client client.Client
Config *rest.Config
}

func (r *GenericProviderReconciler) SetupWithManager(mgr ctrl.Manager, options controller.Options) error {
return (&providercontroller.GenericProviderReconciler{
Provider: r.Provider,
ProviderList: r.ProviderList,
Client: r.Client,
Config: r.Config,
}).SetupWithManager(mgr, options)
}
3 changes: 1 addition & 2 deletions internal/controller/component_customizer.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import (
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
"k8s.io/utils/pointer"
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
"sigs.k8s.io/cluster-api-operator/internal/controller/genericprovider"
"sigs.k8s.io/cluster-api/util"
)

Expand All @@ -44,7 +43,7 @@ const (
var bool2Str = map[bool]string{true: "true", false: "false"}

// customizeObjectsFn apply provider specific customization to a list of manifests.
func customizeObjectsFn(provider genericprovider.GenericProvider) func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error) {
func customizeObjectsFn(provider operatorv1.GenericProvider) func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error) {
return func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error) {
results := []unstructured.Unstructured{}

Expand Down
5 changes: 3 additions & 2 deletions internal/controller/component_patches.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@ import (
"context"

"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"sigs.k8s.io/cluster-api-operator/internal/controller/genericprovider"

operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
"sigs.k8s.io/cluster-api-operator/internal/patch"
ctrl "sigs.k8s.io/controller-runtime"
)

func applyPatches(ctx context.Context, provider genericprovider.GenericProvider) func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error) {
func applyPatches(ctx context.Context, provider operatorv1.GenericProvider) func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error) {
log := ctrl.LoggerFrom(ctx)

return func(objs []unstructured.Unstructured) ([]unstructured.Unstructured, error) {
Expand Down
77 changes: 0 additions & 77 deletions internal/controller/genericprovider/addonprovider_wrapper.go

This file was deleted.

77 changes: 0 additions & 77 deletions internal/controller/genericprovider/bootstrapprovider_wrapper.go

This file was deleted.

This file was deleted.

Loading

0 comments on commit e87edf3

Please sign in to comment.