Skip to content

Commit

Permalink
Support adding additional steps
Browse files Browse the repository at this point in the history
  • Loading branch information
zregvart committed Jun 12, 2024
1 parent 676f840 commit fbca710
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tash/golden/prefetch-dependencies/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@ add:
- use-source
- create-source
- create-cachi2
additionalSteps:
- at: 0
name: skip-ta
image: registry.access.redhat.com/ubi9/ubi-minimal:9.3-1612@sha256:119ac25920c8bb50c8b5fd75dcbca369bf7d1f702b82f3d39663307890f0bf26
env:
- name: INPUT
value: $(params.input)
- name: SOURCE_ARTIFACT
value: $(params.SOURCE_ARTIFACT)
script: |
if [ -z "${INPUT}" ]; then
mkdir -p /var/workdir/source
mkdir -p /var/workdir/cachi2
echo "true" > /var/workdir/source/.skip-trusted-artifacts
echo "true" > /var/workdir/cachi2/.skip-trusted-artifacts
echo -n "${SOURCE_ARTIFACT}" > $(results.SOURCE_ARTIFACT.path)
echo -n "" > $(results.CACHI2_ARTIFACT.path)
fi
description: |-
Task that uses Cachi2 to prefetch build dependencies. The fetched dependencies and the
application source code are stored as a trusted artifact in the provided OCI repository.
Expand Down
16 changes: 16 additions & 0 deletions tash/golden/prefetch-dependencies/ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@ spec:
- mountPath: /var/workdir
name: workdir
steps:
- name: skip-ta
image: registry.access.redhat.com/ubi9/ubi-minimal:9.3-1612@sha256:119ac25920c8bb50c8b5fd75dcbca369bf7d1f702b82f3d39663307890f0bf26
env:
- name: INPUT
value: $(params.input)
- name: SOURCE_ARTIFACT
value: $(params.SOURCE_ARTIFACT)
script: |
if [ -z "${INPUT}" ]; then
mkdir -p /var/workdir/source
mkdir -p /var/workdir/cachi2
echo "true" > /var/workdir/source/.skip-trusted-artifacts
echo "true" > /var/workdir/cachi2/.skip-trusted-artifacts
echo -n "${SOURCE_ARTIFACT}" > $(results.SOURCE_ARTIFACT.path)
echo -n "" > $(results.CACHI2_ARTIFACT.path)
fi
- image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d
name: use-trusted-artifact
args:
Expand Down
6 changes: 6 additions & 0 deletions tash/recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ import (
"sigs.k8s.io/yaml"
)

type AdditionalStep struct {
pipeline.Step
At int `json:"at"`
}

type Recipe struct {
Add []string `json:"add"`
AddEnvironment []core.EnvVar `json:"addEnvironment"`
AdditionalSteps []AdditionalStep `json:"additionalSteps"`
AddParams pipeline.ParamSpecs `json:"addParams"`
AddResult []pipeline.TaskResult `json:"addResult"`
AddVolume []core.Volume `json:"addVolume"`
Expand Down
4 changes: 4 additions & 0 deletions tash/ta.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,9 @@ func perform(task *pipeline.Task, recipe *Recipe) error {
task.Spec.Steps = append(task.Spec.Steps, create)
}

for _, additional := range recipe.AdditionalSteps {
task.Spec.Steps = slices.Insert(task.Spec.Steps, additional.At, additional.Step)
}

return nil
}

0 comments on commit fbca710

Please sign in to comment.