Skip to content

Commit f731315

Browse files
authored
fix: Parse flags before loading kubeconfig (#494)
To respect the --kubeconfig flag, we must parse it before loading the kubeconfig.
1 parent c623231 commit f731315

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

main.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,15 @@ func initializeManager(config *managerConfig) (manager.Manager, error) {
306306
func main() {
307307
logger := setupLogger()
308308

309-
restConfig := ctrl.GetConfigOrDie()
310-
311-
config := &managerConfig{
312-
logger: logger,
313-
restConfig: restConfig,
314-
}
309+
config := &managerConfig{}
315310
parseFlags(config)
316311

312+
// Flags must be parsed before calling GetConfigOrDie, because
313+
// it reads the value of the--kubeconfig flag.
314+
config.restConfig = ctrl.GetConfigOrDie()
315+
316+
config.logger = logger
317+
317318
logger.Info("Initializing Nutanix Cluster API Infrastructure Provider", "Git Hash", gitCommitHash)
318319
mgr, err := initializeManager(config)
319320
if err != nil {

0 commit comments

Comments
 (0)