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: env0_environment does not redeploy when revision is changed in w… #907

Merged
merged 1 commit into from
Jul 25, 2024

Conversation

TomerHeber
Copy link
Collaborator

…ithout_template_settings

Issue & Steps to Reproduce / Feature Request

fixes #906

Solution

  1. Update shouldDeploy to test that use-cases.
  2. Some other small changes.
  3. Updated the acceptance tests.

@@ -732,6 +732,12 @@ func shouldUpdateTemplate(d *schema.ResourceData) bool {
}

func shouldDeploy(d *schema.ResourceData) bool {
if _, ok := d.GetOk("without_template_settings.0"); ok {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added the required use-case.

@@ -1126,8 +1132,7 @@ func getDeployPayload(d *schema.ResourceData, apiClient client.ApiClientInterfac
var err error

if isTemplateless(d) {
templateId, ok := d.GetOk("without_template_settings.0.id")
if ok {
if templateId, ok := d.GetOk("without_template_settings.0.id"); ok {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no change... just one less line.

Copy link
Contributor

Choose a reason for hiding this comment

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

this syntax is super strange ... do we use it a lot in this codebase / is it common in Go?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes.
This is common go.

@@ -1139,6 +1144,10 @@ func getDeployPayload(d *schema.ResourceData, apiClient client.ApiClientInterfac
}

if isRedeploy {
if revision, ok := d.GetOk("without_template_settings.0.revision"); ok {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

set the revision in the deploy request only if it's a redeploy.

@@ -2541,6 +2541,13 @@ func TestUnitEnvironmentWithoutTemplateResource(t *testing.T) {

// Update
mock.EXPECT().TemplateUpdate(template.Id, templateUpdatePayload).Times(1).Return(updatedTemplate, nil),
mock.EXPECT().ConfigurationSetsAssignments("ENVIRONMENT", environment.Id).Times(1).Return(nil, nil),
mock.EXPECT().EnvironmentDeploy(environment.Id, client.DeployRequest{
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Now deploy is called as part of the test.

Copy link
Contributor

@avnerenv0 avnerenv0 left a comment

Choose a reason for hiding this comment

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

Thank you

@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 Jul 25, 2024
@TomerHeber TomerHeber merged commit 9581439 into main Jul 25, 2024
13 checks passed
@TomerHeber TomerHeber deleted the fix-redeploy-without-template-#906 branch July 25, 2024 21:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix 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.

env0_environment does not redeploy when revision is changed in without_template_settings
2 participants