Skip to content

(how) can I use convert function? #2813

Description

@alxgomz

Not sure whether that's a problem with me or a bug but here is what I'm trying to do:

I wrote a function in my bake file to compute a list of targets based on an whether an env var (MY_ VERSION) matches a list of versions:

function "exclude_if_version" {
  params = [
    versions,
    inputlist,
    excludees
    ]
  result = sethaselement(convert(versions, list(string)),"${MY_VERSION}") ? setsubtract(inputlist, excludees) : inputlist
}

As you can see above, I'd like to deal with cases where someone using that function passes numbers (e.g. [3, 4]) or string representation of the version (["3.0", "4.0"]) in the versions list.
Though when running that simple code I get the error below:

Invalid expression; function "list" does not exist: undefined

I've tried with more simple types and get the same error (e.g. convert("true", bool))

I would have expected that to work given the bake Reference states:

A set of general-purpose functions provided by go-cty are available for use in HCL files

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions