Skip to content

Commit

Permalink
Merge pull request #503 from hmlanigan/fix-cli-discovery
Browse files Browse the repository at this point in the history
fix: live discovery of data needed for juju
  • Loading branch information
hmlanigan authored Jun 20, 2024
2 parents 0931bec + c02077e commit e2e123d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func jujuProviderModelEnvVar() jujuProviderModel {
func jujuProviderModelLiveDiscovery() (jujuProviderModel, bool) {
data := jujuProviderModel{}
controllerConfig, cliNotExist := juju.GetLocalControllerConfig()
if cliNotExist {
return data, false
}

if ctrlAddrs, ok := controllerConfig[JujuControllerEnvKey]; ok && ctrlAddrs != "" {
data.ControllerAddrs = types.StringValue(ctrlAddrs)
Expand All @@ -73,7 +76,7 @@ func jujuProviderModelLiveDiscovery() (jujuProviderModel, bool) {
if password, ok := controllerConfig[JujuPasswordEnvKey]; ok && password != "" {
data.Password = types.StringValue(password)
}
return data, cliNotExist
return data, true
}

func getEnvVar(field string) types.String {
Expand Down
1 change: 0 additions & 1 deletion internal/provider/resource_application.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/hashicorp/terraform-plugin-framework/types"
"github.com/hashicorp/terraform-plugin-log/tflog"
"github.com/juju/errors"

"github.com/juju/juju/core/constraints"

"github.com/juju/terraform-provider-juju/internal/juju"
Expand Down

0 comments on commit e2e123d

Please sign in to comment.