Skip to content

Commit

Permalink
Merge branch 'main' into feat-add-support-for-duration-#710
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber authored Sep 21, 2023
2 parents 93be30b + 1fa7a0e commit 61437b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 6 additions & 1 deletion client/remote_state_access.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type RemoteStateAccessConfiguration struct {

type RemoteStateAccessConfigurationCreate struct {
AccessibleFromEntireOrganization bool `json:"accessibleFromEntireOrganization"`
AllowedProjectIds []string `json:"allowedProjectIds,omitempty"`
AllowedProjectIds []string `json:"allowedProjectIds"`
}

func (client *ApiClient) RemoteStateAccessConfiguration(environmentId string) (*RemoteStateAccessConfiguration, error) {
Expand All @@ -22,6 +22,11 @@ func (client *ApiClient) RemoteStateAccessConfiguration(environmentId string) (*
}

func (client *ApiClient) RemoteStateAccessConfigurationCreate(environmentId string, payload RemoteStateAccessConfigurationCreate) (*RemoteStateAccessConfiguration, error) {
// The API doesn't accept "null". If the array isn't set, pass "[]" instead.
if payload.AllowedProjectIds == nil {
payload.AllowedProjectIds = []string{}
}

var result RemoteStateAccessConfiguration
if err := client.http.Put("/remote-backend/states/"+environmentId+"/access-control", payload, &result); err != nil {
return nil, err
Expand Down
9 changes: 5 additions & 4 deletions tests/integration/012_environment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ resource "env0_team_environment_assignment" "team_role_environment_assignment" {
role_id = var.second_run ? env0_custom_role.custom_role1.id : env0_custom_role.custom_role2.id
}

/* TODO: need to add an integration test.
resource "env0_environment_state_access" "state_access" {
environment_id = env0_environment.example.id
allowed_project_ids = [env0_project.test_project.id]
/* TODO
resource "env0_environment_state_access" "disallow" {
environment_id = env0_environment.example.id
accessible_from_entire_organization = false
allowed_project_ids = []
}
*/

Expand Down

0 comments on commit 61437b9

Please sign in to comment.