Skip to main content
parseint(str, base) converts the string representation of an integer to a number. base specifies the numeric base: 10 for decimal, 16 for hexadecimal, 2 for binary, and so on. The base must be between 2 and 62 inclusive.

Signature

parseint(number string, base number) number

Example

Read a replica count from an environment variable and use it in a deployment command:
computed "replicas" {
  description = "Number of replicas from CI environment"
  expression  = parseint(env("REPLICA_COUNT", "2"), 10)
}

task "scale" {
  description = "Scale the deployment to the configured replica count"
  commands    = ["kubectl scale deployment/api --replicas=${computed.replicas}"]
}
env returns a string. parseint converts it to a number so it can be used in numeric contexts or validated with min and max.

Notes

  • base must be a whole number between 2 and 62 inclusive.
  • If the string is not a valid integer in the given base, Errand reports an error at evaluation time.
  • The result is always an integer. Decimals are not parsed by parseint.