Skip to content

Commit

Permalink
KRBN-8115: should not depend on existence of file "/etc/nutanix/confi…
Browse files Browse the repository at this point in the history
…g/prismCentral"
  • Loading branch information
yanhua121 committed Apr 8, 2024
1 parent 767aef4 commit d13fcc7
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions pkg/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,17 +106,19 @@ func (n *NutanixClientHelper) buildManagementEndpoint(ctx context.Context, nutan
}
if providerForNutanixCluster != nil {
providers = append(providers, providerForNutanixCluster)
log.Info(fmt.Sprintf("use the prismCentral endpoint from NutanixCluster %s", nutanixCluster.Name))

} else {
log.Info(fmt.Sprintf("[WARNING] prismCentral attribute was not set on NutanixCluster %s in namespace %s. Defaulting to CAPX manager credentials", nutanixCluster.Name, nutanixCluster.Namespace))
}

// Fallback to building a provider using the global CAPX manager credentials
providerForLocalFile, err := n.buildProviderFromFile()
if err != nil {
return nil, fmt.Errorf("error building an environment provider from file: %w", err)
}
if providerForLocalFile != nil {
providers = append(providers, providerForLocalFile)
// Fallback to building a provider using the global CAPX manager credentials
providerForLocalFile, err := n.buildProviderFromFile()
if err != nil {
return nil, fmt.Errorf("error building an environment provider from file: %w", err)
}
if providerForLocalFile != nil {
providers = append(providers, providerForLocalFile)
}
}

// Initialize environment with providers
Expand All @@ -126,6 +128,8 @@ func (n *NutanixClientHelper) buildManagementEndpoint(ctx context.Context, nutan
if err != nil {
return nil, fmt.Errorf("failed to get management endpoint object: %w", err)
}
log.Info(fmt.Sprintf("The prismCentral endpoint: %+v", *me.Address))

return me, nil
}

Expand Down

0 comments on commit d13fcc7

Please sign in to comment.