Skip to content
New issue

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

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

Already on GitHub? # to your account

Adding labels/annotations to resources or data to config maps/secrets when those were empty fails #115

Closed
pdecat opened this issue Feb 12, 2018 · 4 comments
Labels

Comments

@pdecat
Copy link
Contributor

pdecat commented Feb 12, 2018

Adding labels to a resource that didn't have any fails with a jsonpatch add operation does not apply: doc is missing path error message.

Terraform Version

# Terraform v0.11.3
+ provider.kubernetes v1.0.1

Note: the exact same issue happens from master.

Affected Resource(s)

  • All resources with metadata

Terraform Configuration Files

  1. Resource without labels:
resource "kubernetes_namespace" "test" {
	metadata {
		annotations {
			TestAnnotationOne = "one"
			TestAnnotationTwo = "two"
		}
		name = "test"
	}
}
  1. Resource with labels:
resource "kubernetes_namespace" "test" {
	metadata {
		annotations {
			TestAnnotationOne = "one"
			TestAnnotationTwo = "two"
		}
		labels {
			TestLabelOne = "one"
			TestLabelTwo = "two"
			TestLabelThree = "three"
		}
		name = "test"
	}
}

Expected Behavior

Applying the first file then the second one should add the labels to the resource.

Actual Behavior

Applying the first file then the second one fails:

                * kubernetes_namespace.test: 1 error(s) occurred:

                * kubernetes_namespace.test: jsonpatch add operation does not apply: doc is missing path: /metadata/labels/TestLabelTwo

Steps to Reproduce

  1. terraform apply with first file
  2. terraform apply with second file
pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
@pdecat pdecat changed the title Adding labels to a resource that didn't have any fails Adding labels or annotations to a resource that didn't have any fails Feb 12, 2018
@pdecat
Copy link
Contributor Author

pdecat commented Feb 12, 2018

Also affects annotations which use the same diffStringMap() function.

pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
@pdecat
Copy link
Contributor Author

pdecat commented Feb 12, 2018

Also affects empty config maps with no data which use the same diffStringMap() function.

pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
… config map resource that didn't have any
pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
@pdecat
Copy link
Contributor Author

pdecat commented Feb 12, 2018

And finally, it also affects secrets with no data which use the same diffStringMap() function.

@pdecat pdecat changed the title Adding labels or annotations to a resource that didn't have any fails Adding labels/annotations to resources or data to config maps/secrets when those were empty fails Feb 12, 2018
pdecat added a commit to pdecat/terraform-provider-kubernetes that referenced this issue Feb 12, 2018
@radeksimko radeksimko added the bug label Feb 13, 2018
radeksimko pushed a commit that referenced this issue Mar 1, 2018
radeksimko pushed a commit that referenced this issue Mar 1, 2018
radeksimko pushed a commit that referenced this issue Mar 1, 2018
radeksimko pushed a commit that referenced this issue Mar 1, 2018
@radeksimko
Copy link
Member

Fixed via #116

Thanks for reporting this bug and sending the patch @pdecat ! 👍

@ghost ghost locked and limited conversation to collaborators Apr 21, 2020
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants