Skip to content

Commit

Permalink
fix: Parse flags before loading kubeconfig
Browse files Browse the repository at this point in the history
To respect the --kubeconfig flag, we must parse it before loading the
kubeconfig.
  • Loading branch information
dlipovetsky committed Jan 15, 2025
1 parent fec1de5 commit 4216b8a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -306,14 +306,15 @@ func initializeManager(config *managerConfig) (manager.Manager, error) {
func main() {
logger := setupLogger()

restConfig := ctrl.GetConfigOrDie()

config := &managerConfig{
logger: logger,
restConfig: restConfig,
}
config := &managerConfig{}

Check warning on line 309 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L309

Added line #L309 was not covered by tests
parseFlags(config)

// Flags must be parsed before calling GetConfigOrDie, because
// it reads the value of the--kubeconfig flag.
config.restConfig = ctrl.GetConfigOrDie()

config.logger = logger

Check warning on line 317 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L312-L317

Added lines #L312 - L317 were not covered by tests
logger.Info("Initializing Nutanix Cluster API Infrastructure Provider", "Git Hash", gitCommitHash)
mgr, err := initializeManager(config)
if err != nil {
Expand Down

0 comments on commit 4216b8a

Please sign in to comment.