Skip to main content

Object

Object typed values are a container for string indexed values (referred to as properties).

Objects...

Initialization

Object typed values can be constructed from a literal or templated object.

A templated object is an object which includes one or more variable-reference [string]. At runtime, each reference gets evaluated and replaced with it's corresponding value.

Initialization Example (literal)

myObject:
prop1: value

Initialization Example (templated)

given:

  • someDir/file2.txt is embedded in op
  • prop2Name is in scope
  • someObject
    • is in scope
    • is type coercible to object
    • has property someProperty
  • prop4 is in scope
# interpolate properties
myObject:
prop1: string $(./someDir/file2.txt)
$(prop2Name): $(someObject.someProperty)
prop3: [ sub, array, 2]
# Shorthand property name; equivalent to prop4: $(prop4)
prop4:

Property Referencing

Object properties can be referenced via $(OBJECT.PROPERTY) or $(OBJECT[PROPERTY]) syntax.

Property Referencing Example (from scope)

given:

  • someObject
    • is in scope
    • is type coercible to object
    • contains property someProperty
$(someObject.someProperty)

Coercion

Object typed values are coercible to:

  • boolean (objects which are null or empty coerce to false; all else coerce to true)
  • file (will be serialized to JSON)
  • dir (will be treated as dir initializer)
  • string (will be serialized to JSON)

Coercion Example (object to string)

name: objAsString
inputs:
obj:
object:
default:
prop1: prop1Value
prop2: [ item1 ]
run:
container:
image: { ref: alpine }
cmd:
- echo
- $(obj)