Skip to content

Commit

Permalink
Detect tsuru_target to tsuru_app_deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
wpjunior committed Jun 20, 2024
1 parent bec1b2e commit cc4d422
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/tsuru/go-tsuruclient/pkg/client"
"github.com/tsuru/go-tsuruclient/pkg/config"
"github.com/tsuru/go-tsuruclient/pkg/tsuru"
)

Expand Down Expand Up @@ -127,11 +128,21 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, terraformVer
}
}

var err error
host := d.Get("host").(string)
if host != "" {
cfg.BasePath = host
os.Setenv("TSURU_TARGET", host)
if host == "" {
host = os.Getenv("TSURU_TARGET")
}
if host == "" {
host, err = config.GetTarget()
if err != nil {
return nil, diag.FromErr(err)
}
}

cfg.BasePath = host
os.Setenv("TSURU_TARGET", host)

token := d.Get("token").(string)
if token != "" {
cfg.DefaultHeader["Authorization"] = token
Expand Down

0 comments on commit cc4d422

Please sign in to comment.