Skip to content

Commit

Permalink
Merge branch 'main' into feat-add-auto-approve-for-sub-#869
Browse files Browse the repository at this point in the history
  • Loading branch information
TomerHeber authored Jun 24, 2024
2 parents 753e36a + bef9f11 commit bd3db67
Show file tree
Hide file tree
Showing 9 changed files with 386 additions and 55 deletions.
2 changes: 1 addition & 1 deletion client/configuration_set_assignment.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func (client *ApiClient) UnassignConfigurationSets(scope string, scopeId string,
func (client *ApiClient) ConfigurationSetsAssignments(scope string, scopeId string) ([]ConfigurationSet, error) {
var result []ConfigurationSet

url := fmt.Sprintf("/configuration-sets/assignments/%s/%s", scope, scopeId)
url := fmt.Sprintf("/configuration-sets/assignments/%s/%s", strings.ToLower(scope), scopeId)

if err := client.http.Get(url, nil, &result); err != nil {
return nil, err
Expand Down
3 changes: 1 addition & 2 deletions client/configuration_variable.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ func (client *ApiClient) ConfigurationVariablesByScope(scope Scope, scopeId stri
case scope == ScopeDeploymentLog:
params["deploymentLogId"] = scopeId
case scope == ScopeWorkflow:
params["environmentId"] = scopeId // temporary mitigation
scope = ScopeEnvironment // temporary mitigation
params["environmentId"] = scopeId
params["workflowEnvironmentId"] = scopeId
}
err = client.http.Get("/configuration", params, &result)
Expand Down
61 changes: 34 additions & 27 deletions client/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,15 @@ type SubEnvironment struct {
}

type DeployRequest struct {
BlueprintId string `json:"blueprintId,omitempty"`
BlueprintRevision string `json:"blueprintRevision,omitempty"`
BlueprintRepository string `json:"blueprintRepository,omitempty"`
ConfigurationChanges *ConfigurationChanges `json:"configurationChanges,omitempty"`
TTL *TTL `json:"ttl,omitempty"`
EnvName string `json:"envName,omitempty"`
UserRequiresApproval *bool `json:"userRequiresApproval,omitempty"`
SubEnvironments map[string]SubEnvironment `json:"subEnvironments,omitempty"`
BlueprintId string `json:"blueprintId,omitempty"`
BlueprintRevision string `json:"blueprintRevision,omitempty"`
BlueprintRepository string `json:"blueprintRepository,omitempty"`
ConfigurationChanges *ConfigurationChanges `json:"configurationChanges,omitempty"`
TTL *TTL `json:"ttl,omitempty"`
EnvName string `json:"envName,omitempty"`
UserRequiresApproval *bool `json:"userRequiresApproval,omitempty"`
SubEnvironments map[string]SubEnvironment `json:"subEnvironments,omitempty"`
ConfigurationSetChanges *ConfigurationSetChanges `json:"configurationSetChanges,omitempty" tfschema:"-"`
}

type WorkflowSubEnvironment struct {
Expand All @@ -100,6 +101,11 @@ type DriftDetectionRequest struct {
Cron string `json:"cron"`
}

type ConfigurationSetChanges struct {
Assign []string `json:"assign,omitempty"`
Unassign []string `json:"unassign,omitempty"`
}

type Environment struct {
Id string `json:"id"`
Name string `json:"name"`
Expand All @@ -120,29 +126,30 @@ type Environment struct {
IsRemoteBackend *bool `json:"isRemoteBackend" tfschema:"-"`
IsArchived *bool `json:"isArchived" tfschema:"-"`
IsRemoteApplyEnabled bool `json:"isRemoteApplyEnabled"`
K8sNamespace string `json:"k8s_namespace"`
K8sNamespace string `json:"k8sNamespace"`
IsSingleUseBlueprint bool `json:"isSingleUseBlueprint" tfschema:"-"`
}

type EnvironmentCreate struct {
Name string `json:"name"`
ProjectId string `json:"projectId"`
DeployRequest *DeployRequest `json:"deployRequest" tfschema:"-"`
WorkspaceName string `json:"workspaceName,omitempty" tfschema:"workspace"`
RequiresApproval *bool `json:"requiresApproval,omitempty" tfschema:"-"`
ContinuousDeployment *bool `json:"continuousDeployment,omitempty" tfschema:"-"`
PullRequestPlanDeployments *bool `json:"pullRequestPlanDeployments,omitempty" tfschema:"-"`
AutoDeployOnPathChangesOnly *bool `json:"autoDeployOnPathChangesOnly,omitempty" tfchema:"-"`
AutoDeployByCustomGlob string `json:"autoDeployByCustomGlob"`
ConfigurationChanges *ConfigurationChanges `json:"configurationChanges,omitempty" tfschema:"-"`
TTL *TTL `json:"ttl,omitempty" tfschema:"-"`
TerragruntWorkingDirectory string `json:"terragruntWorkingDirectory,omitempty"`
VcsCommandsAlias string `json:"vcsCommandsAlias"`
IsRemoteBackend *bool `json:"isRemoteBackend,omitempty" tfschema:"-"`
Type string `json:"type,omitempty"`
DriftDetectionRequest *DriftDetectionRequest `json:"driftDetectionRequest,omitempty" tfschema:"-"`
PreventAutoDeploy *bool `json:"preventAutoDeploy,omitempty" tfschema:"-"`
K8sNamespace string `json:"k8s_namespace,omitempty"`
Name string `json:"name"`
ProjectId string `json:"projectId"`
DeployRequest *DeployRequest `json:"deployRequest" tfschema:"-"`
WorkspaceName string `json:"workspaceName,omitempty" tfschema:"workspace"`
RequiresApproval *bool `json:"requiresApproval,omitempty" tfschema:"-"`
ContinuousDeployment *bool `json:"continuousDeployment,omitempty" tfschema:"-"`
PullRequestPlanDeployments *bool `json:"pullRequestPlanDeployments,omitempty" tfschema:"-"`
AutoDeployOnPathChangesOnly *bool `json:"autoDeployOnPathChangesOnly,omitempty" tfchema:"-"`
AutoDeployByCustomGlob string `json:"autoDeployByCustomGlob"`
ConfigurationChanges *ConfigurationChanges `json:"configurationChanges,omitempty" tfschema:"-"`
TTL *TTL `json:"ttl,omitempty" tfschema:"-"`
TerragruntWorkingDirectory string `json:"terragruntWorkingDirectory,omitempty"`
VcsCommandsAlias string `json:"vcsCommandsAlias"`
IsRemoteBackend *bool `json:"isRemoteBackend,omitempty" tfschema:"-"`
Type string `json:"type,omitempty"`
DriftDetectionRequest *DriftDetectionRequest `json:"driftDetectionRequest,omitempty" tfschema:"-"`
PreventAutoDeploy *bool `json:"preventAutoDeploy,omitempty" tfschema:"-"`
K8sNamespace string `json:"k8sNamespace,omitempty"`
ConfigurationSetChanges *ConfigurationSetChanges `json:"configurationSetChanges,omitempty" tfschema:"-"`
}

// When converted to JSON needs to be flattened. See custom MarshalJSON below.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/environment.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Important note: the template must first be assigned to the same project as the e
Important note: After the environment is created, this field cannot be modified.
- `terragrunt_working_directory` (String) The working directory path to be used by a Terragrunt template. If left empty '/' is used. Note: modifying this field destroys the current environment and creates a new one
- `ttl` (String) the date the environment should be destroyed at (iso format). omitting this attribute will result in infinite ttl.
- `variable_sets` (List of String) a list of variable set to assign to this environment
- `vcs_commands_alias` (String) set an alias for this environment in favor of running VCS commands using PR comments against it. Additional details: https://docs.env0.com/docs/plan-and-apply-from-pr-comments
- `without_template_settings` (Block List, Max: 1) settings for creating an environment without a template (see [below for nested schema](#nestedblock--without_template_settings))
- `workspace` (String) the terraform workspace of the environment
Expand Down
2 changes: 1 addition & 1 deletion env0/data_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func dataEnvironmentRead(ctx context.Context, d *schema.ResourceData, meta inter
}
}

setEnvironmentSchema(ctx, d, environment, client.ConfigurationChanges{})
setEnvironmentSchema(ctx, d, environment, client.ConfigurationChanges{}, nil)

templateId := environment.LatestDeploymentLog.BlueprintId

Expand Down
Loading

0 comments on commit bd3db67

Please sign in to comment.