Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix environment resource variables on create #176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions client/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,16 +41,17 @@ type ProjectCreatePayload struct {
}

type EnvironmentCreate struct {
Name string `json:"name"`
ProjectId string `json:"projectId"`
DeployRequest *DeployRequest `json:"deployRequest"`
WorkspaceName string `json:"workspaceName,omitempty"`
RequiresApproval *bool `json:"requiresApproval,omitempty"`
ContinuousDeployment *bool `json:"continuousDeployment,omitempty"`
PullRequestPlanDeployments *bool `json:"pullRequestPlanDeployments,omitempty"`
AutoDeployOnPathChangesOnly *bool `json:"autoDeployOnPathChangesOnly,omitempty"`
AutoDeployByCustomGlob string `json:"autoDeployByCustomGlob,omitempty"`
TTL *TTL `json:"ttl,omitempty"`
Name string `json:"name"`
ProjectId string `json:"projectId"`
DeployRequest *DeployRequest `json:"deployRequest"`
WorkspaceName string `json:"workspaceName,omitempty"`
RequiresApproval *bool `json:"requiresApproval,omitempty"`
ContinuousDeployment *bool `json:"continuousDeployment,omitempty"`
PullRequestPlanDeployments *bool `json:"pullRequestPlanDeployments,omitempty"`
AutoDeployOnPathChangesOnly *bool `json:"autoDeployOnPathChangesOnly,omitempty"`
AutoDeployByCustomGlob string `json:"autoDeployByCustomGlob,omitempty"`
ConfigurationChanges *ConfigurationChanges `json:"configurationChanges,omitempty"`
TTL *TTL `json:"ttl,omitempty"`
}

type DeployRequest struct {
Expand Down
6 changes: 5 additions & 1 deletion env0/resource_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ func getCreatePayload(d *schema.ResourceData) client.EnvironmentCreate {
if autoDeployByCustomGlob, ok := d.GetOk("auto_deploy_by_custom_glob"); ok {
payload.AutoDeployByCustomGlob = autoDeployByCustomGlob.(string)
}
if configuration, ok := d.GetOk("configuration"); ok {
configurationChanges := getConfigurationVariables(configuration.([]interface{}))
payload.ConfigurationChanges = &configurationChanges
}
if ttl, ok := d.GetOk("ttl"); ok {
ttlPayload := getTTl(ttl.(string))
payload.TTL = &ttlPayload
Expand Down Expand Up @@ -429,7 +433,7 @@ func getConfigurationVariableForEnvironment(variable map[string]interface{}) cli
configurationVariable.Description = variable["description"].(string)
}

if variable["schema_type"] != nil && variable["schema_enum"] != nil {
if variable["schema_type"] != "" && len(variable["schema_enum"].([]interface{})) > 0 {
enumOfAny := variable["schema_enum"].([]interface{})
enum := make([]string, len(enumOfAny))
for i := range enum {
Expand Down