syntasso / kratix-cli

CLI-based tool to build Promises
Apache License 2.0
2 stars 2 forks source link

kratix add pipeline images #7

Closed ChunyiLyu closed 4 months ago

ChunyiLyu commented 5 months ago

Context

Implement a command that can add a container image to promise directory. The command should bootstrap the necessary files so the user can focus on writing their container logic.

Ensure that:

  1. The pipeline.sh file can be used as an example and has comments explaining what it is doing. For example, it could read the metadata.name and metadata.namespace and echo Hello from ${name} ${namespace}.
  2. the promise.yaml file is updated with the new workflow
  3. If the project was bootstrapped with --split, there's a new workflow.yaml in the workflow-name directory and that is used at promise build time to generate the correct promise.

Design

Reference:

$> kratix add container --help
Adds a container to the named workflow, and generates a template for the container image.

Examples:
  # add a new resource configure container 
  kratix add container resource/configure/instance --image syntasso/postgres-resource:v1.0.0

  # add a new promise configure container, with a specific name
  kratix add container promise/configure/pipeline0 --image syntasso/postgres-resource:v1.0.0 --name deploy-deps

Options:
  --image string               The container image to use (required)
  --name string                The name of the container (defaults to the image name)

Usage:
  kratix add container LIFECYCLE/TRIGGER/NAME [flags]
  where
    LIFECYCLE is one of: promise, resource
    TRIGGER is one of: configure, resource
    NAME is the pipeline name to add the container to
$> kratix add container resource/configure/instance --tag syntasso/postgres-resource:v1.0.0 --name deploy-pg
generated the workflows/resource/configure/instance

* Customize your container by editing the workflows/resource/configure/instance/deploy-pg/scripts/pipeline.sh

Don't forget to build and push your image!

Outputs

postgresql/
...
  workflows/
    resource/
      configure/
        workflow-name/
          containers/
            instance-configure/
              Dockerfile
              resources/
              scripts/
                pipeline.sh

Tasks

ChunyiLyu commented 4 months ago

One possible enhancement we can add to this would be guarding people from adding multiple pipelines to promise delete and resource delete workflows. Kratix currently only supports multiple pipelines for the configure workflows. There is no check for this in the CLI and we are allowing people using the CLI to define invalid configurations.