-
Notifications
You must be signed in to change notification settings - Fork 772
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
Issue labels aren't checked against Github API #245
Comments
Hi @clebio ! Thank you for submitting this issue. When using As for Terraform not checking for existing labels, in order for Terraform to maintain the GitHub labels, the configurations needs to be set up in your main.tf file. You’ll see that in your example provided, you have 6 configured labels, so Terraform will only maintain those 6. If you add the configuration for the other 4 and either import or apply (as an apply on labels will check if the label exists, and then either update, or create as appropriate), then Terraform will be able to maintain them as well. I was unable to see any labels being removed from issues, so it’s possible I’m misunderstanding part of what is happening. I believe GitHub associates labels by id (which is repo-name/label-name), so as long as there is still an existing label with the same name, it should not disassociate the label from the issue. Let me know if you have further questions or if I can help with anything else! |
Ok. I removed all but three labels, just to make imports simpler for now. Then imported them.
Importing:
Clean plan after that:
Then I added another label at the end of the variable:
And applied:
However, when I remove the first label from the Terraform list variable, things break down:
Unfortunately, now
|
Hi @clebio ! One way to avoid this issue is to have one declared resource per label, rather than trying to create it from a list. For example:
The way that Let me know if you have further questions or if I can help with anything else! |
Hmm. Don't use |
Hi @clebio ! I understand the frustration that the code can feel somewhat repetitive, and that it would be a good use case for I’ll close this for now with the thought that further issues and questions will be tracked in one of the places above, or if you run across another issue, a new issue will be opened. Thanks again! |
I'm running into issues using Terraform to manage existing labels. The addition of labels to an existing set fails, and unfortunately removes labels assigned to issues, since Terraform re-orders its indexed list of labels, apparently unaware of Github's own ordering of labels. Terraform doesn't even seem to be checking Github for the existence of labels at all. This makes issue label management via Terraform impossible.
I created a new public Github repo, which by default has nine labels, and set up Terraform to add issue labels.
https://github.com/clebio/example/labels
Further, even if I manually import the existing labels,
Adding one more in alphabetical order (as Github seems to use), causes existing labels to get reordered, and removes the existing labels from issues they were assigned to.
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Output
Labels as they actually exist:
Terraform plan:
Expected Behavior
plan
should see that labels already exist, and not try to add duplicates.apply
should account for existing labels and do ... something sensible (replace, import, fail?).Actual Behavior
Terraform
apply
fails in various related ways.Terraform thinks there are six issues:
and yet, Github says 10:
Steps to Reproduce
terraform apply
blocked
in the example variable:terraform plan
terraform apply -auto-approve
Then,
terraform apply -auto-approve
again:References
The text was updated successfully, but these errors were encountered: