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

add support for no_cleanup_on_delete on application #57

Merged
merged 1 commit into from
Jul 3, 2024
Merged
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
## 0.1.25 (unreleased)
## 0.1.26 (unreleased)

## 0.1.25

FEATURES:
- Add support for `prodvana_application.no_cleanup_on_delete`

## 0.1.24

Expand Down
1 change: 1 addition & 0 deletions docs/resources/application.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ resource "prodvana_application" "example" {
### Optional

- `description` (String) Application description
- `no_cleanup_on_delete` (Boolean) Prevent the application from being deleted when the resource is destroyed

### Read-Only

Expand Down
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ require (
github.com/hashicorp/terraform-plugin-testing v1.1.0
github.com/mitchellh/go-homedir v1.1.0
github.com/pkg/errors v0.9.1
github.com/prodvana/prodvana-public/go/prodvana-sdk v0.3.47
github.com/prodvana/prodvana-public/go/prodvana-sdk v0.3.49
golang.org/x/exp v0.0.0-20230321023759-10a507213a29
google.golang.org/grpc v1.63.2
google.golang.org/grpc v1.64.0
google.golang.org/protobuf v1.34.1
k8s.io/api v0.27.3
k8s.io/apimachinery v0.27.3
Expand Down Expand Up @@ -44,7 +44,7 @@ require (
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-checkpoint v0.5.0 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand Down Expand Up @@ -93,14 +93,14 @@ require (
golang.org/x/crypto v0.21.0 // indirect
golang.org/x/mod v0.12.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/oauth2 v0.17.0 // indirect
golang.org/x/oauth2 v0.20.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/term v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/text v0.15.0 // indirect
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
Expand Down
28 changes: 14 additions & 14 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 h1:bkypFPDjIYGfCYD5mRBvpqxfYX1YCS1PXdKYWi8FsN0=
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0/go.mod h1:P+Lt/0by1T8bfcF3z737NnSbmxQAppXMRziHUxPOC8k=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I=
github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
Expand Down Expand Up @@ -246,8 +246,8 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/posener/complete v1.2.3 h1:NP0eAhjcjImqslEwo/1hq7gpajME0fTLTezBKDqfXqo=
github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s=
github.com/prodvana/prodvana-public/go/prodvana-sdk v0.3.47 h1:AbOe5D2LN+zL1w6OPaeMoCW7Q9Fb8kwUIsHLxL8CclU=
github.com/prodvana/prodvana-public/go/prodvana-sdk v0.3.47/go.mod h1:WcMLLC/WICmzCdzjUHDlz3iGxZCtgKJ7akbpQpebjxc=
github.com/prodvana/prodvana-public/go/prodvana-sdk v0.3.49 h1:8NC+XtOIjsuaZAEPP5bNavcidrkl5SbEkx49vzWTRyI=
github.com/prodvana/prodvana-public/go/prodvana-sdk v0.3.49/go.mod h1:n19mDn+5SxmlniCXDZQ4e16xOYI7X9ODoUeeAG1CM5s=
github.com/prodvana/vtprotobuf v0.6.1-pvn h1:0+wJuxnPw9Otnx8qC6pnJnryVjHWcK/RswaPMEWa1XU=
github.com/prodvana/vtprotobuf v0.6.1-pvn/go.mod h1:t/avpk3KcrXxUnYOhZhMXJlSEyie6gQbtLq5NM3loB8=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down Expand Up @@ -346,8 +346,8 @@ golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/net v0.23.0 h1:7EYJ93RZ9vYSZAIb2x3lnuvqO5zneoD6IvWjuhfxjTs=
golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.17.0 h1:6m3ZPmLEFdVxKKWnKq4VqZ60gutO35zm+zrAHVmHyDQ=
golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA=
golang.org/x/oauth2 v0.20.0 h1:4mQdhULixXKP1rwYBW0vAijoXnkTG0BLCDRzfe1idMo=
golang.org/x/oauth2 v0.20.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand Down Expand Up @@ -390,8 +390,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 h1:vVKdlvoWBphwdxWKrFZEuM0kGgGLxUOYcY4U/2Vjg44=
golang.org/x/time v0.0.0-20220210224613-90d013bbcef8/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
Expand All @@ -418,15 +418,15 @@ google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoA
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no=
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c h1:kaI7oewGK5YnVwj+Y+EJBO/YN1ht8iTL9XkFHtVZLsc=
google.golang.org/genproto/googleapis/api v0.0.0-20240314234333-6e1732d8331c/go.mod h1:VQW3tUculP/D4B+xVCo+VgSq8As6wA9ZjHl//pmk+6s=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2 h1:9IZDv+/GcI6u+a4jRFRLxQs0RUCfavGfoOgEW6jpkI0=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs=
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8 h1:W5Xj/70xIA4x60O/IFyXivR5MGqblAb8R3w26pnD6No=
google.golang.org/genproto/googleapis/api v0.0.0-20240513163218-0867130af1f8/go.mod h1:vPrPUTsDCYxXWjP7clS81mZ6/803D8K4iM9Ma27VKas=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8 h1:mxSlqyb8ZAHsYDCfiXN1EDdNTdvjUJSLY+OnAUtYNYA=
google.golang.org/genproto/googleapis/rpc v0.0.0-20240513163218-0867130af1f8/go.mod h1:I7Y+G38R2bu5j1aLzfFmQfTcU/WnFuqDwLZAbvKTKpM=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.63.2 h1:MUeiw1B2maTVZthpU5xvASfTh3LDbxHd6IJ6QQVU+xM=
google.golang.org/grpc v1.63.2/go.mod h1:WAX/8DgncnokcFUldAxq7GeB5DXHDbMF+lLvDomNkRA=
google.golang.org/grpc v1.64.0 h1:KH3VH9y/MgNQg1dE7b3XfVK0GsPSIzJwdF617gUSbvY=
google.golang.org/grpc v1.64.0/go.mod h1:oxjF8E3FBnjp+/gVFYdWacaLDx9na1aqy9oovLpxQYg=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
22 changes: 16 additions & 6 deletions internal/provider/application_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/hashicorp/terraform-plugin-framework/path"
"github.com/hashicorp/terraform-plugin-framework/resource"
"github.com/hashicorp/terraform-plugin-framework/resource/schema"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/booldefault"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/planmodifier"
"github.com/hashicorp/terraform-plugin-framework/resource/schema/stringplanmodifier"
"github.com/hashicorp/terraform-plugin-framework/schema/validator"
Expand All @@ -40,10 +41,11 @@ type ApplicationResource struct {

// ApplicationResourceModel describes the resource data model.
type ApplicationResourceModel struct {
Name types.String `tfsdk:"name"`
Description types.String `tfsdk:"description"`
Id types.String `tfsdk:"id"`
Version types.String `tfsdk:"version"`
Name types.String `tfsdk:"name"`
Description types.String `tfsdk:"description"`
Id types.String `tfsdk:"id"`
Version types.String `tfsdk:"version"`
NoCleanupOnDelete types.Bool `tfsdk:"no_cleanup_on_delete"`
}

func (r *ApplicationResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
Expand Down Expand Up @@ -80,6 +82,12 @@ func (r *ApplicationResource) Schema(ctx context.Context, req resource.SchemaReq
stringvalidator.LengthAtLeast(1),
},
},
"no_cleanup_on_delete": schema.BoolAttribute{
MarkdownDescription: "Prevent the application from being deleted when the resource is destroyed",
Optional: true,
Computed: true,
Default: booldefault.StaticBool(false),
},
},
}
}
Expand Down Expand Up @@ -119,6 +127,7 @@ func readApplicationData(ctx context.Context, client app_pb.ApplicationManagerCl
data.Name = types.StringValue(appMeta.Name)
data.Id = types.StringValue(appMeta.Id)
data.Version = types.StringValue(appMeta.Version)
data.NoCleanupOnDelete = types.BoolValue(getAppResp.Application.Config.NoCleanupOnDelete)

if getAppResp.Application.UserMetadata != nil && getAppResp.Application.UserMetadata.Description != "" {
data.Description = types.StringValue(getAppResp.Application.UserMetadata.Description)
Expand All @@ -145,7 +154,8 @@ func (r *ApplicationResource) Create(ctx context.Context, req resource.CreateReq

configResp, err := r.client.ConfigureApplication(ctx, &app_pb.ConfigureApplicationReq{
ApplicationConfig: &app_pb.ApplicationConfig{
Name: data.Name.ValueString(),
Name: data.Name.ValueString(),
NoCleanupOnDelete: data.NoCleanupOnDelete.ValueBool(),
},
Source: version_pb.Source_IAC,
})
Expand Down Expand Up @@ -226,7 +236,7 @@ func (r *ApplicationResource) Update(ctx context.Context, req resource.UpdateReq

// this is not really needed since changing the application's name is not supported
appConfig.Name = planData.Name.ValueString()
// this is where newly supported fields should be set
appConfig.NoCleanupOnDelete = planData.NoCleanupOnDelete.ValueBool()

configResp, err := r.client.ConfigureApplication(ctx, &app_pb.ConfigureApplicationReq{
ApplicationConfig: appConfig,
Expand Down
52 changes: 52 additions & 0 deletions internal/provider/application_resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ func TestAccApplicationResourceWithDescription(t *testing.T) {
resource.TestCheckResourceAttr("prodvana_application.app", "description", appDesc),
resource.TestCheckResourceAttrSet("prodvana_application.app", "version"),
resource.TestCheckResourceAttrSet("prodvana_application.app", "id"),
resource.TestCheckResourceAttr("prodvana_application.app", "no_cleanup_on_delete", "false"),
),
},
// ImportState testing
Expand All @@ -91,6 +92,48 @@ func TestAccApplicationResourceWithDescription(t *testing.T) {
resource.TestCheckResourceAttr("prodvana_application.app", "description", emptyDesc),
resource.TestCheckResourceAttrSet("prodvana_application.app", "version"),
resource.TestCheckResourceAttrSet("prodvana_application.app", "id"),
resource.TestCheckResourceAttr("prodvana_application.app", "no_cleanup_on_delete", "false"),
),
},
// Delete testing automatically occurs in TestCase
},
})
}

func TestAccApplicationResourceNoCleanupOnDelete(t *testing.T) {
appName := uniqueTestName("app-tests")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
// Create and Read testing
{
Config: testAccApplicationResourceConfigNoCleanupOnDelete(appName, true),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("prodvana_application.app", "name", appName),
resource.TestCheckNoResourceAttr("prodvana_application.app", "description"),
resource.TestCheckResourceAttrSet("prodvana_application.app", "version"),
resource.TestCheckResourceAttrSet("prodvana_application.app", "id"),
resource.TestCheckResourceAttr("prodvana_application.app", "no_cleanup_on_delete", "true"),
),
},
// ImportState testing
{
ResourceName: "prodvana_application.app",
ImportStateId: appName,
ImportState: true,
ImportStateVerify: true,
},
// Update and Read testing
{
Config: testAccApplicationResourceConfigNoCleanupOnDelete(appName, false),
Check: resource.ComposeAggregateTestCheckFunc(
resource.TestCheckResourceAttr("prodvana_application.app", "name", appName),
resource.TestCheckNoResourceAttr("prodvana_application.app", "description"),
resource.TestCheckResourceAttrSet("prodvana_application.app", "version"),
resource.TestCheckResourceAttrSet("prodvana_application.app", "id"),
resource.TestCheckResourceAttr("prodvana_application.app", "no_cleanup_on_delete", "false"),
),
},
// Delete testing automatically occurs in TestCase
Expand Down Expand Up @@ -119,3 +162,12 @@ resource "prodvana_application" "app" {
}
`, name, desc)
}

func testAccApplicationResourceConfigNoCleanupOnDelete(name string, noCleanup bool) string {
return fmt.Sprintf(`
resource "prodvana_application" "app" {
name = %[1]q
no_cleanup_on_delete = %[2]t
}
`, name, noCleanup)
}
39 changes: 22 additions & 17 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (p *ProdvanaProvider) Configure(ctx context.Context, req provider.Configure
orgSlug := os.Getenv("PVN_ORG_SLUG")
apiToken := os.Getenv("PVN_API_TOKEN")
baseDomain := os.Getenv("PVN_BASE_DOMAIN")
apiserverURL := os.Getenv("PVN_APISERVER_URL")

if !data.OrgSlug.IsNull() {
orgSlug = data.OrgSlug.ValueString()
Expand All @@ -133,24 +134,25 @@ func (p *ProdvanaProvider) Configure(ctx context.Context, req provider.Configure

// If any of the expected configurations are missing, return
// errors with provider-specific guidance.
if apiserverURL == "" {
if orgSlug == "" {
resp.Diagnostics.AddAttributeError(
path.Root("org_slug"),
"Missing Prodvana Org Slug",
"The provider cannot create a Prodvana API client as there is an unknown configuration value for the org_slug."+
"Either target apply the source of the value first, set the value statically in the configuration, or use the PVN_ORG_SLUG environment variable."+
"If either is already set, ensure the value is not empty.",
)
}

if orgSlug == "" {
resp.Diagnostics.AddAttributeError(
path.Root("org_slug"),
"Missing Prodvana Org Slug",
"The provider cannot create a Prodvana API client as there is an unknown configuration value for the org_slug."+
"Either target apply the source of the value first, set the value statically in the configuration, or use the PVN_ORG_SLUG environment variable."+
"If either is already set, ensure the value is not empty.",
)
}

if apiToken == "" {
resp.Diagnostics.AddAttributeError(
path.Root("api_token"),
"Missing Prodvana API Token",
"The provider cannot create a Prodvana API client as there is an unknown configuration value for the api_token."+
"Either target apply the source of the value first, set the value statically in the configuration, or use the PVN_API_TOKEN environment variable.",
)
if apiToken == "" {
resp.Diagnostics.AddAttributeError(
path.Root("api_token"),
"Missing Prodvana API Token",
"The provider cannot create a Prodvana API client as there is an unknown configuration value for the api_token."+
"Either target apply the source of the value first, set the value statically in the configuration, or use the PVN_API_TOKEN environment variable.",
)
}
}

if baseDomain == "" {
Expand All @@ -168,6 +170,9 @@ func (p *ProdvanaProvider) Configure(ctx context.Context, req provider.Configure
tflog.Debug(ctx, "Creating Prodvana client")

domain := fmt.Sprintf("%s.grpc.%s", orgSlug, baseDomain)
if apiserverURL != "" {
domain = apiserverURL
}
cred := credentials.NewTLS(&tls.Config{ServerName: domain})
options := []grpc.DialOption{
grpc.WithTransportCredentials(cred),
Expand Down
Loading