@@ -19,10 +19,12 @@ package main
19
19
import (
20
20
"context"
21
21
"errors"
22
+ "flag"
22
23
"os"
23
24
24
25
"golang.org/x/sync/errgroup"
25
26
clusterinventoryv1alpha1 "sigs.k8s.io/cluster-inventory-api/apis/v1alpha1"
27
+ "sigs.k8s.io/cluster-inventory-api/pkg/credentials"
26
28
27
29
corev1 "k8s.io/api/core/v1"
28
30
apierrors "k8s.io/apimachinery/pkg/api/errors"
@@ -50,6 +52,9 @@ func init() {
50
52
}
51
53
52
54
func main () {
55
+ credentialsProviderFile := credentials .SetupProviderFileFlag ()
56
+ flag .Parse ()
57
+
53
58
ctrllog .SetLogger (zap .New (zap .UseDevMode (true )))
54
59
entryLog := ctrllog .Log .WithName ("entrypoint" )
55
60
ctx := signals .SetupSignalHandler ()
@@ -61,13 +66,25 @@ func main() {
61
66
os .Exit (1 )
62
67
}
63
68
64
- // Create the provider against the local manager.
69
+ // Load credential providers from configuration file
70
+ credentialsProvider , err := credentials .NewFromFile (* credentialsProviderFile )
71
+ if err != nil {
72
+ entryLog .Error (err , "Got error reading credentials providers" )
73
+ os .Exit (1 )
74
+ }
75
+
76
+ // Create the provider.
65
77
provider , err := clusterinventoryapi .New (clusterinventoryapi.Options {
78
+ // Specifying the strategy how to fetch kubeconfig from ClusterProfile.
66
79
KubeconfigStrategyOption : kubeconfigstrategy.Option {
67
- // Use the Secret strategy with a specific consumer name.
68
- Secret : kubeconfigstrategy.SecretStrategyOption {
69
- ConsumerName : "cluster-inventory-api-consumer" ,
80
+ CredentialsProvider : & kubeconfigstrategy.CredentialsProviderOption {
81
+ Provider : credentialsProvider ,
70
82
},
83
+ // // Alternative:
84
+ // // You can use the Secret strategy, but it is not recommended for production use.
85
+ // Secret: &kubeconfigstrategy.SecretStrategyOption{
86
+ // ConsumerName: "cluster-inventory-api-consumer",
87
+ // },
71
88
},
72
89
})
73
90
if err != nil {
@@ -76,7 +93,7 @@ func main() {
76
93
}
77
94
78
95
// Create a multi-cluster manager attached to the provider.
79
- entryLog .Info ("Setting up local manager" )
96
+ entryLog .Info ("Setting up manager" )
80
97
mcMgr , err := mcmanager .New (cfg , provider , manager.Options {
81
98
LeaderElection : false ,
82
99
Metrics : metricsserver.Options {
0 commit comments