Skip to content

Commit

Permalink
Waypoint acceptance test bugfixes (#1094)
Browse files Browse the repository at this point in the history
Fixes several Waypoint acceptance test issues as well as some Waypoint template and add-on definition data source bugs.

Co-authored-by: paladin-devops <[email protected]>
  • Loading branch information
HenryEstberg and paladin-devops authored Sep 19, 2024
1 parent c6e6394 commit 7b6a076
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .changelog/1094.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
waypoint: Fix `hcp_waypoint_template` and `hcp_waypoint_add_on_definition` data sources.
```
11 changes: 1 addition & 10 deletions docs/data-sources/waypoint_add_on_definition.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The Waypoint Add-on Definition data source retrieves information on a given Add-
- `readme_markdown_template` (String) Instructions for using the Add-on Definition (markdown format supported).
- `summary` (String) A short summary of the Add-on Definition.
- `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 No Code Module source
- `variable_options` (Attributes List) List of variable options for the Add-on Definition. (see [below for nested schema](#nestedatt--variable_options))

<a id="nestedatt--terraform_cloud_workspace_details"></a>
Expand All @@ -40,15 +40,6 @@ 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) Terraform Cloud no-code Module Source
- `version` (String) Terraform Cloud no-code Module Version


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

Expand Down
6 changes: 1 addition & 5 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_source` (Attributes) Terraform No Code Module source (see [below for nested schema](#nestedatt--terraform_no_code_module_source))
- `terraform_no_code_module_source` (String) 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,10 +40,6 @@ Read-Only:
- `terraform_project_id` (String) Terraform Cloud Project ID


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


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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,19 +111,9 @@ func (d *DataSourceAddOnDefinition) Schema(ctx context.Context, req datasource.S
},
},
},
"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: "Terraform No Code Module source",
},
"variable_options": schema.ListNestedAttribute{
Computed: true,
Expand Down Expand Up @@ -211,6 +201,7 @@ func (d *DataSourceAddOnDefinition) Read(ctx context.Context, req datasource.Rea
state.ProjectID = types.StringValue(client.Config.ProjectID)
state.Summary = types.StringValue(definition.Summary)
state.Description = types.StringValue(definition.Description)
state.TerraformNoCodeModuleSource = types.StringValue(definition.ModuleSource)

if definition.TerraformCloudWorkspaceDetails != nil {
tfcWorkspace := &tfcWorkspace{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ func TestAccWaypointData_Add_On_Definition_basic(t *testing.T) {
Config: testDataAddOnDefinitionConfig(name),
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(dataSourceName, "name", name),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.name", "string_variable"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.variable_type", "string"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.options.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.options.0", "b"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.user_editable", "false"),
),
},
{
Expand All @@ -53,11 +48,6 @@ func TestAccWaypointData_Add_On_Definition_basic(t *testing.T) {
Check: resource.ComposeTestCheckFunc(
resource.TestCheckResourceAttr(resourceName, "name", updatedName),
resource.TestCheckResourceAttr(dataSourceName, "name", updatedName),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.name", "string_variable"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.variable_type", "string"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.options.#", "1"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.options.0", "b"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.user_editable", "false"),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (d *DataSourceTemplate) Schema(ctx context.Context, req datasource.SchemaRe
},
},
},
"terraform_no_code_module_source": &schema.SingleNestedAttribute{
"terraform_no_code_module_source": schema.StringAttribute{
Computed: true,
Description: "Terraform No Code Module source",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func TestAccWaypointData_template_with_variable_options(t *testing.T) {
resource.TestCheckResourceAttr(dataSourceName, "name", name),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.#", "2"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.name", "faction"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.type", "string"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.0.variable_type", "string"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.1.name", "vault_dweller_name"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.1.type", "string"),
resource.TestCheckResourceAttr(dataSourceName, "variable_options.1.variable_type", "string"),
),
},
},
Expand Down
6 changes: 3 additions & 3 deletions internal/provider/waypoint/resource_waypoint_add_on.go
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ func (r *AddOnResource) Create(ctx context.Context, req resource.CreateRequest,
plan.OrgID = types.StringValue(orgID)
plan.Summary = types.StringValue(addOn.Summary)
plan.Description = types.StringValue(addOn.Description)
plan.TerraformNoCodeModuleSource = types.StringValue(addOn.TerraformNocodeModule.Source)
plan.TerraformNoCodeModuleSource = types.StringValue(addOn.ModuleSource)

// set plan.description if it's not null or addOn.description is not empty
if addOn.Description == "" {
Expand Down Expand Up @@ -526,7 +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.TerraformNoCodeModuleSource = types.StringValue(addOn.ModuleSource)

state.Description = types.StringValue(addOn.Description)
// set plan.description if it's not null or addOn.description is not empty
Expand Down Expand Up @@ -677,7 +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.TerraformNoCodeModuleSource = types.StringValue(addOn.ModuleSource)

plan.Description = types.StringValue(addOn.Description)
// set plan.description if it's not null or addOn.description is not empty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@ func TestAccWaypoint_Add_On_Definition_basic(t *testing.T) {
testAccCheckWaypointAddOnDefinitionExists(t, resourceName, &addOnDefinitionModel),
testAccCheckWaypointAddOnDefinitionName(t, &addOnDefinitionModel, name),
resource.TestCheckResourceAttr(resourceName, "name", name),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.name", "string_variable"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.variable_type", "string"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.options.#", "1"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.options.0", "b"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.user_editable", "false"),
),
},
{
Expand All @@ -48,11 +43,6 @@ func TestAccWaypoint_Add_On_Definition_basic(t *testing.T) {
testAccCheckWaypointAddOnDefinitionExists(t, resourceName, &addOnDefinitionModel),
testAccCheckWaypointAddOnDefinitionName(t, &addOnDefinitionModel, updatedName),
resource.TestCheckResourceAttr(resourceName, "name", updatedName),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.name", "string_variable"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.variable_type", "string"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.options.#", "1"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.options.0", "b"),
resource.TestCheckResourceAttr(resourceName, "variable_options.0.user_editable", "false"),
),
},
},
Expand All @@ -74,7 +64,7 @@ func testAccCheckWaypointAddOnDefinitionExists(t *testing.T, resourceName string
// find the corresponding state object
rs, ok := s.RootModule().Resources[resourceName]
if !ok {
return fmt.Errorf("Not found: %s", resourceName)
return fmt.Errorf("not found: %s", resourceName)
}

client := acctest.HCPClients(t)
Expand Down Expand Up @@ -148,15 +138,5 @@ resource "hcp_waypoint_add_on_definition" "test" {
name = "Default Project"
terraform_project_id = "prj-gfVyPJ2q2Aurn25o"
}
variable_options = [
{
name = "string_variable"
variable_type = "string"
options = [
"b"
]
user_editable = false
}
]
}`, name)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import (
)

func TestAccWaypointTfcConfig_basic(t *testing.T) {
// This will need to be rewritten to delete the TFC Config before running in order to function
t.Skip("Skipping nonfunctional TFC Config test")
var tfcConfig waypoint.TfcConfigResourceModel
resourceName := "hcp_waypoint_tfc_config.test"

Expand Down

0 comments on commit 7b6a076

Please sign in to comment.