Skip to content

Commit

Permalink
Merge branch 'main' into switch-buildah-source
Browse files Browse the repository at this point in the history
  • Loading branch information
arewm authored Jul 10, 2024
2 parents 5e93921 + 95cf488 commit d5c716b
Show file tree
Hide file tree
Showing 21 changed files with 187 additions and 81 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/check-buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
name: Check Buildah Remote
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5
uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5
with:
go-version-file: './task-generator/go.mod'
- name: Check buildah remote
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/go-ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ jobs:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: './task-generator/go.mod'
- name: golangci-lint
Expand All @@ -20,9 +20,9 @@ jobs:
name: Check sources
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Install Go
uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: './task-generator/go.mod'
- name: Check go mod status
Expand Down Expand Up @@ -51,8 +51,8 @@ jobs:
name: Security scan
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: './task-generator/go.mod'
# https://github.com/securego/gosec/blob/12be14859bc7d4b956b71bef0b443694aa519d8a/README.md#integrating-with-code-scanning
Expand All @@ -62,7 +62,7 @@ jobs:
# we let the report trigger content trigger a failure using the GitHub Security features.
args: '-tags normal,periodic -no-fail -fmt sarif -out results.sarif ./...'
- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@1b1aada464948af03b950897e5eb522f92603cc2
uses: github/codeql-action/upload-sarif@6e04d518baf348f53b5454ff7a14ddd0bfec6653
with:
# Path to SARIF file relative to the root of the repository
sarif_file: results.sarif
7 changes: 6 additions & 1 deletion .tekton/push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ spec:
DATA_BUNDLE_TAG=$(date '+%s')
export DATA_BUNDLE_REPO DATA_BUNDLE_TAG
.tekton/scripts/build-acceptable-bundles.sh "$@"
list=()
for f in "$@"; do
[[ -f "$f" ]] && list+=("$f")
done
.tekton/scripts/build-acceptable-bundles.sh "${list[@]}"
echo -n "${DATA_BUNDLE_TAG}" > acceptable_bundle_tag
args:
Expand Down
4 changes: 2 additions & 2 deletions .tekton/tasks/ec-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
$(all_tasks_dir all_tasks-ec)
- name: validate-all-tasks
workingDir: "$(workspaces.source.path)/source"
image: quay.io/enterprise-contract/ec-cli:snapshot@sha256:868c24978b21099988c09a7e35136db5219755e13a62c65247642ce13be6ec6b
image: quay.io/enterprise-contract/ec-cli:snapshot@sha256:6845f91bb0eeb045769f0e25b1beb85594cea1dd6a4f506f90acb5a0ee2bd5aa
script: |
set -euo pipefail
Expand All @@ -37,7 +37,7 @@ spec:
ec validate input --policy "${policy}" --output yaml --strict=true ${args[*]}
- name: validate-build-tasks
workingDir: "$(workspaces.source.path)/source"
image: quay.io/enterprise-contract/ec-cli:snapshot@sha256:868c24978b21099988c09a7e35136db5219755e13a62c65247642ce13be6ec6b
image: quay.io/enterprise-contract/ec-cli:snapshot@sha256:6845f91bb0eeb045769f0e25b1beb85594cea1dd6a4f506f90acb5a0ee2bd5aa
script: |
set -euo pipefail
Expand Down
2 changes: 1 addition & 1 deletion pipelines/enterprise-contract.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ spec:
resolver: bundles
params:
- name: bundle
value: quay.io/enterprise-contract/ec-task-bundle:snapshot@sha256:41a5947107beba8cab3c3af1e4d9b9556c93b955d1f5c7224fc8ae68b050f1a2
value: quay.io/enterprise-contract/ec-task-bundle:snapshot@sha256:63a95401b1d5cdf6d3843dad92eef72da21f483527e3f746b33ba8d8f8d71b12
- name: name
value: verify-enterprise-contract
- name: kind
Expand Down
1 change: 1 addition & 0 deletions policies/all-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ sources:
- git-basic-auth
- basic-auth
- ssh-directory
- netrc
config:
include:
- kind
Expand Down
7 changes: 3 additions & 4 deletions task/build-image-manifest/0.1/build-image-manifest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ spec:
value: $(params.IMAGE)
- name: TLSVERIFY
value: $(params.TLSVERIFY)
- name: COMMIT_SHA
value: $(params.COMMIT_SHA)
steps:
- image: quay.io/konflux-ci/buildah:latest@sha256:9ef792d74bcc1d330de6be58b61f2cdbfa1c23b74a291eb2136ffd452d373050
# per https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting
Expand All @@ -56,9 +58,6 @@ spec:
requests:
memory: 512Mi
cpu: 250m
env:
- name: COMMIT_SHA
value: $(params.COMMIT_SHA)
args: ["$(params.IMAGES[*])"]
script: |
#!/bin/bash
Expand All @@ -79,7 +78,7 @@ spec:
TOADD="$(echo $i | cut -d: -f1)@sha256:$(echo $i | cut -d: -f3)"
fi
echo "Adding $TOADD"
buildah manifest add $IMAGE "docker://$TOADD"
buildah manifest add $IMAGE "docker://$TOADD" --all
done
status=-1
Expand Down
2 changes: 1 addition & 1 deletion task/buildah-oci-ta/0.1/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ spec:
name: workdir
steps:
- name: use-trusted-artifact
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:bf4bfae950fe31d08f44488bb788bea8800cd6d75f5e09fcc21cf98689c61185
args:
- use
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
Expand Down
2 changes: 1 addition & 1 deletion task/buildah-remote-oci-ta/0.1/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ spec:
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
- $(params.CACHI2_ARTIFACT)=/var/workdir/cachi2
computeResources: {}
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:bf4bfae950fe31d08f44488bb788bea8800cd6d75f5e09fcc21cf98689c61185
name: use-trusted-artifact
- args:
- $(params.BUILD_ARGS[*])
Expand Down
2 changes: 1 addition & 1 deletion task/clamav-scan/0.1/clamav-scan.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ spec:
- mountPath: /work
name: work
- name: upload
image: quay.io/konflux-ci/oras:latest@sha256:04cbd5efbcf1a38944b050e3adbc3071218643f6aa92e95d5d25b173574bca5e
image: quay.io/konflux-ci/oras:latest@sha256:1619b84cea3777387f643d7a1ecde98dd10904439f31607e66530cd2299c7b91
env:
- name: IMAGE_URL
value: $(params.image-url)
Expand Down
6 changes: 3 additions & 3 deletions task/git-clone-oci-ta/0.1/git-clone-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ spec:
optional: true
steps:
- name: clone
image: quay.io/konflux-ci/git-clone@sha256:005487d3967e7a90490f96b2ff3b0c6d0463b647d212cd809683b494e20146a8
image: quay.io/konflux-ci/git-clone@sha256:2cde938c6f4902c35dbfe1809a96b468b6b47d273269a0ca3cad323481f45874
volumeMounts:
- mountPath: /mnt/trusted-ca
name: trusted-ca
Expand Down Expand Up @@ -247,7 +247,7 @@ spec:
securityContext:
runAsUser: 0
- name: symlink-check
image: quay.io/konflux-ci/git-clone@sha256:005487d3967e7a90490f96b2ff3b0c6d0463b647d212cd809683b494e20146a8
image: quay.io/konflux-ci/git-clone@sha256:2cde938c6f4902c35dbfe1809a96b468b6b47d273269a0ca3cad323481f45874
volumeMounts:
- mountPath: /var/workdir
name: workdir
Expand Down Expand Up @@ -279,7 +279,7 @@ spec:
check_symlinks
fi
- name: create-trusted-artifact
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:bf4bfae950fe31d08f44488bb788bea8800cd6d75f5e09fcc21cf98689c61185
args:
- create
- --store
Expand Down
4 changes: 2 additions & 2 deletions task/git-clone/0.1/git-clone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ spec:
value: $(workspaces.basic-auth.bound)
- name: WORKSPACE_BASIC_AUTH_DIRECTORY_PATH
value: $(workspaces.basic-auth.path)
image: quay.io/konflux-ci/git-clone@sha256:005487d3967e7a90490f96b2ff3b0c6d0463b647d212cd809683b494e20146a8
image: quay.io/konflux-ci/git-clone@sha256:2cde938c6f4902c35dbfe1809a96b468b6b47d273269a0ca3cad323481f45874
computeResources: {}
securityContext:
runAsUser: 0
Expand Down Expand Up @@ -245,7 +245,7 @@ spec:
fi
- name: symlink-check
image: quay.io/konflux-ci/git-clone@sha256:005487d3967e7a90490f96b2ff3b0c6d0463b647d212cd809683b494e20146a8
image: quay.io/konflux-ci/git-clone@sha256:2cde938c6f4902c35dbfe1809a96b468b6b47d273269a0ca3cad323481f45874
# per https://kubernetes.io/docs/concepts/containers/images/#imagepullpolicy-defaulting
# the cluster will set imagePullPolicy to IfNotPresent
env:
Expand Down
3 changes: 2 additions & 1 deletion task/oci-copy-oci-ta/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Given a file in the user's source directory, copy content from arbitrary urls in
## Parameters
|name|description|default value|required|
|---|---|---|---|
|BEARER_TOKEN_SECRET_NAME|Name of a secret which will be made available to the build as an Authorization header. Note, the token will be sent to all servers found in the oci-copy.yaml file. If you do not wish to send the token to all servers, different taskruns and therefore different oci artifacts must be used.|""|false|
|BEARER_TOKEN_SECRET_NAME|Name of a secret which will be made available to the build as an Authorization header. Note, the token will be sent to all servers found in the oci-copy.yaml file. If you do not wish to send the token to all servers, different taskruns and therefore different oci artifacts must be used.|does-not-exist|false|
|IMAGE|Reference of the image we will push||true|
|OCI_COPY_FILE|Path to the oci copy file.|./oci-copy.yaml|false|
|SOURCE_ARTIFACT|The Trusted Artifact URI pointing to the artifact with the application source code.||true|
Expand All @@ -15,4 +15,5 @@ Given a file in the user's source directory, copy content from arbitrary urls in
|---|---|
|IMAGE_DIGEST|Digest of the artifact just pushed|
|IMAGE_URL|Repository where the artifact was pushed|
|SBOM_BLOB_URL|Link to the SBOM blob pushed to the registry.|

