Skip to main content
contains(list, value) returns true if value is present in list, and false otherwise.

Signature

contains(list list, value any) bool

Example

Only run the container build task when the current operating system is one of the supported platforms:
computed "current_os" {
  expression = os()
}

task "build-image" {
  description = "Build the Docker image"
  condition   = contains(["linux", "darwin"], computed.current_os)
  commands    = ["docker build -t myapp:latest ."]
}
On Windows, where the Docker build task requires different setup, the task is skipped automatically.

Notes

  • The comparison is type-sensitive. A string "1" and a number 1 are not equal.
  • contains works on lists, tuples, and sets, not maps. To check map keys, use lookup with a sentinel value.