Skip to content

Conversation

@nakamasato
Copy link
Contributor

@nakamasato nakamasato commented Jul 23, 2025

What

Add Plan: 0 to add, 0 to change, 0 to destroy. to the regex condition for no changes.

Why

Close #358

I think this is not a perfect solution but would still be better than the current behavior adding add-or-update label for the pr that DOESN'T have any addition or update.

If the label were has-diff, it'd be ok to align with the result of terraform plan -detailed-exitcode but the label add-or-update is different interpretation than the exit code.

  -detailed-exitcode         Return detailed exit codes when the command exits.
                             This will change the meaning of exit codes to:
                             0 - Succeeded, diff is empty (no changes)
                             1 - Errored
                             2 - Succeeded, there is a diff

Check List

@nakamasato nakamasato marked this pull request as ready for review July 23, 2025 02:13
@suzuki-shunsuke
Copy link
Owner

Thank you for your contribution!
Hmm. It's hard to make a decision.

For instance, the following output includes Plan: 0 to add, 0 to change, 0 to destroy. but outputs are changed.

$ terraform plan -detailed-exitcode
null_resource.foo: Refreshing state... [id=2480052438659796792]

Terraform will perform the following actions:

  # null_resource.example has moved to null_resource.foo
    resource "null_resource" "foo" {
        id = "2480052438659796792"
    }

Plan: 0 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  ~ foo = "foo" -> "bar"

You can apply this plan to save these new output values to the Terraform state, without changing any real infrastructure.

──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform
apply" now.

So no-changes is incorrect.
But add-or-update is also incorrect.
has-diff is more appropriate than these labels, but I don't think it's good to add a new label.

no-changes may be better than add-or-update.

@nakamasato
Copy link
Contributor Author

Thank you for your quick reply and consideration.

For instance, the following output includes Plan: 0 to add, 0 to change, 0 to destroy. but outputs are changed.

That's true.

Maybe there are two options:

Option1: use no-changes for Plan: 0 to add, 0 to change, 0 to destroy (this pr)

If we consider no-changes label as no changes in infrastructure, it can be considered correct.

Option2: add a new WhenNoChangesInInfra option with Plan: 0 to add, 0 to change, 0 to destroy. condition

I also consider a new option to consider zero changes in infra (Plan: 0 to add, 0 to change, 0 to destroy) to attach the no-changes label. You also mentioned an option #358 (comment)?

If I implement an option, I'd add a new regex HasNoChangesInInfra for Plan: 0 to add, 0 to change, 0 to destroy. and then we can add config WhenNoChangesInInfra with the default label name and color. If we want to keep the backward compatibility, we can set add-or-update for the default value.

@nakamasato
Copy link
Contributor Author

@suzuki-shunsuke Could you check my comment above when you have time? Thank you!

@suzuki-shunsuke
Copy link
Owner

Sorry for late reply.
I think the option 2 is better.
The default value should be no-changes. This isn't compatible, but I think this change is acceptable.
I think no-changes is better for many users.

@nakamasato
Copy link
Contributor Author

@suzuki-shunsuke Thank you for your feedback. I've made a pr for option2 #1896. Please check it when you have time.

@suzuki-shunsuke
Copy link
Owner

@suzuki-shunsuke suzuki-shunsuke merged commit f698819 into suzuki-shunsuke:main Aug 16, 2025
13 checks passed
@suzuki-shunsuke suzuki-shunsuke added this to the v4.15.0 milestone Aug 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tfcmt plan result isn't intuitive when moved block is used

2 participants