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

Feat: resource env0_environment - add support to change template_id #998

Merged
merged 2 commits into from
Dec 22, 2024

Conversation

TomerHeber
Copy link
Collaborator

Issue & Steps to Reproduce / Feature Request

resolves #986

Solution

  1. Removed the code that blocked modifying template_id from an environment.
  2. Updated the schema description.
  3. Will now run a redeploy if tempate_id is modified (I have verified that it's the same behavior as in env0 UI).
  4. Updated acceptance tests.
  5. Added a harness test.

@TomerHeber
Copy link
Collaborator Author

/review

@bot-env0 bot-env0 requested a review from a team December 21, 2024 19:57
@@ -382,13 +381,6 @@ func resourceEnvironment() *schema.Resource {
Optional: true,
},
},
CustomizeDiff: customdiff.ValidateChange("template_id", func(ctx context.Context, oldValue, newValue, meta interface{}) error {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this blocked changing template_id...

@@ -736,7 +728,7 @@ func shouldDeploy(d *schema.ResourceData) bool {
}
}

return d.HasChanges("revision", "configuration", "sub_environment_configuration", "variable_sets")
return d.HasChanges("revision", "configuration", "sub_environment_configuration", "variable_sets", "template_id")
Copy link
Collaborator Author

@TomerHeber TomerHeber Dec 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will call redeploy if template_id has changed.

@@ -626,6 +643,12 @@ func TestUnitEnvironmentResource(t *testing.T) {
mock.EXPECT().ConfigurationSetsAssignments("ENVIRONMENT", environment.Id).Times(1).Return(nil, nil),
mock.EXPECT().Environment(environment.Id).Times(1).Return(environment, nil),
mock.EXPECT().ConfigurationVariablesByScope(client.ScopeEnvironment, environment.Id).Times(1).Return(client.ConfigurationChanges{}, nil),
mock.EXPECT().ConfigurationSetsAssignments("ENVIRONMENT", environment.Id).Times(2).Return(nil, nil),
mock.EXPECT().EnvironmentDeploy(environment.Id, deployRequest).Times(1).Return(client.EnvironmentDeployResponse{
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is important - it shows that redeploy is called.

Copy link
Contributor

@liranfarage89 liranfarage89 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

env0/resource_environment.go Outdated Show resolved Hide resolved
@github-actions github-actions bot added ready to merge PR approved - can be merged once the PR owner is ready and removed pending final review labels Dec 22, 2024
@TomerHeber TomerHeber merged commit 405ac96 into main Dec 22, 2024
4 checks passed
@TomerHeber TomerHeber deleted the feat-change-template-id-#986 branch December 22, 2024 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature integration-tests provider ready to merge PR approved - can be merged once the PR owner is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

resource env0_environment - add support to change template_id
2 participants