Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Populating Juju controller config no longer immediately fails if Juju CLI does not exist #362

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,16 @@ const (
// controller as a fallback.
func populateJujuProviderModelLive() (jujuProviderModel, error) {
data := jujuProviderModel{}
controllerConfig, err := juju.GetLocalControllerConfig()
if err != nil {
Osama-Kassem marked this conversation as resolved.
Show resolved Hide resolved
return data, err
}

controllerConfig, cliNotExist := juju.GetLocalControllerConfig()
data.ControllerAddrs = types.StringValue(getField(JujuControllerEnvKey, controllerConfig))
data.UserName = types.StringValue(getField(JujuUsernameEnvKey, controllerConfig))
data.Password = types.StringValue(getField(JujuPasswordEnvKey, controllerConfig))
data.CACert = types.StringValue(getField(JujuCACertEnvKey, controllerConfig))
// Only error if a valid controller config could not be fetched
// from the environment variables.
if cliNotExist != nil && !data.valid() {
return data, errors.New("unable to acquire Juju controller config: no working Juju client, and environment variables are not fully set")
}

return data, nil
}
Expand Down