generated from hashicorp/terraform-provider-scaffolding
-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New Resource: Waypoint Application Template (#778)
* CRUD for application template and data source - labels still can't be completely removed due to API bug * add data source and test updates * add generated docs for waypoint app template data source * update docs * changelog * revert go/toolchain update * Update internal/provider/waypoint/data_source_waypoint_application_template.go Co-authored-by: Brian Cain <[email protected]> * Update internal/provider/waypoint/data_source_waypoint_application_template.go Co-authored-by: Brian Cain <[email protected]> * Update internal/provider/waypoint/resource_waypoint_application_template.go Co-authored-by: Brian Cain <[email protected]> * update docs * update data source fields to be computed not optional; regen docs --------- Co-authored-by: Brian Cain <[email protected]>
- Loading branch information
Showing
9 changed files
with
1,192 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```release-note:feature | ||
New resource: Add `hcp_waypoint_application_template` resource for managing Waypoint Application Templates. | ||
New data-source: Add `data.hcp_waypoint_application_template` data-source for Waypoint Application Templates. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "hcp_waypoint_application_template Data Source - terraform-provider-hcp" | ||
subcategory: "" | ||
description: |- | ||
The Waypoint Template data source retrieves information on a given Application Template. | ||
--- | ||
|
||
# hcp_waypoint_application_template (Data Source) | ||
|
||
The Waypoint Template data source retrieves information on a given Application Template. | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## 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. | ||
|
||
### 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. | ||
- `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)) | ||
|
||
<a id="nestedatt--terraform_cloud_workspace_details"></a> | ||
### Nested Schema for `terraform_cloud_workspace_details` | ||
|
||
Read-Only: | ||
|
||
- `name` (String) Name of the Terraform Cloud Workspace | ||
- `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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "hcp_waypoint_application_template Resource - terraform-provider-hcp" | ||
subcategory: "" | ||
description: |- | ||
Waypoint Application Template resource | ||
--- | ||
|
||
# hcp_waypoint_application_template (Resource) | ||
|
||
Waypoint Application Template resource | ||
|
||
|
||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `name` (String) The name of the Application 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)) | ||
|
||
### 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. | ||
- `readme_markdown_template` (String) Instructions for using the template (markdown format supported | ||
|
||
### 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. | ||
|
||
<a id="nestedatt--terraform_cloud_workspace_details"></a> | ||
### Nested Schema for `terraform_cloud_workspace_details` | ||
|
||
Required: | ||
|
||
- `name` (String) Name of the Terraform Cloud Workspace | ||
- `terraform_project_id` (String) Tetraform 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// Copyright (c) HashiCorp, Inc. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
package clients | ||
|
||
import ( | ||
"context" | ||
|
||
sharedmodels "github.com/hashicorp/hcp-sdk-go/clients/cloud-shared/v1/models" | ||
"github.com/hashicorp/hcp-sdk-go/clients/cloud-waypoint-service/preview/2023-08-18/client/waypoint_service" | ||
waypoint_models "github.com/hashicorp/hcp-sdk-go/clients/cloud-waypoint-service/preview/2023-08-18/models" | ||
) | ||
|
||
// getNamespaceByLocation will retrieve a namespace by location information | ||
// provided by HCP | ||
func getNamespaceByLocation(_ context.Context, client *Client, loc *sharedmodels.HashicorpCloudLocationLocation) (*waypoint_models.HashicorpCloudWaypointNamespace, error) { | ||
namespaceParams := &waypoint_service.WaypointServiceGetNamespaceParams{ | ||
LocationOrganizationID: loc.OrganizationID, | ||
LocationProjectID: loc.ProjectID, | ||
} | ||
// get namespace | ||
ns, err := client.Waypoint.WaypointServiceGetNamespace(namespaceParams, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return ns.GetPayload().Namespace, nil | ||
} | ||
|
||
// GetApplicationTemplateByName will retrieve an application 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 { | ||
return nil, err | ||
} | ||
|
||
params := &waypoint_service.WaypointServiceGetApplicationTemplate2Params{ | ||
ApplicationTemplateName: appName, | ||
NamespaceID: ns.ID, | ||
} | ||
|
||
getResp, err := client.Waypoint.WaypointServiceGetApplicationTemplate2(params, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return getResp.GetPayload().ApplicationTemplate, nil | ||
} | ||
|
||
// GetApplicationTemplateByID will retrieve an application 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 { | ||
return nil, err | ||
} | ||
|
||
params := &waypoint_service.WaypointServiceGetApplicationTemplateParams{ | ||
ApplicationTemplateID: appID, | ||
NamespaceID: ns.ID, | ||
} | ||
|
||
getResp, err := client.Waypoint.WaypointServiceGetApplicationTemplate(params, nil) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return getResp.GetPayload().ApplicationTemplate, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.