From a7a54e2927b69cdaf302e4fbb5fe4d87969f5251 Mon Sep 17 00:00:00 2001 From: Osama Kassem Date: Thu, 7 Dec 2023 11:20:37 +0300 Subject: [PATCH] Populating Juju controller config no longer immediately fails if Juju CLI does not exist. --- internal/provider/provider.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 89d21d1e..f5f80625 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -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 }