From 829d3af329d91bd728d0b17d857ad7769c074642 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20W=C3=BCrbach?= Date: Wed, 18 Oct 2023 10:03:51 +0200 Subject: [PATCH] fix: user mapping resource naming --- ...pplication_user.md => application_user.md} | 20 +++++++++++++++++-- ..._type_user.md => environment_type_user.md} | 20 +++++++++++++++++-- .../provider/resource_application_user.go | 2 +- .../resource_application_user_test.go | 10 +++++----- .../resource_environment_type_user.go | 2 +- .../resource_environment_type_user_test.go | 10 +++++----- 6 files changed, 48 insertions(+), 16 deletions(-) rename docs/resources/{resource_application_user.md => application_user.md} (74%) rename docs/resources/{resource_environment_type_user.md => environment_type_user.md} (73%) diff --git a/docs/resources/resource_application_user.md b/docs/resources/application_user.md similarity index 74% rename from docs/resources/resource_application_user.md rename to docs/resources/application_user.md index d2b9b72..ba7e6e2 100644 --- a/docs/resources/resource_application_user.md +++ b/docs/resources/application_user.md @@ -1,16 +1,24 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "humanitec_resource_application_user Resource - terraform-provider-humanitec" +page_title: "humanitec_application_user Resource - terraform-provider-humanitec" subcategory: "" description: |- Resource Application User holds the mapping of role to user for an application. --- -# humanitec_resource_application_user (Resource) +# humanitec_application_user (Resource) Resource Application User holds the mapping of role to user for an application. +## Example Usage +```terraform +resource "humanitec_application_user" "another_owner" { + app_id = "example" + user_id = "user-id" + role = "owner" +} +``` ## Schema @@ -36,3 +44,11 @@ Optional: - `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). - `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import humanitec_resource_application_user.example app_id/user_id +``` diff --git a/docs/resources/resource_environment_type_user.md b/docs/resources/environment_type_user.md similarity index 73% rename from docs/resources/resource_environment_type_user.md rename to docs/resources/environment_type_user.md index 6583213..b578d22 100644 --- a/docs/resources/resource_environment_type_user.md +++ b/docs/resources/environment_type_user.md @@ -1,16 +1,24 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "humanitec_resource_environment_type_user Resource - terraform-provider-humanitec" +page_title: "humanitec_environment_type_user Resource - terraform-provider-humanitec" subcategory: "" description: |- Resource Environment Type User holds the mapping of role to user for an environment type. --- -# humanitec_resource_environment_type_user (Resource) +# humanitec_environment_type_user (Resource) Resource Environment Type User holds the mapping of role to user for an environment type. +## Example Usage +```terraform +resource "humanitec_environment_type_user" "another_deployer" { + env_type_id = "production" + user_id = "user-id" + role = "deployer" +} +``` ## Schema @@ -36,3 +44,11 @@ Optional: - `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). - `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled. + +## Import + +Import is supported using the following syntax: + +```shell +terraform import humanitec_resource_environment_type_user.example env_type_id/user_id +``` diff --git a/internal/provider/resource_application_user.go b/internal/provider/resource_application_user.go index 0b5bfe0..36e415d 100644 --- a/internal/provider/resource_application_user.go +++ b/internal/provider/resource_application_user.go @@ -50,7 +50,7 @@ type ResourceApplicationUserModel struct { } func (r *ResourceApplicationUser) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_resource_application_user" + resp.TypeName = req.ProviderTypeName + "_application_user" } func (r *ResourceApplicationUser) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/internal/provider/resource_application_user_test.go b/internal/provider/resource_application_user_test.go index 9a4bc39..a93930d 100644 --- a/internal/provider/resource_application_user_test.go +++ b/internal/provider/resource_application_user_test.go @@ -21,13 +21,13 @@ func TestAccResourceApplicationUser(t *testing.T) { { Config: testAccResourceApplicationUser(id, testUserID, "owner"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_application_user.another_user", "id", fmt.Sprintf("%s/%s", id, testUserID)), - resource.TestCheckResourceAttr("humanitec_resource_application_user.another_user", "role", "owner"), + resource.TestCheckResourceAttr("humanitec_application_user.another_user", "id", fmt.Sprintf("%s/%s", id, testUserID)), + resource.TestCheckResourceAttr("humanitec_application_user.another_user", "role", "owner"), ), }, // ImportState testing { - ResourceName: "humanitec_resource_application_user.another_user", + ResourceName: "humanitec_application_user.another_user", ImportState: true, ImportStateVerify: true, ImportStateIdFunc: func(s *terraform.State) (string, error) { @@ -38,7 +38,7 @@ func TestAccResourceApplicationUser(t *testing.T) { { Config: testAccResourceApplicationUser(id, testUserID, "developer"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_application_user.another_user", "role", "developer"), + resource.TestCheckResourceAttr("humanitec_application_user.another_user", "role", "developer"), ), }, // Delete testing automatically occurs in TestCase @@ -53,7 +53,7 @@ resource "humanitec_application" "app_user_test" { name = "%s" } -resource "humanitec_resource_application_user" "another_user" { +resource "humanitec_application_user" "another_user" { app_id = humanitec_application.app_user_test.id user_id = "%s" role = "%s" diff --git a/internal/provider/resource_environment_type_user.go b/internal/provider/resource_environment_type_user.go index 24db5e6..2084a16 100644 --- a/internal/provider/resource_environment_type_user.go +++ b/internal/provider/resource_environment_type_user.go @@ -50,7 +50,7 @@ type ResourceEnvironmentTypeUserModel struct { } func (r *ResourceEnvironmentTypeUser) Metadata(ctx context.Context, req resource.MetadataRequest, resp *resource.MetadataResponse) { - resp.TypeName = req.ProviderTypeName + "_resource_environment_type_user" + resp.TypeName = req.ProviderTypeName + "_environment_type_user" } func (r *ResourceEnvironmentTypeUser) Schema(ctx context.Context, req resource.SchemaRequest, resp *resource.SchemaResponse) { diff --git a/internal/provider/resource_environment_type_user_test.go b/internal/provider/resource_environment_type_user_test.go index f13114e..c8e2fa3 100644 --- a/internal/provider/resource_environment_type_user_test.go +++ b/internal/provider/resource_environment_type_user_test.go @@ -21,13 +21,13 @@ func TestAccResourceEnvironmentTypeUser(t *testing.T) { { Config: testAccResourceEnvironmentTypeUser(id, testUserID, "deployer"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_environment_type_user.another_user", "id", fmt.Sprintf("%s/%s", id, testUserID)), - resource.TestCheckResourceAttr("humanitec_resource_environment_type_user.another_user", "role", "deployer"), + resource.TestCheckResourceAttr("humanitec_environment_type_user.another_user", "id", fmt.Sprintf("%s/%s", id, testUserID)), + resource.TestCheckResourceAttr("humanitec_environment_type_user.another_user", "role", "deployer"), ), }, // ImportState testing { - ResourceName: "humanitec_resource_environment_type_user.another_user", + ResourceName: "humanitec_environment_type_user.another_user", ImportState: true, ImportStateVerify: true, ImportStateIdFunc: func(s *terraform.State) (string, error) { @@ -39,7 +39,7 @@ func TestAccResourceEnvironmentTypeUser(t *testing.T) { // At the moment there is nothing we can update :-/ Config: testAccResourceEnvironmentTypeUser(id, testUserID, "deployer"), Check: resource.ComposeAggregateTestCheckFunc( - resource.TestCheckResourceAttr("humanitec_resource_environment_type_user.another_user", "role", "deployer"), + resource.TestCheckResourceAttr("humanitec_environment_type_user.another_user", "role", "deployer"), ), }, // Delete testing automatically occurs in TestCase @@ -54,7 +54,7 @@ resource "humanitec_environment_type" "qa" { description = "%s" } -resource "humanitec_resource_environment_type_user" "another_user" { +resource "humanitec_environment_type_user" "another_user" { env_type_id = humanitec_environment_type.qa.id user_id = "%s" role = "%s"