Carvel Logo

If Statements

Refer to Starlark if statement specification for details.

  • if
#@ if True:
test1: 123
test2: 124
#@ end
  • if (negative)
#@ if not True:
test1: 123
#@ end
  • single-node if
#@ if/end True:
test1: 123
  • if-else conditional
#@ if True:
test1: 123
#@ else:
test2: 124
#@ end
  • if-elif-else conditional
#@ if True:
test2: 123
#@ elif False:
test2: 124
#@ else:
test2: 125
#@ end
  • single line if
#@ passwd = "..."
test1: #@ passwd if passwd else assert.fail("password must be set")
  • implicit if
#@ passwd = "..."
test1: #@ passwd or assert.fail("password must be set")