94 changes: 72 additions & 22 deletions task/oci-copy-oci-ta/0.1/oci-copy-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ spec:
to all servers, different taskruns and therefore different oci artifacts
must be used.
type: string
default: ""
default: does-not-exist
- name: IMAGE
description: Reference of the image we will push
type: string
Expand All @@ -37,6 +37,8 @@ spec:
description: Digest of the artifact just pushed
- name: IMAGE_URL
description: Repository where the artifact was pushed
- name: SBOM_BLOB_URL
description: Link to the SBOM blob pushed to the registry.
volumes:
- name: varlibcontainers
emptyDir: {}
Expand All @@ -57,7 +59,7 @@ spec:
name: workdir
steps:
- name: use-trusted-artifact
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:4e39fb97f4444c2946944482df47b39c5bbc195c54c6560b0647635f553ab23d
image: quay.io/redhat-appstudio/build-trusted-artifacts:latest@sha256:bf4bfae950fe31d08f44488bb788bea8800cd6d75f5e09fcc21cf98689c61185
args:
- use
- $(params.SOURCE_ARTIFACT)=/var/workdir/source
Expand Down Expand Up @@ -88,7 +90,7 @@ spec:
cat /var/workdir/vars/$filename
done
- name: oci-copy
image: quay.io/konflux-ci/oras:latest@sha256:04cbd5efbcf1a38944b050e3adbc3071218643f6aa92e95d5d25b173574bca5e
image: quay.io/konflux-ci/oras:latest@sha256:1619b84cea3777387f643d7a1ecde98dd10904439f31607e66530cd2299c7b91
workingDir: /var/workdir
volumeMounts:
- mountPath: /var/lib/containers
Expand All @@ -114,36 +116,75 @@ spec:
set -u
echo "Selecting auth for $IMAGE"
select-oci-auth $IMAGE >auth.json
echo "Extracting artifact_type"
ARTIFACT_TYPE=$(cat "$(pwd)/source/$OCI_COPY_FILE" | yq '.artifact_type')
REPO=${IMAGE%:*}
echo "Found that ${REPO} is the repository for ${IMAGE}"
cat >artifact-manifest.json <<EOL
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"artifactType": "${ARTIFACT_TYPE}",
"config": {
"mediaType": "application/vnd.oci.empty.v1+json",
"digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
"size": 2,
"data": "e30="
},
"layers": [],
"annotations": {
"org.opencontainers.image.created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"
}
}
EOL
for varfile in /var/workdir/vars/*; do
echo "Reading $varfile"
source $varfile
echo "Downloading $OCI_SOURCE to $OCI_FILENAME"
curl "${CURL_ARGS[@]}" --fail --silent --show-error --location $OCI_SOURCE -o $OCI_FILENAME
echo "Checking to see if blob $OCI_ARTIFACT_DIGEST exists"
if [[ $(oras blob fetch --registry-config auth.json --descriptor "${REPO}@sha256:${OCI_ARTIFACT_DIGEST}") ]]; then
echo "Blob for ${OCI_FILENAME} already exists in the registry at ${REPO}@sha256:${OCI_ARTIFACT_DIGEST}. Skipping download."
else
echo "Blob for ${OCI_FILENAME} does not yet exist in the registry at ${REPO}@sha256:${OCI_ARTIFACT_DIGEST}."
echo "Downloading $OCI_SOURCE to $OCI_FILENAME"
curl "${CURL_ARGS[@]}" --fail --silent --show-error --location $OCI_SOURCE -o $OCI_FILENAME
echo "Confirming that digest of $OCI_FILENAME matches expected $OCI_ARTIFACT_DIGEST"
echo "$OCI_ARTIFACT_DIGEST $OCI_FILENAME" | sha256sum --check
echo "Confirming that digest of $OCI_FILENAME matches expected $OCI_ARTIFACT_DIGEST"
echo "$OCI_ARTIFACT_DIGEST $OCI_FILENAME" | sha256sum --check
echo "Appending to arguments for $OCI_FILENAME of type $OCI_ARTIFACT_TYPE"
args+=("${OCI_FILENAME}:${OCI_ARTIFACT_TYPE}")
done
echo "Pushing blob of $OCI_FILENAME of type $OCI_ARTIFACT_TYPE"
oras blob push --registry-config auth.json ${REPO} --media-type ${OCI_ARTIFACT_TYPE} ${OCI_FILENAME}
if [ -z "${args}" ]; then
echo "No files found. Something is very wrong. Skipping upload."
exit 1
fi
echo "Removing local copy of $OCI_FILENAME to save space."
rm ${OCI_FILENAME}
fi
echo "Extracting artifact_type"
ARTIFACT_TYPE=$(cat "$(pwd)/source/$OCI_COPY_FILE" | yq '.artifact_type')
echo "Grabbing descriptor of blob from the registry"
oras blob fetch --registry-config auth.json --descriptor "${REPO}@sha256:${OCI_ARTIFACT_DIGEST}" >descriptor.json
echo "Selecting auth for $IMAGE"
select-oci-auth $IMAGE >auth.json
echo "Setting mediaType to ${OCI_ARTIFACT_TYPE}"
yq -oj -i '.mediaType = "'${OCI_ARTIFACT_TYPE}'"' descriptor.json
echo "Inserting org.opencontainers.image.title = ${OCI_FILENAME} annotation"
yq -oj -i '.annotations."org.opencontainers.image.title" = "'${OCI_FILENAME}'"' descriptor.json
echo "Pushing contents to ${IMAGE}"
oras push --no-tty --registry-config auth.json --artifact-type ${ARTIFACT_TYPE} "${IMAGE}" "${args[@]}"
echo "Appending blob descriptor for ${OCI_FILENAME} to the overall artifact manifest for ${IMAGE}"
yq -oj -i ".layers += $(cat descriptor.json)" artifact-manifest.json
IMAGE_INDEX_DIGEST=$(oras resolve --registry-config auth.json "${IMAGE}")
echo -n "$IMAGE_INDEX_DIGEST" | tee "$(results.IMAGE_DIGEST.path)"
echo "Done with ${OCI_FILENAME}."
done
echo "Pushing complete artifact manifest to ${IMAGE}"
oras manifest push --no-tty --registry-config auth.json "${IMAGE}" artifact-manifest.json
RESULTING_DIGEST=$(oras resolve --registry-config auth.json "${IMAGE}")
echo -n "$RESULTING_DIGEST" | tee "$(results.IMAGE_DIGEST.path)"
echo -n "$IMAGE" | tee "$(results.IMAGE_URL.path)"
computeResources:
limits:
Expand Down Expand Up @@ -191,3 +232,12 @@ spec:
- cyclonedx
- $(params.IMAGE)
workingDir: /var/workdir
- name: report-sbom-url
image: quay.io/konflux-ci/yq:latest@sha256:974dea6375ee9df561ffd3baf994db2b61777a71f3bcf0050c5dca91ac9b3430
workingDir: /var/workdir
script: |
REPO=${IMAGE%:*}
echo "Found that ${REPO} is the repository for ${IMAGE}"
SBOM_DIGEST=$(sha256sum sbom-cyclonedx.json | awk '{ print $1 }')
echo "Found that ${SBOM_DIGEST} is the SBOM digest"
echo -n "${REPO}@sha256:${SBOM_DIGEST}" | tee $(results.SBOM_BLOB_URL.path)
3 changes: 2 additions & 1 deletion task/oci-copy/0.1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ Note: the bearer token secret, if specified, will be sent to **all servers liste
|---|---|---|---|
|IMAGE|Reference of the image buildah will produce.||true|
|OCI_COPY_FILE|Path to the oci copy file.|./oci-copy.yaml|false|
|BEARER_TOKEN_SECRET_NAME|Name of a secret which will be made available to the build as an Authorization header. Note, the token will be sent to all servers found in the oci-copy.yaml file. If you do not wish to send the token to all servers, different taskruns and therefore different oci artifacts must be used.|""|false|
|BEARER_TOKEN_SECRET_NAME|Name of a secret which will be made available to the build as an Authorization header. Note, the token will be sent to all servers found in the oci-copy.yaml file. If you do not wish to send the token to all servers, different taskruns and therefore different oci artifacts must be used.|"does-not-exist"|false|


## Results
|name|description|
|---|---|
|IMAGE_DIGEST|Digest of the image just built|
|IMAGE_URL|Image repository where the built image was pushed|
|SBOM_BLOB_URL|Link to the SBOM blob pushed to the registry.|

## Workspaces
|name|description|optional|
Expand Down
Loading

0 comments on commit d5c716b

Please sign in to comment.