From 0eb86a5d5d8b8cccd9d1008b50ad91e985f7780f Mon Sep 17 00:00:00 2001
From: Joe <83741749+paladin-devops@users.noreply.github.com>
Date: Thu, 8 Aug 2024 12:36:54 -0400
Subject: [PATCH] Waypoint: Remove module version (#869)
* Remove module version from Waypoint templates + add-ons.
* wp: Fix value set for module source.
---
.changelog/869.txt | 3 +
docs/data-sources/waypoint_add_on.md | 13 +--
docs/data-sources/waypoint_template.md | 11 +--
docs/resources/waypoint_add_on.md | 13 +--
docs/resources/waypoint_add_on_definition.md | 11 +--
docs/resources/waypoint_template.md | 11 +--
.../waypoint/data_source_waypoint_add_on.go | 29 +------
.../data_source_waypoint_add_on_definition.go | 15 +---
.../waypoint/data_source_waypoint_template.go | 29 ++-----
.../waypoint/resource_waypoint_add_on.go | 67 ++-------------
.../resource_waypoint_add_on_definition.go | 82 ++++++-------------
...esource_waypoint_add_on_definition_test.go | 5 +-
.../waypoint/resource_waypoint_add_on_test.go | 30 ++-----
.../resource_waypoint_application_test.go | 10 +--
.../waypoint/resource_waypoint_template.go | 77 +++++------------
.../resource_waypoint_template_test.go | 10 +--
16 files changed, 86 insertions(+), 330 deletions(-)
create mode 100644 .changelog/869.txt
diff --git a/.changelog/869.txt b/.changelog/869.txt
new file mode 100644
index 000000000..4465fc5f7
--- /dev/null
+++ b/.changelog/869.txt
@@ -0,0 +1,3 @@
+```release-note:breaking-change
+waypoint: Remove version number from templates and add-on definition resources and data sources.
+```
diff --git a/docs/data-sources/waypoint_add_on.md b/docs/data-sources/waypoint_add_on.md
index 90978fd65..157831b1b 100644
--- a/docs/data-sources/waypoint_add_on.md
+++ b/docs/data-sources/waypoint_add_on.md
@@ -34,7 +34,7 @@ The Waypoint Add-on data source retrieves information on a given Add-on.
- `readme_markdown` (String) Instructions for using the Add-on (markdown format supported).
- `status` (Number) The status of the Terraform run for the Add-on.
- `summary` (String) A short summary of the Add-on.
-- `terraform_no_code_module` (Attributes) Terraform Cloud no-code Module details. (see [below for nested schema](#nestedatt--terraform_no_code_module))
+- `terraform_no_code_module_source` (String) The Terraform module source for the Add-on.
### Nested Schema for `input_variables`
@@ -54,13 +54,4 @@ Read-Only:
- `name` (String) The name of the output value.
- `sensitive` (Boolean) Whether the output value is sensitive.
- `type` (String) The type of the output value.
-- `value` (String) The value of the output value.
-
-
-
-### Nested Schema for `terraform_no_code_module`
-
-Read-Only:
-
-- `source` (String) Terraform Cloud no-code Module Source
-- `version` (String) Terraform Cloud no-code Module Version
\ No newline at end of file
+- `value` (String) The value of the output value.
\ No newline at end of file
diff --git a/docs/data-sources/waypoint_template.md b/docs/data-sources/waypoint_template.md
index f9b2a7027..7a5d67db4 100644
--- a/docs/data-sources/waypoint_template.md
+++ b/docs/data-sources/waypoint_template.md
@@ -28,7 +28,7 @@ The Waypoint Template data source retrieves information on a given Template.
- `readme_markdown_template` (String) Instructions for using the template (markdown format supported)
- `summary` (String) A brief description of the template, up to 110 characters
- `terraform_cloud_workspace_details` (Attributes) Terraform Cloud Workspace details (see [below for nested schema](#nestedatt--terraform_cloud_workspace_details))
-- `terraform_no_code_module` (Attributes) Terraform Cloud No-Code Module details (see [below for nested schema](#nestedatt--terraform_no_code_module))
+- `terraform_no_code_module_source` (Attributes) Terraform No Code Module source (see [below for nested schema](#nestedatt--terraform_no_code_module_source))
- `variable_options` (Attributes List) List of variable options for the template (see [below for nested schema](#nestedatt--variable_options))
@@ -40,13 +40,8 @@ Read-Only:
- `terraform_project_id` (String) Terraform Cloud Project ID
-
-### Nested Schema for `terraform_no_code_module`
-
-Read-Only:
-
-- `source` (String) No-Code Module Source
-- `version` (String) No-Code Module Version
+
+### Nested Schema for `terraform_no_code_module_source`
diff --git a/docs/resources/waypoint_add_on.md b/docs/resources/waypoint_add_on.md
index 61b8201c5..cae31e9f0 100644
--- a/docs/resources/waypoint_add_on.md
+++ b/docs/resources/waypoint_add_on.md
@@ -38,7 +38,7 @@ Waypoint Add-on resource
- `readme_markdown` (String) The markdown for the Add-on README.
- `status` (Number) The status of the Terraform run for the Add-on.
- `summary` (String) A short summary of the Add-on.
-- `terraform_no_code_module` (Attributes) Terraform Cloud no-code Module details. (see [below for nested schema](#nestedatt--terraform_no_code_module))
+- `terraform_no_code_module_source` (String) The Terraform No Code Module source for the Add-on.
### Nested Schema for `add_on_input_variables`
@@ -71,13 +71,4 @@ Read-Only:
- `name` (String) The name of the output value.
- `sensitive` (Boolean) Whether the output value is sensitive.
- `type` (String) The type of the output value.
-- `value` (String) The value of the output value.
-
-
-
-### Nested Schema for `terraform_no_code_module`
-
-Read-Only:
-
-- `source` (String) Terraform Cloud no-code Module Source
-- `version` (String) Terraform Cloud no-code Module Version
\ No newline at end of file
+- `value` (String) The value of the output value.
\ No newline at end of file
diff --git a/docs/resources/waypoint_add_on_definition.md b/docs/resources/waypoint_add_on_definition.md
index c86fa0588..e9b91d764 100644
--- a/docs/resources/waypoint_add_on_definition.md
+++ b/docs/resources/waypoint_add_on_definition.md
@@ -19,7 +19,7 @@ Waypoint Add-on Definition resource
- `description` (String) A longer description of the Add-on Definition.
- `name` (String) The name of the Add-on Definition.
- `summary` (String) A short summary of the Add-on Definition.
-- `terraform_no_code_module` (Attributes) Terraform Cloud no-code Module details. (see [below for nested schema](#nestedatt--terraform_no_code_module))
+- `terraform_no_code_module_source` (String) Terraform Cloud no-code Module Source, expected to be in one of the following formats: "app.terraform.io/hcp_waypoint_example/ecs-advanced-microservice/aws" or "private/hcp_waypoint_example/ecs-advanced-microservice/aws"
### Optional
@@ -34,15 +34,6 @@ Waypoint Add-on Definition resource
- `id` (String) The ID of the Add-on Definition.
- `organization_id` (String) The ID of the HCP organization where the Waypoint Add-on Definition is located.
-
-### Nested Schema for `terraform_no_code_module`
-
-Required:
-
-- `source` (String) Terraform Cloud no-code Module Source , expected to be in one of the following formats: "app.terraform.io/hcp_waypoint_example/ecs-advanced-microservice/aws" or "private/hcp_waypoint_example/ecs-advanced-microservice/aws"
-- `version` (String) Terraform Cloud no-code Module Version
-
-
### Nested Schema for `terraform_cloud_workspace_details`
diff --git a/docs/resources/waypoint_template.md b/docs/resources/waypoint_template.md
index dab1095e7..f22c27220 100644
--- a/docs/resources/waypoint_template.md
+++ b/docs/resources/waypoint_template.md
@@ -19,7 +19,7 @@ Waypoint Template resource
- `name` (String) The name of the Template.
- `summary` (String) A brief description of the template, up to 110 characters
- `terraform_cloud_workspace_details` (Attributes) Terraform Cloud Workspace details (see [below for nested schema](#nestedatt--terraform_cloud_workspace_details))
-- `terraform_no_code_module` (Attributes) Terraform Cloud No-Code Module details (see [below for nested schema](#nestedatt--terraform_no_code_module))
+- `terraform_no_code_module_source` (String) Terraform Cloud No-Code Module details
### Optional
@@ -43,15 +43,6 @@ Required:
- `terraform_project_id` (String) Terraform Cloud Project ID
-
-### Nested Schema for `terraform_no_code_module`
-
-Required:
-
-- `source` (String) No-Code Module Source
-- `version` (String) No-Code Module Version
-
-
### Nested Schema for `variable_options`
diff --git a/internal/provider/waypoint/data_source_waypoint_add_on.go b/internal/provider/waypoint/data_source_waypoint_add_on.go
index 1a6aa7279..696e1ad6b 100644
--- a/internal/provider/waypoint/data_source_waypoint_add_on.go
+++ b/internal/provider/waypoint/data_source_waypoint_add_on.go
@@ -59,7 +59,7 @@ type AddOnDataSourceModel struct {
DefinitionID types.String `tfsdk:"definition_id"`
OutputValues types.List `tfsdk:"output_values"`
- TerraformNoCodeModule types.Object `tfsdk:"terraform_no_code_module"`
+ TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"`
InputVars types.Set `tfsdk:"input_variables"`
}
@@ -121,19 +121,9 @@ func (d *DataSourceAddOn) Schema(ctx context.Context, req datasource.SchemaReque
Computed: true,
Description: "The ID of the Application that this Add-on is created for.",
},
- "terraform_no_code_module": &schema.SingleNestedAttribute{
+ "terraform_no_code_module_source": schema.StringAttribute{
Computed: true,
- Description: "Terraform Cloud no-code Module details.",
- Attributes: map[string]schema.Attribute{
- "source": &schema.StringAttribute{
- Computed: true,
- Description: "Terraform Cloud no-code Module Source",
- },
- "version": &schema.StringAttribute{
- Computed: true,
- Description: "Terraform Cloud no-code Module Version",
- },
- },
+ Description: "The Terraform module source for the Add-on.",
},
"status": schema.Int64Attribute{
Computed: true,
@@ -243,6 +233,7 @@ func (d *DataSourceAddOn) Read(ctx context.Context, req datasource.ReadRequest,
}
state.Summary = types.StringValue(addOn.Summary)
+ state.TerraformNoCodeModuleSource = types.StringValue(addOn.ModuleSource)
labels, diags := types.ListValueFrom(ctx, types.StringType, addOn.Labels)
resp.Diagnostics.Append(diags...)
@@ -254,18 +245,6 @@ func (d *DataSourceAddOn) Read(ctx context.Context, req datasource.ReadRequest,
}
state.Labels = labels
- if addOn.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(addOn.TerraformNocodeModule.Source),
- Version: types.StringValue(addOn.TerraformNocodeModule.Version),
- }
- state.TerraformNoCodeModule, diags = types.ObjectValueFrom(ctx, tfcNoCode.attrTypes(), tfcNoCode)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
// set plan.description if it's not null or addOn.description is not empty
state.Description = types.StringValue(addOn.Description)
if addOn.Description == "" {
diff --git a/internal/provider/waypoint/data_source_waypoint_add_on_definition.go b/internal/provider/waypoint/data_source_waypoint_add_on_definition.go
index e345bc793..7fbd7387d 100644
--- a/internal/provider/waypoint/data_source_waypoint_add_on_definition.go
+++ b/internal/provider/waypoint/data_source_waypoint_add_on_definition.go
@@ -44,9 +44,9 @@ type DataSourceAddOnDefinitionModel struct {
Description types.String `tfsdk:"description"`
ReadmeMarkdownTemplate types.String `tfsdk:"readme_markdown_template"`
- TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"`
- TerraformNoCodeModule *tfcNoCodeModule `tfsdk:"terraform_no_code_module"`
- TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
+ TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"`
+ TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"`
+ TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
}
func NewAddOnDefinitionDataSource() datasource.DataSource {
@@ -210,6 +210,7 @@ func (d *DataSourceAddOnDefinition) Read(ctx context.Context, req datasource.Rea
state.OrgID = types.StringValue(client.Config.OrganizationID)
state.ProjectID = types.StringValue(client.Config.ProjectID)
state.Summary = types.StringValue(definition.Summary)
+ state.Description = types.StringValue(definition.Description)
if definition.TerraformCloudWorkspaceDetails != nil {
tfcWorkspace := &tfcWorkspace{
@@ -219,14 +220,6 @@ func (d *DataSourceAddOnDefinition) Read(ctx context.Context, req datasource.Rea
state.TerraformCloudWorkspace = tfcWorkspace
}
- if definition.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(definition.TerraformNocodeModule.Source),
- Version: types.StringValue(definition.TerraformNocodeModule.Version),
- }
- state.TerraformNoCodeModule = tfcNoCode
- }
-
labels, diags := types.ListValueFrom(ctx, types.StringType, definition.Labels)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
diff --git a/internal/provider/waypoint/data_source_waypoint_template.go b/internal/provider/waypoint/data_source_waypoint_template.go
index 5e3f7d15a..fbc69774f 100644
--- a/internal/provider/waypoint/data_source_waypoint_template.go
+++ b/internal/provider/waypoint/data_source_waypoint_template.go
@@ -44,9 +44,9 @@ type DataSourceTemplateModel struct {
Description types.String `tfsdk:"description"`
ReadmeMarkdownTemplate types.String `tfsdk:"readme_markdown_template"`
- TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"`
- TerraformNoCodeModule *tfcNoCodeModule `tfsdk:"terraform_no_code_module"`
- VariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
+ TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"`
+ TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"`
+ VariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
}
func NewTemplateDataSource() datasource.DataSource {
@@ -111,19 +111,9 @@ func (d *DataSourceTemplate) Schema(ctx context.Context, req datasource.SchemaRe
},
},
},
- "terraform_no_code_module": &schema.SingleNestedAttribute{
+ "terraform_no_code_module_source": &schema.SingleNestedAttribute{
Computed: true,
- Description: "Terraform Cloud No-Code Module details",
- Attributes: map[string]schema.Attribute{
- "source": &schema.StringAttribute{
- Computed: true,
- Description: "No-Code Module Source",
- },
- "version": &schema.StringAttribute{
- Computed: true,
- Description: "No-Code Module Version",
- },
- },
+ Description: "Terraform No Code Module source",
},
"variable_options": schema.ListNestedAttribute{
Computed: true,
@@ -210,6 +200,7 @@ func (d *DataSourceTemplate) Read(ctx context.Context, req datasource.ReadReques
data.OrgID = types.StringValue(client.Config.OrganizationID)
data.ProjectID = types.StringValue(client.Config.ProjectID)
data.Summary = types.StringValue(appTemplate.Summary)
+ data.TerraformNoCodeModuleSource = types.StringValue(appTemplate.ModuleSource)
if appTemplate.TerraformCloudWorkspaceDetails != nil {
tfcWorkspace := &tfcWorkspace{
@@ -219,14 +210,6 @@ func (d *DataSourceTemplate) Read(ctx context.Context, req datasource.ReadReques
data.TerraformCloudWorkspace = tfcWorkspace
}
- if appTemplate.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(appTemplate.TerraformNocodeModule.Source),
- Version: types.StringValue(appTemplate.TerraformNocodeModule.Version),
- }
- data.TerraformNoCodeModule = tfcNoCode
- }
-
data.VariableOptions, err = readVarOpts(ctx, appTemplate.VariableOptions, &resp.Diagnostics)
if err != nil {
tflog.Error(ctx, err.Error())
diff --git a/internal/provider/waypoint/resource_waypoint_add_on.go b/internal/provider/waypoint/resource_waypoint_add_on.go
index 6b7ad5d5b..99d7f1581 100644
--- a/internal/provider/waypoint/resource_waypoint_add_on.go
+++ b/internal/provider/waypoint/resource_waypoint_add_on.go
@@ -53,7 +53,7 @@ type AddOnResourceModel struct {
DefinitionID types.String `tfsdk:"definition_id"`
OutputValues types.List `tfsdk:"output_values"`
- TerraformNoCodeModule types.Object `tfsdk:"terraform_no_code_module"`
+ TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"`
InputVars types.Set `tfsdk:"add_on_input_variables"`
AddOnDefinitionInputVars types.Set `tfsdk:"add_on_definition_input_variables"`
@@ -75,13 +75,6 @@ func (o outputValue) attrTypes() map[string]attr.Type {
}
}
-func (r tfcNoCodeModule) attrTypes() map[string]attr.Type {
- return map[string]attr.Type{
- "source": types.StringType,
- "version": types.StringType,
- }
-}
-
func (r *AddOnResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_waypoint_add_on"
}
@@ -148,19 +141,9 @@ func (r *AddOnResource) Schema(ctx context.Context, req resource.SchemaRequest,
"Add-on Definition.",
Computed: true,
},
- "terraform_no_code_module": &schema.SingleNestedAttribute{
+ "terraform_no_code_module_source": schema.StringAttribute{
+ Description: "The Terraform No Code Module source for the Add-on.",
Computed: true,
- Description: "Terraform Cloud no-code Module details.",
- Attributes: map[string]schema.Attribute{
- "source": &schema.StringAttribute{
- Computed: true,
- Description: "Terraform Cloud no-code Module Source",
- },
- "version": &schema.StringAttribute{
- Computed: true,
- Description: "Terraform Cloud no-code Module Version",
- },
- },
},
"definition_id": schema.StringAttribute{
Required: true,
@@ -391,8 +374,9 @@ func (r *AddOnResource) Create(ctx context.Context, req resource.CreateRequest,
plan.ProjectID = types.StringValue(projectID)
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(addOn.Summary)
-
plan.Description = types.StringValue(addOn.Description)
+ plan.TerraformNoCodeModuleSource = types.StringValue(addOn.TerraformNocodeModule.Source)
+
// set plan.description if it's not null or addOn.description is not empty
if addOn.Description == "" {
plan.Description = types.StringNull()
@@ -410,21 +394,6 @@ func (r *AddOnResource) Create(ctx context.Context, req resource.CreateRequest,
}
plan.Labels = labels
- if addOn.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{}
- if addOn.TerraformNocodeModule.Source != "" {
- tfcNoCode.Source = types.StringValue(addOn.TerraformNocodeModule.Source)
- }
- if addOn.TerraformNocodeModule.Version != "" {
- tfcNoCode.Version = types.StringValue(addOn.TerraformNocodeModule.Version)
- }
- plan.TerraformNoCodeModule, diags = types.ObjectValueFrom(ctx, tfcNoCode.attrTypes(), tfcNoCode)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
// Display the reference to the Definition in the plan
if addOn.Definition != nil {
if addOn.Definition.ID != "" {
@@ -557,6 +526,7 @@ func (r *AddOnResource) Read(ctx context.Context, req resource.ReadRequest, resp
state.ProjectID = types.StringValue(projectID)
state.OrgID = types.StringValue(orgID)
state.Summary = types.StringValue(addOn.Summary)
+ state.TerraformNoCodeModuleSource = types.StringValue(addOn.TerraformNocodeModule.Source)
state.Description = types.StringValue(addOn.Description)
// set plan.description if it's not null or addOn.description is not empty
@@ -576,18 +546,6 @@ func (r *AddOnResource) Read(ctx context.Context, req resource.ReadRequest, resp
}
state.Labels = labels
- if addOn.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(addOn.TerraformNocodeModule.Source),
- Version: types.StringValue(addOn.TerraformNocodeModule.Version),
- }
- state.TerraformNoCodeModule, diags = types.ObjectValueFrom(ctx, tfcNoCode.attrTypes(), tfcNoCode)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
state.CreatedBy = types.StringValue(addOn.CreatedBy)
// If we can process status as an int64, add it to the plan
@@ -719,6 +677,7 @@ func (r *AddOnResource) Update(ctx context.Context, req resource.UpdateRequest,
plan.ProjectID = types.StringValue(projectID)
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(addOn.Summary)
+ plan.TerraformNoCodeModuleSource = types.StringValue(addOn.TerraformNocodeModule.Source)
plan.Description = types.StringValue(addOn.Description)
// set plan.description if it's not null or addOn.description is not empty
@@ -738,18 +697,6 @@ func (r *AddOnResource) Update(ctx context.Context, req resource.UpdateRequest,
}
plan.Labels = labels
- if addOn.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(addOn.TerraformNocodeModule.Source),
- Version: types.StringValue(addOn.TerraformNocodeModule.Version),
- }
- plan.TerraformNoCodeModule, diags = types.ObjectValueFrom(ctx, tfcNoCode.attrTypes(), tfcNoCode)
- resp.Diagnostics.Append(diags...)
- if resp.Diagnostics.HasError() {
- return
- }
- }
-
// Display the reference to the Definition in the plan
if addOn.Definition != nil {
if addOn.Definition.ID != "" {
diff --git a/internal/provider/waypoint/resource_waypoint_add_on_definition.go b/internal/provider/waypoint/resource_waypoint_add_on_definition.go
index 63cd993dd..744cd0ebe 100644
--- a/internal/provider/waypoint/resource_waypoint_add_on_definition.go
+++ b/internal/provider/waypoint/resource_waypoint_add_on_definition.go
@@ -47,9 +47,9 @@ type AddOnDefinitionResourceModel struct {
Description types.String `tfsdk:"description"`
ReadmeMarkdownTemplate types.String `tfsdk:"readme_markdown_template"`
- TerraformCloudWorkspace types.Object `tfsdk:"terraform_cloud_workspace_details"`
- TerraformNoCodeModule *tfcNoCodeModule `tfsdk:"terraform_no_code_module"`
- TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
+ TerraformCloudWorkspace types.Object `tfsdk:"terraform_cloud_workspace_details"`
+ TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"`
+ TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
}
func (r *AddOnDefinitionResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) {
@@ -125,20 +125,13 @@ func (r *AddOnDefinitionResource) Schema(ctx context.Context, req resource.Schem
},
},
},
- "terraform_no_code_module": &schema.SingleNestedAttribute{
- Required: true,
- Description: "Terraform Cloud no-code Module details.",
- Attributes: map[string]schema.Attribute{
- "source": &schema.StringAttribute{
- Required: true,
- Description: "Terraform Cloud no-code Module Source , expected to be in one of the following formats:" +
- " \"app.terraform.io/hcp_waypoint_example/ecs-advanced-microservice/aws\" or " +
- "\"private/hcp_waypoint_example/ecs-advanced-microservice/aws\"",
- },
- "version": &schema.StringAttribute{
- Required: true,
- Description: "Terraform Cloud no-code Module Version",
- },
+ "terraform_no_code_module_source": &schema.StringAttribute{
+ Required: true,
+ Description: "Terraform Cloud no-code Module Source, expected to be in one of the following formats:" +
+ " \"app.terraform.io/hcp_waypoint_example/ecs-advanced-microservice/aws\" or " +
+ "\"private/hcp_waypoint_example/ecs-advanced-microservice/aws\"",
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.RequiresReplace(),
},
},
"variable_options": schema.SetNestedAttribute{
@@ -253,15 +246,11 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat
}
modelBody := &waypointModels.HashicorpCloudWaypointWaypointServiceCreateAddOnDefinitionBody{
- Name: plan.Name.ValueString(),
- Summary: plan.Summary.ValueString(),
- Description: plan.Description.ValueString(),
- Labels: stringLabels,
- TerraformNocodeModule: &waypointModels.HashicorpCloudWaypointTerraformNocodeModule{
- // verify these exist in the file
- Source: plan.TerraformNoCodeModule.Source.ValueString(),
- Version: plan.TerraformNoCodeModule.Version.ValueString(),
- },
+ Name: plan.Name.ValueString(),
+ Summary: plan.Summary.ValueString(),
+ Description: plan.Description.ValueString(),
+ Labels: stringLabels,
+ ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(),
VariableOptions: varOpts,
}
@@ -314,6 +303,7 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat
plan.Name = types.StringValue(addOnDefinition.Name)
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(addOnDefinition.Summary)
+ plan.TerraformNoCodeModuleSource = types.StringValue(addOnDefinition.ModuleSource)
plan.Description = types.StringValue(addOnDefinition.Description)
// set plan.description if it's not null or addOnDefinition.description is not empty
@@ -345,14 +335,6 @@ func (r *AddOnDefinitionResource) Create(ctx context.Context, req resource.Creat
}
}
- if addOnDefinition.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(addOnDefinition.TerraformNocodeModule.Source),
- Version: types.StringValue(addOnDefinition.TerraformNocodeModule.Version),
- }
- plan.TerraformNoCodeModule = tfcNoCode
- }
-
plan.TerraformVariableOptions, err = readVarOpts(ctx, addOnDefinition.VariableOptions, &resp.Diagnostics)
if err != nil {
tflog.Error(ctx, err.Error())
@@ -406,6 +388,7 @@ func (r *AddOnDefinitionResource) Read(ctx context.Context, req resource.ReadReq
state.OrgID = types.StringValue(client.Config.OrganizationID)
state.ProjectID = types.StringValue(client.Config.ProjectID)
state.Summary = types.StringValue(definition.Summary)
+ state.TerraformNoCodeModuleSource = types.StringValue(definition.ModuleSource)
state.Description = types.StringValue(definition.Description)
// set plan.description if it's not null or addOnDefinition.description is not empty
@@ -437,14 +420,6 @@ func (r *AddOnDefinitionResource) Read(ctx context.Context, req resource.ReadReq
}
}
- if definition.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(definition.TerraformNocodeModule.Source),
- Version: types.StringValue(definition.TerraformNocodeModule.Version),
- }
- state.TerraformNoCodeModule = tfcNoCode
- }
-
state.TerraformVariableOptions, err = readVarOpts(ctx, definition.VariableOptions, &resp.Diagnostics)
if err != nil {
tflog.Error(ctx, err.Error())
@@ -515,15 +490,11 @@ func (r *AddOnDefinitionResource) Update(ctx context.Context, req resource.Updat
// TODO: add support for Tags
modelBody := &waypointModels.HashicorpCloudWaypointWaypointServiceUpdateAddOnDefinitionBody{
- Name: plan.Name.ValueString(),
- Summary: plan.Summary.ValueString(),
- Description: plan.Description.ValueString(),
- Labels: stringLabels,
- TerraformNocodeModule: &waypointModels.HashicorpCloudWaypointTerraformNocodeModule{
- // verify these exist in the file
- Source: plan.TerraformNoCodeModule.Source.ValueString(),
- Version: plan.TerraformNoCodeModule.Version.ValueString(),
- },
+ Name: plan.Name.ValueString(),
+ Summary: plan.Summary.ValueString(),
+ Description: plan.Description.ValueString(),
+ Labels: stringLabels,
+ ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(),
VariableOptions: varOpts,
}
@@ -577,6 +548,7 @@ func (r *AddOnDefinitionResource) Update(ctx context.Context, req resource.Updat
plan.Name = types.StringValue(addOnDefinition.Name)
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(addOnDefinition.Summary)
+ plan.TerraformNoCodeModuleSource = types.StringValue(addOnDefinition.ModuleSource)
plan.Description = types.StringValue(addOnDefinition.Description)
// set plan.description if it's not null or addOnDefinition.description is not empty
@@ -608,14 +580,6 @@ func (r *AddOnDefinitionResource) Update(ctx context.Context, req resource.Updat
}
}
- if addOnDefinition.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(addOnDefinition.TerraformNocodeModule.Source),
- Version: types.StringValue(addOnDefinition.TerraformNocodeModule.Version),
- }
- plan.TerraformNoCodeModule = tfcNoCode
- }
-
plan.TerraformVariableOptions, err = readVarOpts(ctx, addOnDefinition.VariableOptions, &resp.Diagnostics)
if err != nil {
tflog.Error(ctx, err.Error())
diff --git a/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go b/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go
index 4798b0444..3721f14d1 100644
--- a/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go
+++ b/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go
@@ -142,10 +142,7 @@ resource "hcp_waypoint_add_on_definition" "test" {
name = %q
summary = "some summary for fun"
description = "some description for fun"
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
- version = "0.0.3"
- }
+ terraform_no_code_module = "private/waypoint-tfc-testing/waypoint-template-starter/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
diff --git a/internal/provider/waypoint/resource_waypoint_add_on_test.go b/internal/provider/waypoint/resource_waypoint_add_on_test.go
index 5516039d3..15d4e2cb5 100644
--- a/internal/provider/waypoint/resource_waypoint_add_on_test.go
+++ b/internal/provider/waypoint/resource_waypoint_add_on_test.go
@@ -190,10 +190,7 @@ resource "hcp_waypoint_template" "test" {
name = "%s"
summary = "some summary for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
- version = "0.0.2"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -210,10 +207,7 @@ resource "hcp_waypoint_add_on_definition" "test" {
name = "%s"
summary = "some summary for fun"
description = "some description for fun"
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
- version = "0.0.2"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -233,10 +227,7 @@ resource "hcp_waypoint_template" "test" {
name = "%s"
summary = "some summary for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
- version = "0.0.2"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -254,10 +245,7 @@ resource "hcp_waypoint_add_on_definition" "test_var_opts" {
summary = "some summary for fun"
description = "some description for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
- version = "0.0.1"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -318,10 +306,7 @@ resource "hcp_waypoint_template" "test" {
name = "%s"
summary = "some summary for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
- version = "0.0.2"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -339,10 +324,7 @@ resource "hcp_waypoint_add_on_definition" "test_var_opts" {
summary = "some summary for fun"
description = "some description"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
- version = "0.0.1"
- }
+ terraform_no_code_module = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
diff --git a/internal/provider/waypoint/resource_waypoint_application_test.go b/internal/provider/waypoint/resource_waypoint_application_test.go
index 2efe77060..67f88f4d1 100644
--- a/internal/provider/waypoint/resource_waypoint_application_test.go
+++ b/internal/provider/waypoint/resource_waypoint_application_test.go
@@ -215,10 +215,7 @@ resource "hcp_waypoint_template" "test_var_opts" {
name = "%s"
summary = "some summary for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
- version = "0.0.1"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -276,10 +273,7 @@ resource "hcp_waypoint_template" "test_var_opts" {
name = "%s"
summary = "some summary for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
- version = "0.0.1"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
diff --git a/internal/provider/waypoint/resource_waypoint_template.go b/internal/provider/waypoint/resource_waypoint_template.go
index cd4bf8d62..7cf1c3579 100644
--- a/internal/provider/waypoint/resource_waypoint_template.go
+++ b/internal/provider/waypoint/resource_waypoint_template.go
@@ -50,9 +50,9 @@ type TemplateResourceModel struct {
Description types.String `tfsdk:"description"`
ReadmeMarkdownTemplate types.String `tfsdk:"readme_markdown_template"`
- TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"`
- TerraformNoCodeModule *tfcNoCodeModule `tfsdk:"terraform_no_code_module"`
- TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
+ TerraformCloudWorkspace *tfcWorkspace `tfsdk:"terraform_cloud_workspace_details"`
+ TerraformNoCodeModuleSource types.String `tfsdk:"terraform_no_code_module_source"`
+ TerraformVariableOptions []*tfcVariableOption `tfsdk:"variable_options"`
}
type tfcWorkspace struct {
@@ -68,11 +68,6 @@ func (t tfcWorkspace) attrTypes() map[string]attr.Type {
}
}
-type tfcNoCodeModule struct {
- Source types.String `tfsdk:"source"`
- Version types.String `tfsdk:"version"`
-}
-
type tfcVariableOption struct {
Name types.String `tfsdk:"name"`
VariableType types.String `tfsdk:"variable_type"`
@@ -151,18 +146,11 @@ func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaReques
},
},
},
- "terraform_no_code_module": &schema.SingleNestedAttribute{
+ "terraform_no_code_module_source": schema.StringAttribute{
Required: true,
Description: "Terraform Cloud No-Code Module details",
- Attributes: map[string]schema.Attribute{
- "source": &schema.StringAttribute{
- Required: true,
- Description: "No-Code Module Source",
- },
- "version": &schema.StringAttribute{
- Required: true,
- Description: "No-Code Module Version",
- },
+ PlanModifiers: []planmodifier.String{
+ stringplanmodifier.RequiresReplace(),
},
},
"variable_options": schema.SetNestedAttribute{
@@ -274,14 +262,11 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
modelBody := &waypoint_models.HashicorpCloudWaypointWaypointServiceCreateApplicationTemplateBody{
ApplicationTemplate: &waypoint_models.HashicorpCloudWaypointApplicationTemplate{
- Name: plan.Name.ValueString(),
- Summary: plan.Summary.ValueString(),
- Labels: strLabels,
- Description: plan.Description.ValueString(),
- TerraformNocodeModule: &waypoint_models.HashicorpCloudWaypointTerraformNocodeModule{
- Source: plan.TerraformNoCodeModule.Source.ValueString(),
- Version: plan.TerraformNoCodeModule.Version.ValueString(),
- },
+ Name: plan.Name.ValueString(),
+ Summary: plan.Summary.ValueString(),
+ Labels: strLabels,
+ Description: plan.Description.ValueString(),
+ ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(),
TerraformCloudWorkspaceDetails: &waypoint_models.HashicorpCloudWaypointTerraformCloudWorkspaceDetails{
Name: plan.TerraformCloudWorkspace.Name.ValueString(),
ProjectID: plan.TerraformCloudWorkspace.TerraformProjectID.ValueString(),
@@ -326,6 +311,7 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
plan.Name = types.StringValue(appTemplate.Name)
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(appTemplate.Summary)
+ plan.TerraformNoCodeModuleSource = types.StringValue(appTemplate.ModuleSource)
if appTemplate.TerraformCloudWorkspaceDetails != nil {
tfcWorkspace := &tfcWorkspace{
@@ -335,14 +321,6 @@ func (r *TemplateResource) Create(ctx context.Context, req resource.CreateReques
plan.TerraformCloudWorkspace = tfcWorkspace
}
- if appTemplate.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(appTemplate.TerraformNocodeModule.Source),
- Version: types.StringValue(appTemplate.TerraformNocodeModule.Version),
- }
- plan.TerraformNoCodeModule = tfcNoCode
- }
-
labels, diags := types.ListValueFrom(ctx, types.StringType, appTemplate.Labels)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
@@ -448,6 +426,7 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r
data.OrgID = types.StringValue(client.Config.OrganizationID)
data.ProjectID = types.StringValue(client.Config.ProjectID)
data.Summary = types.StringValue(appTemplate.Summary)
+ data.TerraformNoCodeModuleSource = types.StringValue(appTemplate.ModuleSource)
if appTemplate.TerraformCloudWorkspaceDetails != nil {
tfcWorkspace := &tfcWorkspace{
@@ -457,14 +436,6 @@ func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, r
data.TerraformCloudWorkspace = tfcWorkspace
}
- if appTemplate.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(appTemplate.TerraformNocodeModule.Source),
- Version: types.StringValue(appTemplate.TerraformNocodeModule.Version),
- }
- data.TerraformNoCodeModule = tfcNoCode
- }
-
data.TerraformVariableOptions, err = readVarOpts(ctx, appTemplate.VariableOptions, &resp.Diagnostics)
if err != nil {
tflog.Error(ctx, err.Error())
@@ -552,14 +523,11 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques
modelBody := &waypoint_models.HashicorpCloudWaypointWaypointServiceUpdateApplicationTemplateBody{
ApplicationTemplate: &waypoint_models.HashicorpCloudWaypointApplicationTemplate{
- Name: plan.Name.ValueString(),
- Summary: plan.Summary.ValueString(),
- Labels: strLabels,
- Description: plan.Description.ValueString(),
- TerraformNocodeModule: &waypoint_models.HashicorpCloudWaypointTerraformNocodeModule{
- Source: plan.TerraformNoCodeModule.Source.ValueString(),
- Version: plan.TerraformNoCodeModule.Version.ValueString(),
- },
+ Name: plan.Name.ValueString(),
+ Summary: plan.Summary.ValueString(),
+ Labels: strLabels,
+ Description: plan.Description.ValueString(),
+ ModuleSource: plan.TerraformNoCodeModuleSource.ValueString(),
TerraformCloudWorkspaceDetails: &waypoint_models.HashicorpCloudWaypointTerraformCloudWorkspaceDetails{
Name: plan.TerraformCloudWorkspace.Name.ValueString(),
ProjectID: plan.TerraformCloudWorkspace.TerraformProjectID.ValueString(),
@@ -605,6 +573,7 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques
plan.Name = types.StringValue(appTemplate.Name)
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(appTemplate.Summary)
+ plan.TerraformNoCodeModuleSource = types.StringValue(appTemplate.ModuleSource)
labels, diags := types.ListValueFrom(ctx, types.StringType, appTemplate.Labels)
resp.Diagnostics.Append(diags...)
@@ -621,14 +590,6 @@ func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateReques
plan.TerraformCloudWorkspace = tfcWorkspace
}
- if appTemplate.TerraformNocodeModule != nil {
- tfcNoCode := &tfcNoCodeModule{
- Source: types.StringValue(appTemplate.TerraformNocodeModule.Source),
- Version: types.StringValue(appTemplate.TerraformNocodeModule.Version),
- }
- plan.TerraformNoCodeModule = tfcNoCode
- }
-
plan.Description = types.StringValue(appTemplate.Description)
if appTemplate.Description == "" {
plan.Description = types.StringNull()
diff --git a/internal/provider/waypoint/resource_waypoint_template_test.go b/internal/provider/waypoint/resource_waypoint_template_test.go
index 2e962ee31..1f6cd2ff7 100644
--- a/internal/provider/waypoint/resource_waypoint_template_test.go
+++ b/internal/provider/waypoint/resource_waypoint_template_test.go
@@ -157,10 +157,7 @@ resource "hcp_waypoint_template" "test" {
name = "%s"
summary = "some summary for fun"
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
- version = "0.0.2"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-template-starter/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
@@ -175,10 +172,7 @@ resource "hcp_waypoint_template" "var_opts_test" {
name = "%s"
summary = "A template with a variable with options."
readme_markdown_template = base64encode("# Some Readme")
- terraform_no_code_module = {
- source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
- version = "0.0.1"
- }
+ terraform_no_code_module_source = "private/waypoint-tfc-testing/waypoint-vault-dweller/null"
terraform_cloud_workspace_details = {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"