diff --git a/.changelog/861.txt b/.changelog/861.txt new file mode 100644 index 000000000..84a1b51f3 --- /dev/null +++ b/.changelog/861.txt @@ -0,0 +1,4 @@ +```release-note:breaking-change +waypoint: Rename `hcp_waypoint_application_template` resource and data source to +`hcp_waypoint_template`. +``` \ No newline at end of file diff --git a/docs/data-sources/waypoint_add_on_definition.md b/docs/data-sources/waypoint_add_on_definition.md index 89d65e038..90c09d6bb 100644 --- a/docs/data-sources/waypoint_add_on_definition.md +++ b/docs/data-sources/waypoint_add_on_definition.md @@ -29,7 +29,7 @@ The Waypoint Add-on Definition data source retrieves information on a given Add- - `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)) -- `variable_options` (Attributes List) List of variable options for the template (see [below for nested schema](#nestedatt--variable_options)) +- `variable_options` (Attributes List) List of variable options for the Add-on Definition. (see [below for nested schema](#nestedatt--variable_options)) ### Nested Schema for `terraform_cloud_workspace_details` diff --git a/docs/data-sources/waypoint_application.md b/docs/data-sources/waypoint_application.md index 948af6718..41ae3f064 100644 --- a/docs/data-sources/waypoint_application.md +++ b/docs/data-sources/waypoint_application.md @@ -23,11 +23,11 @@ The Waypoint Application data source retrieves information on a given Applicatio ### Read-Only -- `application_template_id` (String) ID of the Application Template this Application is based on. -- `application_template_name` (String) Name of the Application Template this Application is based on. - `namespace_id` (String) Internal Namespace ID. - `organization_id` (String) The ID of the HCP organization where the Waypoint Application is located. - `readme_markdown` (String) Instructions for using the Application (markdown format supported). +- `template_id` (String) ID of the Template this Application is based on. +- `template_name` (String) Name of the Template this Application is based on. ### Nested Schema for `input_variables` diff --git a/docs/data-sources/waypoint_application_template.md b/docs/data-sources/waypoint_template.md similarity index 80% rename from docs/data-sources/waypoint_application_template.md rename to docs/data-sources/waypoint_template.md index c0f0e5561..f9b2a7027 100644 --- a/docs/data-sources/waypoint_application_template.md +++ b/docs/data-sources/waypoint_template.md @@ -1,30 +1,30 @@ --- -page_title: "hcp_waypoint_application_template Data Source - terraform-provider-hcp" +page_title: "hcp_waypoint_template Data Source - terraform-provider-hcp" subcategory: "HCP Waypoint" description: |- - The Waypoint Template data source retrieves information on a given Application Template. + The Waypoint Template data source retrieves information on a given Template. --- -# hcp_waypoint_application_template `Data Source` +# hcp_waypoint_template `Data Source` -> **Note:** HCP Waypoint is currently in public beta. -The Waypoint Template data source retrieves information on a given Application Template. +The Waypoint Template data source retrieves information on a given Template. ## Schema ### Optional -- `id` (String) The ID of the Application Template. -- `name` (String) The name of the Application Template. -- `project_id` (String) The ID of the HCP project where the Waypoint Application Template is located. +- `id` (String) The ID of the Template. +- `name` (String) The name of the Template. +- `project_id` (String) The ID of the HCP project where the Waypoint Template is located. ### Read-Only - `description` (String) A description of the template, along with when and why it should be used, up to 500 characters -- `labels` (List of String) List of labels attached to this Application Template. -- `organization_id` (String) The ID of the HCP organization where the Waypoint Application Template is located. +- `labels` (List of String) List of labels attached to this Template. +- `organization_id` (String) The ID of the HCP organization where the Waypoint Template is located. - `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)) diff --git a/docs/resources/waypoint_add_on_definition.md b/docs/resources/waypoint_add_on_definition.md index 9b696752b..fdae778ad 100644 --- a/docs/resources/waypoint_add_on_definition.md +++ b/docs/resources/waypoint_add_on_definition.md @@ -27,7 +27,7 @@ Waypoint Add-on Definition resource - `labels` (List of String) List of labels attached to this Add-on Definition. - `project_id` (String) The ID of the HCP project where the Waypoint Add-on Definition is located. - `readme_markdown_template` (String) The markdown template for the Add-on Definition README. -- `variable_options` (Attributes Set) List of variable options for the template (see [below for nested schema](#nestedatt--variable_options)) +- `variable_options` (Attributes Set) List of variable options for the Add-on Definition. (see [below for nested schema](#nestedatt--variable_options)) ### Read-Only diff --git a/docs/resources/waypoint_application.md b/docs/resources/waypoint_application.md index 22b6345e9..f362f7d5b 100644 --- a/docs/resources/waypoint_application.md +++ b/docs/resources/waypoint_application.md @@ -16,22 +16,22 @@ The Waypoint Application resource managed the lifecycle of an Application that's ### Required -- `application_template_id` (String) ID of the Application Template this Application is based on. - `name` (String) The name of the Application. +- `template_id` (String) ID of the Template this Application is based on. ### Optional - `application_input_variables` (Attributes Set) Input variables set for the application. (see [below for nested schema](#nestedatt--application_input_variables)) - `project_id` (String) The ID of the HCP project where the Waypoint Application is located. -- `readme_markdown` (String) Instructions for using the Application (markdown format supported). Note: this is a base64 encoded string, and can only be set in configuration after initial creation. The initial version of the README is generated from the README Template from source Application Template. +- `readme_markdown` (String) Instructions for using the Application (markdown format supported). Note: this is a base64 encoded string, and can only be set in configuration after initial creation. The initial version of the README is generated from the README Template from source Template. ### Read-Only -- `application_template_name` (String) Name of the Application Template this Application is based on. - `id` (String) The ID of the Application. - `namespace_id` (String) Internal Namespace ID. - `organization_id` (String) The ID of the HCP organization where the Waypoint Application is located. - `template_input_variables` (Attributes Set) Input variables set for the application. (see [below for nested schema](#nestedatt--template_input_variables)) +- `template_name` (String) Name of the Template this Application is based on. ### Nested Schema for `application_input_variables` diff --git a/docs/resources/waypoint_application_template.md b/docs/resources/waypoint_template.md similarity index 79% rename from docs/resources/waypoint_application_template.md rename to docs/resources/waypoint_template.md index 0d9d9d073..8f4d39018 100644 --- a/docs/resources/waypoint_application_template.md +++ b/docs/resources/waypoint_template.md @@ -1,22 +1,22 @@ --- -page_title: "hcp_waypoint_application_template Resource - terraform-provider-hcp" +page_title: "hcp_waypoint_template Resource - terraform-provider-hcp" subcategory: "HCP Waypoint" description: |- - Waypoint Application Template resource + Waypoint Template resource --- -# hcp_waypoint_application_template `Resource` +# hcp_waypoint_template `Resource` -> **Note:** HCP Waypoint is currently in public beta. -Waypoint Application Template resource +Waypoint Template resource ## Schema ### Required -- `name` (String) The name of the Application Template. +- `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)) @@ -24,15 +24,15 @@ Waypoint Application Template resource ### Optional - `description` (String) A description of the template, along with when and why it should be used, up to 500 characters -- `labels` (List of String) List of labels attached to this Application Template. -- `project_id` (String) The ID of the HCP project where the Waypoint Application Template is located. +- `labels` (List of String) List of labels attached to this Template. +- `project_id` (String) The ID of the HCP project where the Waypoint Template is located. - `readme_markdown_template` (String) Instructions for using the template (markdown format supported - `variable_options` (Attributes Set) List of variable options for the template (see [below for nested schema](#nestedatt--variable_options)) ### Read-Only -- `id` (String) The ID of the Application Template. -- `organization_id` (String) The ID of the HCP organization where the Waypoint Application Template is located. +- `id` (String) The ID of the Template. +- `organization_id` (String) The ID of the HCP organization where the Waypoint Template is located. ### Nested Schema for `terraform_cloud_workspace_details` diff --git a/internal/clients/waypoint.go b/internal/clients/waypoint.go index 357e5e1b7..45522d498 100644 --- a/internal/clients/waypoint.go +++ b/internal/clients/waypoint.go @@ -47,7 +47,7 @@ func GetAction(ctx context.Context, client *Client, loc *sharedmodels.HashicorpC return getResp.GetPayload().ActionConfig, nil } -// GetApplicationTemplateByName will retrieve an application template by name +// GetApplicationTemplateByName will retrieve a template by name func GetApplicationTemplateByName(ctx context.Context, client *Client, loc *sharedmodels.HashicorpCloudLocationLocation, appName string) (*waypoint_models.HashicorpCloudWaypointApplicationTemplate, error) { ns, err := getNamespaceByLocation(ctx, client, loc) if err != nil { @@ -66,7 +66,7 @@ func GetApplicationTemplateByName(ctx context.Context, client *Client, loc *shar return getResp.GetPayload().ApplicationTemplate, nil } -// GetApplicationTemplateByID will retrieve an application template by ID +// GetApplicationTemplateByID will retrieve a template by ID func GetApplicationTemplateByID(ctx context.Context, client *Client, loc *sharedmodels.HashicorpCloudLocationLocation, appID string) (*waypoint_models.HashicorpCloudWaypointApplicationTemplate, error) { ns, err := getNamespaceByLocation(ctx, client, loc) if err != nil { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index f79a346dc..6498db984 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -157,7 +157,7 @@ func (p *ProviderFramework) Resources(ctx context.Context) []func() resource.Res // Waypoint waypoint.NewActionResource, waypoint.NewApplicationResource, - waypoint.NewApplicationTemplateResource, + waypoint.NewTemplateResource, waypoint.NewAddOnResource, waypoint.NewAddOnDefinitionResource, waypoint.NewTfcConfigResource, @@ -181,7 +181,7 @@ func (p *ProviderFramework) DataSources(ctx context.Context) []func() datasource // Waypoint waypoint.NewActionDataSource, waypoint.NewApplicationDataSource, - waypoint.NewApplicationTemplateDataSource, + waypoint.NewTemplateDataSource, waypoint.NewAddOnDataSource, waypoint.NewAddOnDefinitionDataSource, }, packer.DataSourceSchemaBuilders...) 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 0b1aae1f9..e345bc793 100644 --- a/internal/provider/waypoint/data_source_waypoint_add_on_definition.go +++ b/internal/provider/waypoint/data_source_waypoint_add_on_definition.go @@ -127,7 +127,7 @@ func (d *DataSourceAddOnDefinition) Schema(ctx context.Context, req datasource.S }, "variable_options": schema.ListNestedAttribute{ Computed: true, - Description: "List of variable options for the template", + Description: "List of variable options for the Add-on Definition.", NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "name": &schema.StringAttribute{ diff --git a/internal/provider/waypoint/data_source_waypoint_application.go b/internal/provider/waypoint/data_source_waypoint_application.go index 0711a39b3..76073ff1c 100644 --- a/internal/provider/waypoint/data_source_waypoint_application.go +++ b/internal/provider/waypoint/data_source_waypoint_application.go @@ -68,13 +68,13 @@ func (d *DataSourceApplication) Schema(ctx context.Context, req datasource.Schem Computed: true, Description: "Instructions for using the Application (markdown format supported).", }, - "application_template_id": schema.StringAttribute{ + "template_id": schema.StringAttribute{ Computed: true, - Description: "ID of the Application Template this Application is based on.", + Description: "ID of the Template this Application is based on.", }, - "application_template_name": schema.StringAttribute{ + "template_name": schema.StringAttribute{ Computed: true, - Description: "Name of the Application Template this Application is based on.", + Description: "Name of the Template this Application is based on.", }, "namespace_id": schema.StringAttribute{ Computed: true, @@ -122,14 +122,14 @@ func (d *DataSourceApplication) Configure(ctx context.Context, req datasource.Co // ApplicationDataSourceModel describes the data source data model type ApplicationDataSourceModel struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - ProjectID types.String `tfsdk:"project_id"` - OrgID types.String `tfsdk:"organization_id"` - ReadmeMarkdown types.String `tfsdk:"readme_markdown"` - ApplicationTemplateID types.String `tfsdk:"application_template_id"` - ApplicationTemplateName types.String `tfsdk:"application_template_name"` - NamespaceID types.String `tfsdk:"namespace_id"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + ProjectID types.String `tfsdk:"project_id"` + OrgID types.String `tfsdk:"organization_id"` + ReadmeMarkdown types.String `tfsdk:"readme_markdown"` + TemplateID types.String `tfsdk:"template_id"` + TemplateName types.String `tfsdk:"template_name"` + NamespaceID types.String `tfsdk:"namespace_id"` // deferred for now // Tags types.List `tfsdk:"tags"` diff --git a/internal/provider/waypoint/data_source_waypoint_application_test.go b/internal/provider/waypoint/data_source_waypoint_application_test.go index 0cae3723e..bc5b35485 100644 --- a/internal/provider/waypoint/data_source_waypoint_application_test.go +++ b/internal/provider/waypoint/data_source_waypoint_application_test.go @@ -13,7 +13,7 @@ import ( ) func TestAccWaypoint_Application_DataSource_basic(t *testing.T) { - // this is only used to verify the app template gets cleaned up in the end + // this is only used to verify the template gets cleaned up in the end // of the test, and not used for any other purpose at this time var applicationModel waypoint.ApplicationResourceModel resourceName := "hcp_waypoint_application.test" @@ -27,14 +27,14 @@ func TestAccWaypoint_Application_DataSource_basic(t *testing.T) { CheckDestroy: testAccCheckWaypointApplicationDestroy(t, &applicationModel), Steps: []resource.TestStep{ { - // establish the base app template and application + // establish the base template and application Config: testApplicationConfig(templateName, applicationName), Check: resource.ComposeTestCheckFunc( testAccCheckWaypointApplicationExists(t, resourceName, &applicationModel), ), }, { - // add a data source config to read the app template + // add a data source config to read the template Config: testDataApplicationConfig(templateName, applicationName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "name", applicationName), @@ -45,7 +45,7 @@ func TestAccWaypoint_Application_DataSource_basic(t *testing.T) { } func TestAccWaypoint_Application_DataSource_WithInputVars(t *testing.T) { - // this is only used to verify the app template gets cleaned up in the end + // this is only used to verify the template gets cleaned up in the end // of the test, and not used for any other purpose at this time var applicationModel waypoint.ApplicationResourceModel resourceName := "hcp_waypoint_application.test_var_opts" @@ -59,14 +59,14 @@ func TestAccWaypoint_Application_DataSource_WithInputVars(t *testing.T) { CheckDestroy: testAccCheckWaypointApplicationDestroy(t, &applicationModel), Steps: []resource.TestStep{ { - // establish the base app template and application + // establish the base template and application Config: testApplicationWithInputVarsConfig(templateName, applicationName), Check: resource.ComposeTestCheckFunc( testAccCheckWaypointApplicationExists(t, resourceName, &applicationModel), ), }, { - // add a data source config to read the app template + // add a data source config to read the template Config: testDataApplicationWithInputVarsConfig(templateName, applicationName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "name", applicationName), diff --git a/internal/provider/waypoint/data_source_waypoint_application_template.go b/internal/provider/waypoint/data_source_waypoint_template.go similarity index 83% rename from internal/provider/waypoint/data_source_waypoint_application_template.go rename to internal/provider/waypoint/data_source_waypoint_template.go index 287ae2af8..5e3f7d15a 100644 --- a/internal/provider/waypoint/data_source_waypoint_application_template.go +++ b/internal/provider/waypoint/data_source_waypoint_template.go @@ -18,10 +18,10 @@ import ( "github.com/hashicorp/terraform-provider-hcp/internal/clients" ) -var _ datasource.DataSource = &DataSourceApplicationTemplate{} -var _ datasource.DataSourceWithConfigValidators = &DataSourceApplicationTemplate{} +var _ datasource.DataSource = &DataSourceTemplate{} +var _ datasource.DataSourceWithConfigValidators = &DataSourceTemplate{} -func (d DataSourceApplicationTemplate) ConfigValidators(ctx context.Context) []datasource.ConfigValidator { +func (d DataSourceTemplate) ConfigValidators(ctx context.Context) []datasource.ConfigValidator { return []datasource.ConfigValidator{ datasourcevalidator.Conflicting( path.MatchRoot("name"), @@ -30,11 +30,11 @@ func (d DataSourceApplicationTemplate) ConfigValidators(ctx context.Context) []d } } -type DataSourceApplicationTemplate struct { +type DataSourceTemplate struct { client *clients.Client } -type DataSourceApplicationTemplateModel struct { +type DataSourceTemplateModel struct { ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` ProjectID types.String `tfsdk:"project_id"` @@ -49,34 +49,34 @@ type DataSourceApplicationTemplateModel struct { VariableOptions []*tfcVariableOption `tfsdk:"variable_options"` } -func NewApplicationTemplateDataSource() datasource.DataSource { - return &DataSourceApplicationTemplate{} +func NewTemplateDataSource() datasource.DataSource { + return &DataSourceTemplate{} } -func (d *DataSourceApplicationTemplate) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_waypoint_application_template" +func (d *DataSourceTemplate) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_waypoint_template" } -func (d *DataSourceApplicationTemplate) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { +func (d *DataSourceTemplate) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { resp.Schema = schema.Schema{ - MarkdownDescription: "The Waypoint Template data source retrieves information on a given Application Template.", + MarkdownDescription: "The Waypoint Template data source retrieves information on a given Template.", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, Optional: true, - Description: "The ID of the Application Template.", + Description: "The ID of the Template.", }, "name": schema.StringAttribute{ - Description: "The name of the Application Template.", + Description: "The name of the Template.", Computed: true, Optional: true, }, "organization_id": schema.StringAttribute{ - Description: "The ID of the HCP organization where the Waypoint Application Template is located.", + Description: "The ID of the HCP organization where the Waypoint Template is located.", Computed: true, }, "project_id": schema.StringAttribute{ - Description: "The ID of the HCP project where the Waypoint Application Template is located.", + Description: "The ID of the HCP project where the Waypoint Template is located.", Optional: true, Computed: true, }, @@ -94,7 +94,7 @@ func (d *DataSourceApplicationTemplate) Schema(ctx context.Context, req datasour }, "labels": schema.ListAttribute{ Computed: true, - Description: "List of labels attached to this Application Template.", + Description: "List of labels attached to this Template.", ElementType: types.StringType, }, "terraform_cloud_workspace_details": &schema.SingleNestedAttribute{ @@ -154,7 +154,7 @@ func (d *DataSourceApplicationTemplate) Schema(ctx context.Context, req datasour } } -func (d *DataSourceApplicationTemplate) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { +func (d *DataSourceTemplate) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { if req.ProviderData == nil { return } @@ -170,8 +170,8 @@ func (d *DataSourceApplicationTemplate) Configure(ctx context.Context, req datas d.client = client } -func (d *DataSourceApplicationTemplate) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { - var data DataSourceApplicationTemplateModel +func (d *DataSourceTemplate) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var data DataSourceTemplateModel resp.Diagnostics.Append(req.Config.Get(ctx, &data)...) client := d.client diff --git a/internal/provider/waypoint/data_source_waypoint_application_template_test.go b/internal/provider/waypoint/data_source_waypoint_template_test.go similarity index 59% rename from internal/provider/waypoint/data_source_waypoint_application_template_test.go rename to internal/provider/waypoint/data_source_waypoint_template_test.go index 633e685f8..0d0cf94b5 100644 --- a/internal/provider/waypoint/data_source_waypoint_application_template_test.go +++ b/internal/provider/waypoint/data_source_waypoint_template_test.go @@ -12,11 +12,11 @@ import ( "github.com/hashicorp/terraform-provider-hcp/internal/provider/waypoint" ) -func TestAccWaypointData_Application_Template_basic(t *testing.T) { - // this is only used to verify the app template gets cleaned up in the end +func TestAccWaypointData_Template_basic(t *testing.T) { + // this is only used to verify the template gets cleaned up in the end // of the test, and not used for any other purpose at this time - var appTemplateModel waypoint.ApplicationTemplateResourceModel - resourceName := "hcp_waypoint_application_template.test" + var appTemplateModel waypoint.TemplateResourceModel + resourceName := "hcp_waypoint_template.test" dataSourceName := "data." + resourceName name := generateRandomName() updatedName := generateRandomName() @@ -24,26 +24,26 @@ func TestAccWaypointData_Application_Template_basic(t *testing.T) { resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories, - CheckDestroy: testAccCheckWaypointAppTemplateDestroy(t, &appTemplateModel), + CheckDestroy: testAccCheckWaypointTemplateDestroy(t, &appTemplateModel), Steps: []resource.TestStep{ { - // establish the base app template - // note this reuses the config method from the app template + // establish the base template + // note this reuses the config method from the template // resource test - Config: testAppTemplateConfig(name), + Config: testTemplateConfig(name), Check: resource.ComposeTestCheckFunc( - testAccCheckWaypointAppTemplateExists(t, resourceName, &appTemplateModel), + testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel), ), }, { - // add a data source config to read the app template + // add a data source config to read the template Config: testDataAppTemplateConfig(name), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "name", name), ), }, { - // update the app template name, make sure it reflects in the data source + // update the template name, make sure it reflects in the data source Config: testDataAppTemplateConfig(updatedName), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(resourceName, "name", updatedName), @@ -54,30 +54,30 @@ func TestAccWaypointData_Application_Template_basic(t *testing.T) { }) } -func TestAccWaypointData_Application_template_with_variable_options(t *testing.T) { - // this is only used to verify the app template gets cleaned up in the end +func TestAccWaypointData_template_with_variable_options(t *testing.T) { + // this is only used to verify the template gets cleaned up in the end // of the test, and not used for any other purpose at this time - var appTemplateModel waypoint.ApplicationTemplateResourceModel - resourceName := "hcp_waypoint_application_template.var_opts_test" + var appTemplateModel waypoint.TemplateResourceModel + resourceName := "hcp_waypoint_template.var_opts_test" dataSourceName := "data." + resourceName name := generateRandomName() resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories, - CheckDestroy: testAccCheckWaypointAppTemplateDestroy(t, &appTemplateModel), + CheckDestroy: testAccCheckWaypointTemplateDestroy(t, &appTemplateModel), Steps: []resource.TestStep{ { - // establish the base app template - // note this reuses the config method from the app template + // establish the base template + // note this reuses the config method from the template // resource test - Config: testAppTemplateConfigWithVarOpts(name), + Config: testTemplateConfigWithVarOpts(name), Check: resource.ComposeTestCheckFunc( - testAccCheckWaypointAppTemplateExists(t, resourceName, &appTemplateModel), + testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel), ), }, { - // add a data source config to read the app template + // add a data source config to read the template Config: testDataAppTemplateWithVariablesWithOptionsConfig(name), Check: resource.ComposeTestCheckFunc( resource.TestCheckResourceAttr(dataSourceName, "name", name), @@ -95,14 +95,14 @@ func TestAccWaypointData_Application_template_with_variable_options(t *testing.T func testDataAppTemplateConfig(name string) string { return fmt.Sprintf(`%s -data "hcp_waypoint_application_template" "test" { - name = hcp_waypoint_application_template.test.name -}`, testAppTemplateConfig(name)) +data "hcp_waypoint_template" "test" { + name = hcp_waypoint_template.test.name +}`, testTemplateConfig(name)) } func testDataAppTemplateWithVariablesWithOptionsConfig(name string) string { return fmt.Sprintf(`%s -data "hcp_waypoint_application_template" "var_opts_test" { - name = hcp_waypoint_application_template.var_opts_test.name -}`, testAppTemplateConfigWithVarOpts(name)) +data "hcp_waypoint_template" "var_opts_test" { + name = hcp_waypoint_template.var_opts_test.name +}`, testTemplateConfigWithVarOpts(name)) } diff --git a/internal/provider/waypoint/resource_waypoint_add_on_definition.go b/internal/provider/waypoint/resource_waypoint_add_on_definition.go index e3f071649..b894c21ac 100644 --- a/internal/provider/waypoint/resource_waypoint_add_on_definition.go +++ b/internal/provider/waypoint/resource_waypoint_add_on_definition.go @@ -138,7 +138,7 @@ func (r *AddOnDefinitionResource) Schema(ctx context.Context, req resource.Schem }, "variable_options": schema.SetNestedAttribute{ Optional: true, - Description: "List of variable options for the template", + Description: "List of variable options for the Add-on Definition.", NestedObject: schema.NestedAttributeObject{ Attributes: map[string]schema.Attribute{ "name": &schema.StringAttribute{ 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 ebd5378b7..4798b0444 100644 --- a/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go +++ b/internal/provider/waypoint/resource_waypoint_add_on_definition_test.go @@ -131,7 +131,7 @@ func testAccCheckWaypointAddOnDefinitionDestroy(t *testing.T, definitionModel *w return fmt.Errorf("expected add-on definition to be destroyed, but it still exists") } - return fmt.Errorf("Both add-on definition and error were nil in destroy check, this should not happen") + return fmt.Errorf("both add-on definition and error were nil in destroy check, this should not happen") } } diff --git a/internal/provider/waypoint/resource_waypoint_add_on_test.go b/internal/provider/waypoint/resource_waypoint_add_on_test.go index d80b5ff28..ef6bda5ef 100644 --- a/internal/provider/waypoint/resource_waypoint_add_on_test.go +++ b/internal/provider/waypoint/resource_waypoint_add_on_test.go @@ -58,7 +58,7 @@ func testAccCheckWaypointAddOnExists(t *testing.T, resourceName string, addOnMod // 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) @@ -114,7 +114,7 @@ func testAccCheckWaypointAddOnDestroy(t *testing.T, addOnModel *waypoint.AddOnRe return fmt.Errorf("expected add-on to be destroyed, but it still exists") } - return fmt.Errorf("Both add-on and error were nil in destroy check, this should not happen") + return fmt.Errorf("both add-on and error were nil in destroy check, this should not happen") } } @@ -123,7 +123,7 @@ func testAccCheckWaypointAddOnDestroy(t *testing.T, addOnModel *waypoint.AddOnRe // sufficient for now. func testAddOnConfig(templateName string, appName string, defName string, addOnName string) string { return fmt.Sprintf(` -resource "hcp_waypoint_application_template" "test" { +resource "hcp_waypoint_template" "test" { name = "%s" summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") @@ -140,7 +140,7 @@ resource "hcp_waypoint_application_template" "test" { resource "hcp_waypoint_application" "test" { name = "%s" - application_template_id = hcp_waypoint_application_template.test.id + template_id = hcp_waypoint_template.test.id } resource "hcp_waypoint_add_on_definition" "test" { diff --git a/internal/provider/waypoint/resource_waypoint_application.go b/internal/provider/waypoint/resource_waypoint_application.go index 45e44c1a1..654684f7b 100644 --- a/internal/provider/waypoint/resource_waypoint_application.go +++ b/internal/provider/waypoint/resource_waypoint_application.go @@ -37,14 +37,14 @@ type ApplicationResource struct { // ApplicationResourceModel describes the resource data model. type ApplicationResourceModel struct { - ID types.String `tfsdk:"id"` - Name types.String `tfsdk:"name"` - ProjectID types.String `tfsdk:"project_id"` - OrgID types.String `tfsdk:"organization_id"` - ReadmeMarkdown types.String `tfsdk:"readme_markdown"` - ApplicationTemplateID types.String `tfsdk:"application_template_id"` - ApplicationTemplateName types.String `tfsdk:"application_template_name"` - NamespaceID types.String `tfsdk:"namespace_id"` + ID types.String `tfsdk:"id"` + Name types.String `tfsdk:"name"` + ProjectID types.String `tfsdk:"project_id"` + OrgID types.String `tfsdk:"organization_id"` + ReadmeMarkdown types.String `tfsdk:"readme_markdown"` + TemplateID types.String `tfsdk:"template_id"` + TemplateName types.String `tfsdk:"template_name"` + NamespaceID types.String `tfsdk:"namespace_id"` // deferred for now // Tags types.List `tfsdk:"tags"` @@ -115,15 +115,15 @@ func (r *ApplicationResource) Schema(ctx context.Context, req resource.SchemaReq stringplanmodifier.UseStateForUnknown(), }, }, - "application_template_id": schema.StringAttribute{ + "template_id": schema.StringAttribute{ Required: true, - Description: "ID of the Application Template this Application is based on.", + Description: "ID of the Template this Application is based on.", }, - // application_template_name is a computed only attribute for ease + // template_name is a computed only attribute for ease // of reference - "application_template_name": schema.StringAttribute{ + "template_name": schema.StringAttribute{ Computed: true, - Description: "Name of the Application Template this Application is based on.", + Description: "Name of the Template this Application is based on.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -135,7 +135,7 @@ func (r *ApplicationResource) Schema(ctx context.Context, req resource.SchemaReq " format supported). Note: this is a base64 encoded string, and " + "can only be set in configuration after initial creation. The" + " initial version of the README is generated from the README " + - "Template from source Application Template.", + "Template from source Template.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, @@ -270,7 +270,7 @@ func (r *ApplicationResource) Create(ctx context.Context, req resource.CreateReq modelBody := &waypoint_models.HashicorpCloudWaypointWaypointServiceCreateApplicationFromTemplateBody{ Name: plan.Name.ValueString(), ApplicationTemplate: &waypoint_models.HashicorpCloudWaypointRefApplicationTemplate{ - ID: plan.ApplicationTemplateID.ValueString(), + ID: plan.TemplateID.ValueString(), }, Variables: ivs, } @@ -298,7 +298,7 @@ func (r *ApplicationResource) Create(ctx context.Context, req resource.CreateReq plan.ProjectID = types.StringValue(projectID) plan.Name = types.StringValue(application.Name) plan.OrgID = types.StringValue(orgID) - plan.ApplicationTemplateName = types.StringValue(application.ApplicationTemplate.Name) + plan.TemplateName = types.StringValue(application.ApplicationTemplate.Name) plan.NamespaceID = types.StringValue(ns.ID) // set plan.readme if it's not null or application.readme is not @@ -394,7 +394,7 @@ func (r *ApplicationResource) Read(ctx context.Context, req resource.ReadRequest data.ProjectID = types.StringValue(projectID) data.Name = types.StringValue(application.Name) data.OrgID = types.StringValue(orgID) - data.ApplicationTemplateName = types.StringValue(application.ApplicationTemplate.Name) + data.TemplateName = types.StringValue(application.ApplicationTemplate.Name) // set plan.readme if it's not null or application.readme is not // empty @@ -543,7 +543,7 @@ func (r *ApplicationResource) Update(ctx context.Context, req resource.UpdateReq plan.ProjectID = types.StringValue(projectID) plan.Name = types.StringValue(application.Name) plan.OrgID = types.StringValue(orgID) - plan.ApplicationTemplateName = types.StringValue(application.ApplicationTemplate.Name) + plan.TemplateName = types.StringValue(application.ApplicationTemplate.Name) plan.NamespaceID = types.StringValue(ns.ID) // set plan.readme if it's not null or application.readme is not diff --git a/internal/provider/waypoint/resource_waypoint_application_test.go b/internal/provider/waypoint/resource_waypoint_application_test.go index 76bfb3c4c..78468562f 100644 --- a/internal/provider/waypoint/resource_waypoint_application_test.go +++ b/internal/provider/waypoint/resource_waypoint_application_test.go @@ -189,7 +189,7 @@ func testAccCheckWaypointApplicationDestroy(t *testing.T, applicationModel *wayp // sufficient for now. func testApplicationConfig(tempName, appName string) string { return fmt.Sprintf(` -resource "hcp_waypoint_application_template" "test" { +resource "hcp_waypoint_template" "test" { name = "%s" summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") @@ -206,13 +206,13 @@ resource "hcp_waypoint_application_template" "test" { resource "hcp_waypoint_application" "test" { name = "%s" - application_template_id = hcp_waypoint_application_template.test.id + template_id = hcp_waypoint_template.test.id }`, tempName, appName) } func testApplicationWithInputVarsConfig(tempName, appName string) string { return fmt.Sprintf(` -resource "hcp_waypoint_application_template" "test_var_opts" { +resource "hcp_waypoint_template" "test_var_opts" { name = "%s" summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") @@ -254,7 +254,7 @@ resource "hcp_waypoint_application_template" "test_var_opts" { resource "hcp_waypoint_application" "test_var_opts" { name = "%s" - application_template_id = hcp_waypoint_application_template.test_var_opts.id + template_id = hcp_waypoint_template.test_var_opts.id application_input_variables = [ { @@ -273,7 +273,7 @@ resource "hcp_waypoint_application" "test_var_opts" { func testApplicationWithNoInputVarsConfig(tempName, appName string) string { return fmt.Sprintf(` -resource "hcp_waypoint_application_template" "test_var_opts" { +resource "hcp_waypoint_template" "test_var_opts" { name = "%s" summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") @@ -308,6 +308,6 @@ resource "hcp_waypoint_application_template" "test_var_opts" { resource "hcp_waypoint_application" "test_var_opts" { name = "%s" - application_template_id = hcp_waypoint_application_template.test_var_opts.id + template_id = hcp_waypoint_template.test_var_opts.id }`, tempName, appName) } diff --git a/internal/provider/waypoint/resource_waypoint_application_template.go b/internal/provider/waypoint/resource_waypoint_template.go similarity index 88% rename from internal/provider/waypoint/resource_waypoint_application_template.go rename to internal/provider/waypoint/resource_waypoint_template.go index 256b70542..829784408 100644 --- a/internal/provider/waypoint/resource_waypoint_application_template.go +++ b/internal/provider/waypoint/resource_waypoint_template.go @@ -26,20 +26,20 @@ import ( ) // Ensure provider defined types fully satisfy framework interfaces. -var _ resource.Resource = &ApplicationTemplateResource{} -var _ resource.ResourceWithImportState = &ApplicationTemplateResource{} +var _ resource.Resource = &TemplateResource{} +var _ resource.ResourceWithImportState = &TemplateResource{} -func NewApplicationTemplateResource() resource.Resource { - return &ApplicationTemplateResource{} +func NewTemplateResource() resource.Resource { + return &TemplateResource{} } -// ApplicationTemplateResource defines the resource implementation. -type ApplicationTemplateResource struct { +// TemplateResource defines the resource implementation. +type TemplateResource struct { client *clients.Client } -// ApplicationTemplateResourceModel describes the resource data model. -type ApplicationTemplateResourceModel struct { +// TemplateResourceModel describes the resource data model. +type TemplateResourceModel struct { ID types.String `tfsdk:"id"` Name types.String `tfsdk:"name"` ProjectID types.String `tfsdk:"project_id"` @@ -72,36 +72,36 @@ type tfcVariableOption struct { UserEditable types.Bool `tfsdk:"user_editable"` } -func (r *ApplicationTemplateResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_waypoint_application_template" +func (r *TemplateResource) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_waypoint_template" } -func (r *ApplicationTemplateResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { +func (r *TemplateResource) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { resp.Schema = schema.Schema{ // This description is used by the documentation generator and the language server. - MarkdownDescription: "Waypoint Application Template resource", + MarkdownDescription: "Waypoint Template resource", Attributes: map[string]schema.Attribute{ "id": schema.StringAttribute{ Computed: true, - Description: "The ID of the Application Template.", + Description: "The ID of the Template.", PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "name": schema.StringAttribute{ - Description: "The name of the Application Template.", + Description: "The name of the Template.", Required: true, }, "organization_id": schema.StringAttribute{ - Description: "The ID of the HCP organization where the Waypoint Application Template is located.", + Description: "The ID of the HCP organization where the Waypoint Template is located.", Computed: true, PlanModifiers: []planmodifier.String{ stringplanmodifier.UseStateForUnknown(), }, }, "project_id": schema.StringAttribute{ - Description: "The ID of the HCP project where the Waypoint Application Template is located.", + Description: "The ID of the HCP project where the Waypoint Template is located.", Optional: true, Computed: true, PlanModifiers: []planmodifier.String{ @@ -123,7 +123,7 @@ func (r *ApplicationTemplateResource) Schema(ctx context.Context, req resource.S "labels": schema.ListAttribute{ // Computed: true, Optional: true, - Description: "List of labels attached to this Application Template.", + Description: "List of labels attached to this Template.", ElementType: types.StringType, PlanModifiers: []planmodifier.List{ listplanmodifier.UseStateForUnknown(), @@ -192,7 +192,7 @@ func (r *ApplicationTemplateResource) Schema(ctx context.Context, req resource.S } } -func (r *ApplicationTemplateResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { +func (r *TemplateResource) Configure(ctx context.Context, req resource.ConfigureRequest, resp *resource.ConfigureResponse) { // Prevent panic if the provider has not been configured. if req.ProviderData == nil { return @@ -211,8 +211,8 @@ func (r *ApplicationTemplateResource) Configure(ctx context.Context, req resourc r.client = client } -func (r *ApplicationTemplateResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { - var plan *ApplicationTemplateResourceModel +func (r *TemplateResource) Create(ctx context.Context, req resource.CreateRequest, resp *resource.CreateResponse) { + var plan *TemplateResourceModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) @@ -297,7 +297,7 @@ func (r *ApplicationTemplateResource) Create(ctx context.Context, req resource.C } createTplResp, err := r.client.Waypoint.WaypointServiceCreateApplicationTemplate(params, nil) if err != nil { - resp.Diagnostics.AddError("Error creating application template", err.Error()) + resp.Diagnostics.AddError("Error creating template", err.Error()) return } @@ -306,7 +306,7 @@ func (r *ApplicationTemplateResource) Create(ctx context.Context, req resource.C appTemplate = createTplResp.Payload.ApplicationTemplate } if appTemplate == nil { - resp.Diagnostics.AddError("unknown error creating application template", "empty application template returned") + resp.Diagnostics.AddError("unknown error creating template", "empty template returned") return } @@ -364,7 +364,7 @@ func (r *ApplicationTemplateResource) Create(ctx context.Context, req resource.C // Write logs using the tflog package // Documentation: https://terraform.io/plugin/log - tflog.Trace(ctx, "created application template resource") + tflog.Trace(ctx, "created template resource") // Save data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) @@ -398,8 +398,8 @@ func readVarOpts( return varOpts, nil } -func (r *ApplicationTemplateResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { - var data *ApplicationTemplateResourceModel +func (r *TemplateResource) Read(ctx context.Context, req resource.ReadRequest, resp *resource.ReadResponse) { + var data *TemplateResourceModel // Read Terraform prior state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &data)...) @@ -486,8 +486,8 @@ func (r *ApplicationTemplateResource) Read(ctx context.Context, req resource.Rea resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) } -func (r *ApplicationTemplateResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { - var plan *ApplicationTemplateResourceModel +func (r *TemplateResource) Update(ctx context.Context, req resource.UpdateRequest, resp *resource.UpdateResponse) { + var plan *TemplateResourceModel // Read Terraform plan data into the model resp.Diagnostics.Append(req.Plan.Get(ctx, &plan)...) @@ -583,7 +583,7 @@ func (r *ApplicationTemplateResource) Update(ctx context.Context, req resource.U appTemplate = app.Payload.ApplicationTemplate } if appTemplate == nil { - resp.Diagnostics.AddError("unknown error updating application template", "empty application template returned") + resp.Diagnostics.AddError("unknown error updating template", "empty template returned") return } @@ -633,14 +633,14 @@ func (r *ApplicationTemplateResource) Update(ctx context.Context, req resource.U // Write logs using the tflog package // Documentation: https://terraform.io/plugin/log - tflog.Trace(ctx, "updated application template resource") + tflog.Trace(ctx, "updated template resource") // Save updated data into Terraform state resp.Diagnostics.Append(resp.State.Set(ctx, &plan)...) } -func (r *ApplicationTemplateResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { - var data *ApplicationTemplateResourceModel +func (r *TemplateResource) Delete(ctx context.Context, req resource.DeleteRequest, resp *resource.DeleteResponse) { + var data *TemplateResourceModel // Read Terraform prior state data into the model resp.Diagnostics.Append(req.State.Get(ctx, &data)...) @@ -677,17 +677,17 @@ func (r *ApplicationTemplateResource) Delete(ctx context.Context, req resource.D _, err = r.client.Waypoint.WaypointServiceDeleteApplicationTemplate(params, nil) if err != nil { if clients.IsResponseCodeNotFound(err) { - tflog.Info(ctx, "Application Template not found for organization during delete call, ignoring") + tflog.Info(ctx, "Template not found for organization during delete call, ignoring") return } resp.Diagnostics.AddError( - "Error Deleting Application Template", + "Error Deleting Template", err.Error(), ) return } } -func (r *ApplicationTemplateResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { +func (r *TemplateResource) ImportState(ctx context.Context, req resource.ImportStateRequest, resp *resource.ImportStateResponse) { resource.ImportStatePassthroughID(ctx, path.Root("id"), req, resp) } diff --git a/internal/provider/waypoint/resource_waypoint_application_template_test.go b/internal/provider/waypoint/resource_waypoint_template_test.go similarity index 69% rename from internal/provider/waypoint/resource_waypoint_application_template_test.go rename to internal/provider/waypoint/resource_waypoint_template_test.go index b53bb502e..2e962ee31 100644 --- a/internal/provider/waypoint/resource_waypoint_application_template_test.go +++ b/internal/provider/waypoint/resource_waypoint_template_test.go @@ -20,30 +20,30 @@ import ( sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" ) -func TestAccWaypoint_Application_Template_basic(t *testing.T) { - var appTemplateModel waypoint.ApplicationTemplateResourceModel - resourceName := "hcp_waypoint_application_template.test" +func TestAccWaypoint_Template_basic(t *testing.T) { + var appTemplateModel waypoint.TemplateResourceModel + resourceName := "hcp_waypoint_template.test" name := generateRandomName() updatedName := generateRandomName() resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories, - CheckDestroy: testAccCheckWaypointAppTemplateDestroy(t, &appTemplateModel), + CheckDestroy: testAccCheckWaypointTemplateDestroy(t, &appTemplateModel), Steps: []resource.TestStep{ { - Config: testAppTemplateConfig(name), + Config: testTemplateConfig(name), Check: resource.ComposeTestCheckFunc( - testAccCheckWaypointAppTemplateExists(t, resourceName, &appTemplateModel), - testAccCheckWaypointAppTemplateName(t, &appTemplateModel, name), + testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel), + testAccCheckWaypointTemplateName(t, &appTemplateModel, name), resource.TestCheckResourceAttr(resourceName, "name", name), ), }, { - Config: testAppTemplateConfig(updatedName), + Config: testTemplateConfig(updatedName), Check: resource.ComposeTestCheckFunc( - testAccCheckWaypointAppTemplateExists(t, resourceName, &appTemplateModel), - testAccCheckWaypointAppTemplateName(t, &appTemplateModel, updatedName), + testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel), + testAccCheckWaypointTemplateName(t, &appTemplateModel, updatedName), resource.TestCheckResourceAttr(resourceName, "name", updatedName), ), }, @@ -51,21 +51,21 @@ func TestAccWaypoint_Application_Template_basic(t *testing.T) { }) } -func TestAccWaypoint_Application_template_with_variable_options(t *testing.T) { - var appTemplateModel waypoint.ApplicationTemplateResourceModel - resourceName := "hcp_waypoint_application_template.var_opts_test" +func TestAccWaypoint_template_with_variable_options(t *testing.T) { + var appTemplateModel waypoint.TemplateResourceModel + resourceName := "hcp_waypoint_template.var_opts_test" name := generateRandomName() resource.Test(t, resource.TestCase{ PreCheck: func() { acctest.PreCheck(t) }, ProtoV6ProviderFactories: acctest.ProtoV6ProviderFactories, - CheckDestroy: testAccCheckWaypointAppTemplateDestroy(t, &appTemplateModel), + CheckDestroy: testAccCheckWaypointTemplateDestroy(t, &appTemplateModel), Steps: []resource.TestStep{ { - Config: testAppTemplateConfigWithVarOpts(name), + Config: testTemplateConfigWithVarOpts(name), Check: resource.ComposeTestCheckFunc( - testAccCheckWaypointAppTemplateExists(t, resourceName, &appTemplateModel), - testAccCheckWaypointAppTemplateName(t, &appTemplateModel, name), + testAccCheckWaypointTemplateExists(t, resourceName, &appTemplateModel), + testAccCheckWaypointTemplateName(t, &appTemplateModel, name), resource.TestCheckResourceAttr(resourceName, "name", name), ), }, @@ -73,22 +73,22 @@ func TestAccWaypoint_Application_template_with_variable_options(t *testing.T) { }) } -// simple attribute check on the application template receved from the API -func testAccCheckWaypointAppTemplateName(t *testing.T, appTemplateModel *waypoint.ApplicationTemplateResourceModel, nameValue string) resource.TestCheckFunc { +// simple attribute check on the template receved from the API +func testAccCheckWaypointTemplateName(t *testing.T, appTemplateModel *waypoint.TemplateResourceModel, nameValue string) resource.TestCheckFunc { return func(s *terraform.State) error { if appTemplateModel.Name.ValueString() != nameValue { - return fmt.Errorf("expected application template name to be %s, but got %s", nameValue, appTemplateModel.Name.ValueString()) + return fmt.Errorf("expected template name to be %s, but got %s", nameValue, appTemplateModel.Name.ValueString()) } return nil } } -func testAccCheckWaypointAppTemplateExists(t *testing.T, resourceName string, appTemplateModel *waypoint.ApplicationTemplateResourceModel) resource.TestCheckFunc { +func testAccCheckWaypointTemplateExists(t *testing.T, resourceName string, appTemplateModel *waypoint.TemplateResourceModel) resource.TestCheckFunc { return func(s *terraform.State) error { // 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) @@ -102,7 +102,7 @@ func testAccCheckWaypointAppTemplateExists(t *testing.T, resourceName string, ap ProjectID: projectID, } - // Fetch the application template + // Fetch the template template, err := clients.GetApplicationTemplateByID(context.Background(), client, loc, appTempID) if err != nil { return err @@ -120,7 +120,7 @@ func testAccCheckWaypointAppTemplateExists(t *testing.T, resourceName string, ap } } -func testAccCheckWaypointAppTemplateDestroy(t *testing.T, appTemplateModel *waypoint.ApplicationTemplateResourceModel) resource.TestCheckFunc { +func testAccCheckWaypointTemplateDestroy(t *testing.T, appTemplateModel *waypoint.TemplateResourceModel) resource.TestCheckFunc { return func(_ *terraform.State) error { client := acctest.HCPClients(t) id := appTemplateModel.ID.ValueString() @@ -144,16 +144,16 @@ func testAccCheckWaypointAppTemplateDestroy(t *testing.T, appTemplateModel *wayp // fall through, we expect a not found above but if we get this far then // the test should fail if template != nil { - return fmt.Errorf("expected application template to be destroyed, but it still exists") + return fmt.Errorf("expected Template to be destroyed, but it still exists") } return fmt.Errorf("both template and error were nil in destroy check, this should not happen") } } -func testAppTemplateConfig(name string) string { +func testTemplateConfig(name string) string { return fmt.Sprintf(` -resource "hcp_waypoint_application_template" "test" { +resource "hcp_waypoint_template" "test" { name = "%s" summary = "some summary for fun" readme_markdown_template = base64encode("# Some Readme") @@ -169,9 +169,9 @@ resource "hcp_waypoint_application_template" "test" { }`, name) } -func testAppTemplateConfigWithVarOpts(name string) string { +func testTemplateConfigWithVarOpts(name string) string { return fmt.Sprintf(` -resource "hcp_waypoint_application_template" "var_opts_test" { +resource "hcp_waypoint_template" "var_opts_test" { name = "%s" summary = "A template with a variable with options." readme_markdown_template = base64encode("# Some Readme") diff --git a/templates/data-sources/waypoint_application_template.md.tmpl b/templates/data-sources/waypoint_template.md.tmpl similarity index 100% rename from templates/data-sources/waypoint_application_template.md.tmpl rename to templates/data-sources/waypoint_template.md.tmpl diff --git a/templates/resources/waypoint_application_template.md.tmpl b/templates/resources/waypoint_template.md.tmpl similarity index 100% rename from templates/resources/waypoint_application_template.md.tmpl rename to templates/resources/waypoint_template.md.tmpl