Skip to content

Commit

Permalink
Rename for_all_deployments -> all_deployments / for_all_projects -> a…
Browse files Browse the repository at this point in the history
…ll_projects
  • Loading branch information
gigerdo committed Sep 13, 2024
1 parent ae5f6b9 commit a07071f
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 34 deletions.
16 changes: 8 additions & 8 deletions docs/resources/organization.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ resource "ec_organization" "my_org" {
deployment_roles = [
# A role can be given for all deployments
{
role = "editor"
for_all_deployments = true
role = "editor"
all_deployments = true
},
# Or just for specific deployments
Expand All @@ -61,8 +61,8 @@ resource "ec_organization" "my_org" {
project_elasticsearch_roles = [
# A role can be given for all projects
{
role = "admin"
for_all_projects = true
role = "admin"
all_projects = true
},
# Or just for specific projects
Expand Down Expand Up @@ -94,17 +94,17 @@ locals {
deployment_admin = {
deployment_roles = [
{
role = "admin"
for_all_deployments = true
role = "admin"
all_deployments = true
}
]
}
deployment_viewer = {
deployment_roles = [
{
role = "viewer"
for_all_deployments = true
role = "viewer"
all_deployments = true
}
]
}
Expand Down
24 changes: 12 additions & 12 deletions ec/ecresource/organizationresource/resource_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,25 +73,25 @@ func TestOrganizationResourceAgainstMockedAPI(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.role", "editor"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.deployment_ids.0", "abc"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.1.role", "viewer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.1.for_all_deployments", "true"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.1.all_deployments", "true"),

// Elasticsearch roles
resource.TestCheckResourceAttr(resourceName, "[email protected]_elasticsearch_roles.0.role", "developer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_elasticsearch_roles.0.project_ids.0", "qwe"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_elasticsearch_roles.1.role", "viewer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_elasticsearch_roles.1.for_all_projects", "true"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_elasticsearch_roles.1.all_projects", "true"),

// Observability roles
resource.TestCheckResourceAttr(resourceName, "[email protected]_observability_roles.0.role", "editor"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_observability_roles.0.project_ids.0", "rty"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_observability_roles.1.role", "viewer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_observability_roles.1.for_all_projects", "true"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_observability_roles.1.all_projects", "true"),

// Project roles
resource.TestCheckResourceAttr(resourceName, "[email protected]_security_roles.0.role", "editor"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_security_roles.0.project_ids.0", "uio"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_security_roles.1.role", "viewer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_security_roles.1.for_all_projects", "true"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_security_roles.1.all_projects", "true"),
),
},
// A newly added member should be invited to the organization
Expand Down Expand Up @@ -138,7 +138,7 @@ func TestOrganizationResourceAgainstMockedAPI(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.role", "editor"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.deployment_ids.0", "abc"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.1.role", "viewer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.1.for_all_deployments", "true"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.1.all_deployments", "true"),
),
},
// Removing roles from member
Expand All @@ -149,7 +149,7 @@ func TestOrganizationResourceAgainstMockedAPI(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "[email protected]", "[email protected]"),
resource.TestCheckNoResourceAttr(resourceName, "[email protected]_role"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.role", "viewer"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.for_all_deployments", "true"),
resource.TestCheckResourceAttr(resourceName, "[email protected]_roles.0.all_deployments", "true"),
),
},
// Removing member from organization
Expand Down Expand Up @@ -550,7 +550,7 @@ resource "ec_organization" "myorg" {
deployment_roles = [
{
role = "viewer"
for_all_deployments = true
all_deployments = true
},
{
role = "editor"
Expand All @@ -561,7 +561,7 @@ resource "ec_organization" "myorg" {
project_elasticsearch_roles = [
{
role = "viewer"
for_all_projects = true
all_projects = true
},
{
role = "developer"
Expand All @@ -572,7 +572,7 @@ resource "ec_organization" "myorg" {
project_observability_roles = [
{
role = "viewer"
for_all_projects = true
all_projects = true
},
{
role = "editor"
Expand All @@ -583,7 +583,7 @@ resource "ec_organization" "myorg" {
project_security_roles = [
{
role = "viewer"
for_all_projects = true
all_projects = true
},
{
role = "editor"
Expand Down Expand Up @@ -616,7 +616,7 @@ const memberWithNewRoles = `
deployment_roles = [
{
role = "viewer"
for_all_deployments = true
all_deployments = true
},
{
role = "editor"
Expand All @@ -631,7 +631,7 @@ const memberWithRemovedRoles = `
deployment_roles = [
{
role = "viewer"
for_all_deployments = true
all_deployments = true
}
]
}
Expand Down
12 changes: 6 additions & 6 deletions ec/ecresource/organizationresource/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ type OrganizationMember struct {

type DeploymentRoleAssignment struct {
Role types.String `tfsdk:"role"`
ForAllDeployments types.Bool `tfsdk:"for_all_deployments"`
ForAllDeployments types.Bool `tfsdk:"all_deployments"`
DeploymentIDs types.Set `tfsdk:"deployment_ids"`
ApplicationRoles types.Set `tfsdk:"application_roles"`
}

type ProjectRoleAssignment struct {
Role types.String `tfsdk:"role"`
ForAllProjects types.Bool `tfsdk:"for_all_projects"`
ForAllProjects types.Bool `tfsdk:"all_projects"`
ProjectIDs types.Set `tfsdk:"project_ids"`
ApplicationRoles types.Set `tfsdk:"application_roles"`
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func deploymentRoleAssignmentsSchema() schema.SetNestedAttribute {
MarkdownDescription: "Assigned role. Must be on of `viewer`, `editor` or `admin`.",
Required: true,
},
"for_all_deployments": schema.BoolAttribute{
"all_deployments": schema.BoolAttribute{
MarkdownDescription: "Role applies to all deployments in the organization.",
Optional: true,
PlanModifiers: []planmodifier.Bool{
Expand Down Expand Up @@ -220,15 +220,15 @@ func projectRoleAssignmentSchema(roles []string) schema.NestedAttributeObject {
MarkdownDescription: fmt.Sprintf("Assigned role. (Allowed values: %s)", "`"+strings.Join(roles, "`, `")+"`"),
Required: true,
},
"for_all_projects": schema.BoolAttribute{
MarkdownDescription: "Role applies to all deployments in the organization.",
"all_projects": schema.BoolAttribute{
MarkdownDescription: "Role applies to all projects in the organization.",
Optional: true,
PlanModifiers: []planmodifier.Bool{
planmodifiers.BoolDefaultValue(false), // consider unknown as false
},
},
"project_ids": schema.SetAttribute{
MarkdownDescription: "Role applies to deployments listed here.",
MarkdownDescription: "Role applies to projects listed here.",
Optional: true,
ElementType: types.StringType,
},
Expand Down
8 changes: 4 additions & 4 deletions examples/resources/ec_organization/basic.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ resource "ec_organization" "my_org" {
deployment_roles = [
# A role can be given for all deployments
{
role = "editor"
for_all_deployments = true
role = "editor"
all_deployments = true
},

# Or just for specific deployments
Expand All @@ -27,8 +27,8 @@ resource "ec_organization" "my_org" {
project_elasticsearch_roles = [
# A role can be given for all projects
{
role = "admin"
for_all_projects = true
role = "admin"
all_projects = true
},

# Or just for specific projects
Expand Down
8 changes: 4 additions & 4 deletions examples/resources/ec_organization/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@ locals {
deployment_admin = {
deployment_roles = [
{
role = "admin"
for_all_deployments = true
role = "admin"
all_deployments = true
}
]
}

deployment_viewer = {
deployment_roles = [
{
role = "viewer"
for_all_deployments = true
role = "viewer"
all_deployments = true
}
]
}
Expand Down

0 comments on commit a07071f

Please sign in to comment.