hashicorp / terraform-provider-ignition

Terraform Ignition provider
https://www.terraform.io/docs/providers/ignition/
Mozilla Public License 2.0
39 stars 64 forks source link

ignition_directory and ignition_file support only decimal value for mode #68

Open PawelZ-iHQ opened 4 years ago

PawelZ-iHQ commented 4 years ago

Ignition documentation for ignition_file and ignition_directory state that mode argument can be provided either octal or decimal:

mode - (Optional) The directory's permission mode. Note that the mode can be specified as either an octal value (e.g 0755) or a decimal value (i.e. 493 as equivalent to the octal 0755).

While provided values are evaluated as decimals only, even with leading 0. For example 0755 results with --wxrw--wx 0363 octal and 243 decimal. Quick look at the code suggests that mode is evaluated as TypeInt.

Please either extend code, so both octal and decimal are evaluated correctly or update documentation to state that only decimal values are accepted.

sean-abbott commented 4 years ago

I am having this problem as well.

obourdon commented 4 years ago

Seems like a regression to me as I remember getting this to work

obourdon commented 4 years ago

@sean-abbott @PawelZ-iHQ what version of terraform are you using ? (0.11, 0.12, 0.13) I think it is working well with 0.11 but have the same issue you are mentioning with 0.12

obourdon commented 4 years ago

to make sure my code works in all cases, I use expression like:

mode = format("%d", "0644")
obourdon commented 4 years ago

The following code works well with terraform 0.11:

variable "v1" {
  default = 0644
}
output "input-v1" {
  value = "${var.v1}"
}

which gives:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

input-v1 = 420

but with terraform 0.12:

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

input-v1 = 644
obourdon commented 4 years ago

In fact it does not work either with format for TF 0.12 anymore: https://github.com/hashicorp/terraform/issues/22143

sean-abbott commented 4 years ago

I'm using 0.12, and will probably look at migrating to 0.13 the next time I touch terraform.

egeturgay commented 4 years ago

I had a brief look at this and I don't think It'd be possible to use octal values given the constraints on HCL2 as I explained in https://github.com/community-terraform-providers/terraform-provider-ignition/issues/4#issuecomment-709312516