Open armsnyder opened 3 years ago
Hi @armsnyder , as shown in the docs, values should be passed in yaml format json format is not supported, https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/app_v2#values
@rawmind0 I think there's a bug in the ValidateFunc then, since this error condition isn't being hit: https://github.com/rancher/terraform-provider-rancher2/blob/fa0c09dbee71145c60707aa2c98c9b42667c15aa/rancher2/schema_app_v2.go#L89-L93
Using jsonencode
works fine for us, and it creates the correct YAML in the upstream Rancher app.
@armsnyder , it seems the ghodssyaml.Unmarshal()
function is also accepting json format, but the provider is not supporting it, as expressed at the docs. We'll work on checking ghodssyaml
functions issues, but yaml format is required at values
field.
@rawmind0 Hi! I wanted to update you that we are still seeing unexpected diffs, this time using yamlencode
as you suggested, even though we have not changed any values.
Using provider version 1.10.6
Gist: https://gist.github.com/armsnyder/f49c5bab1841076c43fb4d70db772ce1
It looks like maybe the provider is doing a string comparison instead of comparing the yaml structures, so it is seeing quoted keys from yamlencode
, which are stripped when stored in Rancher upstream.
Hi @armsnyder , the values
argument comparison is not done as string, it's done at low level using map[string]interface{}
and reflect.DeepEqual
, https://github.com/rancher/terraform-provider-rancher2/blob/master/rancher2/schema_app_v2.go#L129
The gist link that you've attached, is showing some real diffs on some values fields, so values
diff is not suppressed, Ex:
...
- core:
- resources:
- requests:
- cpu: 60m
- memory: 1Gi
...
+ "core":
+ "replicas": 1
+ "resources":
+ "requests":
+ "cpu": "60m"
+ "memory": "1Gi"
...
Hello!
I'm using the
rancher2_app_v2
resource and specifying thevalues
argument using JSON. Each subsequent plan is showing a diff, because the actual values are stored as YAML in the upstream Rancher API, even though both YAML and JSON are supported in the resource. I suggest suppressing the Terraform diff here. I didn't check, but there may also be a similar issue if the YAML keys are represented in a different order upstream.Config: