forked from openshift/cloud-credential-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecretannotator_controller.go
58 lines (49 loc) · 2.63 KB
/
secretannotator_controller.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
Copyright 2018 The OpenShift 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 secretannotator
import (
configv1 "github.com/openshift/api/config/v1"
"sigs.k8s.io/controller-runtime/pkg/manager"
"github.com/openshift/cloud-credential-operator/pkg/operator/platform"
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/aws"
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/azure"
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/gcp"
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/openstack"
"github.com/openshift/cloud-credential-operator/pkg/operator/secretannotator/vsphere"
log "github.com/sirupsen/logrus"
)
func Add(mgr, rootCredentialManager manager.Manager, kubeconfig string) error {
infraStatus, err := platform.GetInfraStatusUsingKubeconfig(kubeconfig)
if err != nil {
log.Fatal(err)
}
platformType := platform.GetType(infraStatus)
log.Infof("Setting up secret annotator. Platform Type is %s", platformType)
switch platformType {
case configv1.AzurePlatformType:
return azure.Add(mgr, rootCredentialManager, azure.NewReconciler(mgr.GetClient(), rootCredentialManager))
case configv1.AWSPlatformType:
return aws.Add(mgr, rootCredentialManager, aws.NewReconciler(mgr.GetClient(), rootCredentialManager))
case configv1.GCPPlatformType:
if infraStatus.PlatformStatus == nil || infraStatus.PlatformStatus.GCP == nil {
log.Fatalf("Missing GCP configuration in infrastructure platform status")
}
return gcp.Add(mgr, rootCredentialManager, gcp.NewReconciler(mgr.GetClient(), rootCredentialManager, infraStatus.PlatformStatus.GCP.ProjectID))
case configv1.VSpherePlatformType:
return vsphere.Add(mgr, rootCredentialManager, vsphere.NewReconciler(mgr.GetClient(), rootCredentialManager))
case configv1.OpenStackPlatformType:
return openstack.Add(mgr, rootCredentialManager, openstack.NewReconciler(mgr.GetClient(), rootCredentialManager))
default: // returning the AWS implementation for default to avoid changing any behavior
return aws.Add(mgr, rootCredentialManager, aws.NewReconciler(mgr.GetClient(), rootCredentialManager))
}
}