Skip to content

Commit

Permalink
fix: user mapping resource naming
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneswuerbach committed Oct 18, 2023
1 parent a6ddbef commit 829d3af
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
Original file line number Diff line number Diff line change
@@ -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 generated by tfplugindocs -->
## Schema
Expand All @@ -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
```
Original file line number Diff line number Diff line change
@@ -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 generated by tfplugindocs -->
## Schema
Expand All @@ -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
```
2 changes: 1 addition & 1 deletion internal/provider/resource_application_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/resource_application_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/resource_environment_type_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions internal/provider/resource_environment_type_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit 829d3af

Please sign in to comment.