Skip to content

Commit

Permalink
Remove module version from Waypoint templates + add-ons.
Browse files Browse the repository at this point in the history
  • Loading branch information
paladin-devops committed Jul 30, 2024
1 parent f77e1c4 commit 46546ef
Show file tree
Hide file tree
Showing 16 changed files with 86 additions and 330 deletions.
3 changes: 3 additions & 0 deletions .changelog/869.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:breaking-change
waypoint: Remove version number from templates and add-on definition resources and data sources.
```
13 changes: 2 additions & 11 deletions docs/data-sources/waypoint_add_on.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<a id="nestedatt--input_variables"></a>
### Nested Schema for `input_variables`
Expand All @@ -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.


<a id="nestedatt--terraform_no_code_module"></a>
### 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
- `value` (String) The value of the output value.
11 changes: 3 additions & 8 deletions docs/data-sources/waypoint_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

<a id="nestedatt--terraform_cloud_workspace_details"></a>
Expand All @@ -40,13 +40,8 @@ Read-Only:
- `terraform_project_id` (String) Terraform Cloud Project ID


<a id="nestedatt--terraform_no_code_module"></a>
### Nested Schema for `terraform_no_code_module`

Read-Only:

- `source` (String) No-Code Module Source
- `version` (String) No-Code Module Version
<a id="nestedatt--terraform_no_code_module_source"></a>
### Nested Schema for `terraform_no_code_module_source`


<a id="nestedatt--variable_options"></a>
Expand Down
13 changes: 2 additions & 11 deletions docs/resources/waypoint_add_on.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

<a id="nestedatt--add_on_input_variables"></a>
### Nested Schema for `add_on_input_variables`
Expand Down Expand Up @@ -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.


<a id="nestedatt--terraform_no_code_module"></a>
### 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
- `value` (String) The value of the output value.
11 changes: 1 addition & 10 deletions docs/resources/waypoint_add_on_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.

<a id="nestedatt--terraform_no_code_module"></a>
### 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


<a id="nestedatt--terraform_cloud_workspace_details"></a>
### Nested Schema for `terraform_cloud_workspace_details`

Expand Down
11 changes: 1 addition & 10 deletions docs/resources/waypoint_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -43,15 +43,6 @@ Required:
- `terraform_project_id` (String) Terraform Cloud Project ID


<a id="nestedatt--terraform_no_code_module"></a>
### Nested Schema for `terraform_no_code_module`

Required:

- `source` (String) No-Code Module Source
- `version` (String) No-Code Module Version


<a id="nestedatt--variable_options"></a>
### Nested Schema for `variable_options`

Expand Down
29 changes: 4 additions & 25 deletions internal/provider/waypoint/data_source_waypoint_add_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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...)
Expand All @@ -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 == "" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand All @@ -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() {
Expand Down
29 changes: 6 additions & 23 deletions internal/provider/waypoint/data_source_waypoint_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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{
Expand All @@ -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())
Expand Down
Loading

0 comments on commit 46546ef

Please sign in to comment.