Skip to content

Commit

Permalink
feat: enable gke by default in capiprovider controller
Browse files Browse the repository at this point in the history
Signed-off-by: Carlos Salas <[email protected]>
  • Loading branch information
salasberryfin committed Nov 11, 2024
1 parent 427b54d commit 772fee9
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
2 changes: 2 additions & 0 deletions internal/controllers/capiprovider_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ func (r *CAPIProviderReconciler) sync(ctx context.Context, capiProvider *turtles
switch cmp.Or(capiProvider.Spec.Name, capiProvider.GetName()) {
case "azure":
s = append(s, sync.NewAzureProviderSync(r.Client, capiProvider))
case "gcp":
s = append(s, sync.NewGCPProviderSync(r.Client, capiProvider))
default:
s = append(s, sync.NewProviderSync(r.Client, capiProvider))
}
Expand Down
55 changes: 55 additions & 0 deletions internal/sync/gcp_provider_sync.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
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 sync

import (
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
"sigs.k8s.io/controller-runtime/pkg/client"

// operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"

turtlesv1 "github.com/rancher/turtles/api/v1alpha1"
"github.com/rancher/turtles/internal/api"
)

// NewGCPProviderSync creates a new mirror object.
func NewGCPProviderSync(cl client.Client, capiProvider *turtlesv1.CAPIProvider) Sync {
template := ProviderSync{}.Template(capiProvider)

destination, ok := template.(api.Provider)
if !ok || destination == nil {
return nil
}

spec := capiProvider.GetSpec()
if spec.Deployment == nil {
spec.Deployment = &operatorv1.DeploymentSpec{}
}

capiProvider.SetSpec(spec)

if capiProvider.Spec.Variables == nil {
capiProvider.Spec.Variables = map[string]string{}
}

capiProvider.Spec.Variables["EXP_CAPG_GKE"] = "true"

return &ProviderSync{
DefaultSynchronizer: NewDefaultSynchronizer(cl, capiProvider, template),
Destination: destination,
}
}

0 comments on commit 772fee9

Please sign in to comment.