Skip to content
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

Documentation for variable types talks about "keyword any", but any is not a valid type. #12805

Open
johnson-earls opened this issue Jan 27, 2024 · 0 comments
Labels

Comments

@johnson-earls
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Overview of the Issue

I need to accept a variable that can contain any object, not an object with specific fields. By reading the following documentation in https://developer.hashicorp.com/packer/docs/templates/hcl_templates/variables#type-constraints

The keyword any may be used to indicate that any type is acceptable.

I expected that I could use either type = any or type = object(any). Neither is accepted by the parser.

If any is not a valid keyword, then it should not be in the documentation as a valid keyword.

Reproduction Steps

variable "foo" {
    type = any
    default = {}
}

or

variable "foo" {
    type = object(any)
    default = {}
}

Packer version

1.9.4

Simplified Packer Template

template 1:

variable "foo" {
  type = any
  default = {}
}

template 2:

variable "foo" {
  type = object(any)
  default = {}
}

Operating system and Environment details

$ uname -a
Linux turbinevm-builder 4.18.0-448.el8.x86_64 #1 SMP Wed Jan 18 15:02:46 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
$ cat /etc/os-release
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"

Log Fragments and crash.log files

for template 1:

$ packer init t.pkr.hcl
Error: Invalid type specification

  on t.pkr.hcl line 2, in variable "foo":
   2:   type = any

The keyword "any" cannot be used in this type specification: an exact type is
required.

for template 2:

$ packer init t2.pkr.hcl
Error: Invalid type specification

  on t2.pkr.hcl line 2, in variable "foo":
   2:   type = object(any)

Object type constructor requires a map whose keys are attribute names and whose
values are the corresponding attribute types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant