Skip to content

Commit

Permalink
Populating Juju controller config no longer immediately fails if Juju…
Browse files Browse the repository at this point in the history
… CLI does not exist.
  • Loading branch information
Osama-Kassem committed Dec 13, 2023
1 parent 41f36f2 commit a7a54e2
Showing 1 changed file with 6 additions and 5 deletions.
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 {
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

0 comments on commit a7a54e2

Please sign in to comment.