Sub-Commands

A command is typically made up of a noun and a verb. The noun is the object of the command and the verb is what is done to that object.

The following are examples of noun-verb commands:

  • engine start
  • users export
  • feature enable

By convention, multiple verbs can follow a given noun:

  • engine start
  • engine stop

Commands allow you to create a list of sub-commands. Any command with sub-commands cannot be executed by itself, but it can define common attributes such as flags or resource selectors. The following example shows an engine command with two sub-commands: start and stop. Each sub-command has its own execution definition, but the flags and the resource selector are defined by the parent:

command:
  name: engine
  description: Engine related commands
  flags:
    - name: engine
      shortName: e
      type: int
      mandatory: false
      defaultValue: 1
      description: The Engine id
    - name: subdomain
      shortName: s
      type: int
      mandatory: false
      defaultValue: 1
      description: The Subscriber Domain id
resourceSelector:
  kind: pods
  labels:
    engineId: ${command.flag.engine}
    subDomainId: ${command.flag.subdomain}
subCommands:
  - command:
      name: start
      description: Start the Engine
    executor:
      executeOnPod:
        command:
          - "bin/bash"
          - "-c"
          - "startEngine.py"
  - command:
      name: stop
      description: Stop the Engine
    executor:
      executeOnPod:
        command:
          - "bin/bash"
          - "-c"
          - "stopEngine.py"
Note: The example is for demonstrative purposes only and is not a working implementation of engine management.

Sub-commands can also have sub-commands of their own, up to four levels. The following example shows a checkpoint sub-command that itself has two sub-commands:

command:
  name: engine
  description: Engine related commands
  flags:
    - name: engine
      shortName: e
      type: int
      mandatory: false
      defaultValue: 1
      description: The Engine id
    - name: subdomain
      shortName: s
      type: int
      mandatory: false
      defaultValue: 1
      description: The Subscriber Domain id
resourceSelector:
  kind: pods
  labels:
    engineId: ${command.flag.engine}
    subDomainId: ${command.flag.subdomain}
subCommands:
  - command:
      name: start
      description: Start the Engine
    executor:
      executeOnPod:
        command:
          - "bin/bash"
          - "-c"
          - "startEngine.py"
  - command:
      name: stop
      description: Stop the Engine
    executor:
      executeOnPod:
        command:
          - "bin/bash"
          - "-c"
          - "stopEngine.py"
  - command:
      name: checkpoint
      description: Engine Checkpoint Commands
    subCommands:
      - command:
          name: restore
          description: Restore an Engine Checkpoint
        executor:
          executeOnPod:
            command:
              - "bin/bash"
              - "-c"
              - "restoreCheckpoint.py"