diff --git a/docs/architecture.rst b/docs/architecture.rst index ae772c9fec..5a785a6521 100644 --- a/docs/architecture.rst +++ b/docs/architecture.rst @@ -71,6 +71,7 @@ The definition of a ``BlueprintAction`` is: InputArtifactNames []string `json:"inputArtifactNames"` OutputArtifacts map[string]Artifact `json:"outputArtifacts"` Phases []BlueprintPhase `json:"phases"` + DeferPhase *BlueprintPhase `json:"deferPhase,omitempty"` } - ``Kind`` represents the type of Kubernetes object this BlueprintAction is written for. @@ -84,6 +85,10 @@ The definition of a ``BlueprintAction`` is: to the ``BlueprintAction``. - ``Phases`` is a required list of ``BlueprintPhases``. These phases are invoked in order when executing this Action. +- ``DeferPhase`` is an optional ``BlueprintPhase`` invoked after the + execution of ``Phases`` defined above. A ``DeferPhase``, when specified, + is executed regardless of the statuses of the ``Phases``. + A ``DeferPhase`` can be used for cleanup operations at the end of an ``Action``. .. code-block:: go :linenos: diff --git a/docs/templates.rst b/docs/templates.rst index 84227b0523..68352868ca 100644 --- a/docs/templates.rst +++ b/docs/templates.rst @@ -25,6 +25,7 @@ The TemplateParam struct is defined as: Options map[string]string Object map[string]interface{} Phases map[string]*Phase + DeferPhase *Phase PodOverride crv1alpha1.JSONMap } @@ -609,3 +610,28 @@ Similarly, a phase can use Secrets as arguments: .. code-block:: go "{{ .Phases.phase-name.Secrets.secret-name.Namespace }}" + +DeferPhase +---------- + +``DeferPhase`` is used to capture information returned from the Blueprint's ``DeferPhase`` +execution. The information is stored in the ``Phase`` struct that has the below +definition: + +.. code-block:: go + :linenos: + + type Phase struct { + Secrets map[string]v1.Secret + Output map[string]interface{} + } + +Output artifact can be set as follows: + +.. code-block:: go + + "{{ .DeferPhase.Output.key-name }}" + + +Output artifacts that are set using ``DeferPhase`` can be consumed by other actions' +phases using the same way other output artifacts are consumed. diff --git a/docs/tutorial.rst b/docs/tutorial.rst index c3b459dae8..2aebf31561 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -443,6 +443,60 @@ ConfigMap. If you re-execute this Kanister Action, you'll be able to see the Artifact in the ActionSet status. +If you use a ``DeferPhase``, below is how you can set the output artifact +from the output that is being generated from ``DeferPhase`` as shown below. + +.. code-block:: yaml + + cat <