Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for subscription activation keys to trusted artifacts #1173

Merged
merged 3 commits into from
Jul 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions task-generator/remote/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ package main
import (
"bytes"
"flag"
"os"
"path/filepath"
"strings"

tektonapi "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/cli-runtime/pkg/printers"
klog "k8s.io/klog/v2"
"os"
"path/filepath"
"sigs.k8s.io/controller-runtime/pkg/log/zap"
"strings"
)

func main() {
Expand Down Expand Up @@ -127,6 +128,10 @@ fi
`

env := "$PODMAN_PORT_FORWARD \\\n"

// disable podman subscription-manager integration
env += " --tmpfs /run/secrets \\\n"

// Before the build we sync the contents of the workspace to the remote host
for _, workspace := range task.Spec.Workspaces {
ret += "\nrsync -ra $(workspaces." + workspace.Name + ".path)/ \"$SSH_HOST:$BUILD_DIR/workspaces/" + workspace.Name + "/\""
Expand Down
19 changes: 19 additions & 0 deletions task/buildah-oci-ta/0.1/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
---

Check failure on line 1 in task/buildah-oci-ta/0.1/buildah-oci-ta.yaml

View workflow job for this annotation

GitHub Actions / Check Trusted Artifact variants

File is out of date, run `hack/generate-ta-tasks.sh` and include the updated file with your changes
apiVersion: tekton.dev/v1
kind: Task
metadata:
Expand Down Expand Up @@ -59,6 +59,10 @@
description: Name of secret which contains the entitlement certificates
type: string
default: etc-pki-entitlement
- name: ACTIVATION_KEY
default: activation-key
description: Name of secret which contains subscription activation key
type: string
- name: HERMETIC
description: Determines if build will be executed without network access.
type: string
Expand Down Expand Up @@ -148,6 +152,10 @@
secret:
optional: true
secretName: $(params.ENTITLEMENT_SECRET)
- name: activation-key
secret:
optional: true
secretName: $(params.ACTIVATION_KEY)
- name: shared
emptyDir: {}
- name: trusted-ca
Expand Down Expand Up @@ -177,6 +185,8 @@
value: $(params.DOCKERFILE)
- name: ENTITLEMENT_SECRET
value: $(params.ENTITLEMENT_SECRET)
- name: ACTIVATION_KEY
value: $(params.ACTIVATION_KEY)
- name: HERMETIC
value: $(params.HERMETIC)
- name: IMAGE
Expand Down Expand Up @@ -221,6 +231,8 @@
name: varlibcontainers
- mountPath: /entitlement
name: etc-pki-entitlement
- mountPath: /activation-key
name: activation-key
- mountPath: /additional-secret
name: additional-secret
- mountPath: /mnt/trusted-ca
Expand Down Expand Up @@ -353,6 +365,13 @@
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down
23 changes: 23 additions & 0 deletions task/buildah-remote-oci-ta/0.1/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ spec:
description: Name of secret which contains the entitlement certificates
name: ENTITLEMENT_SECRET
type: string
- default: activation-key
description: Name of secret which contains subscription activation key
name: ACTIVATION_KEY
type: string
- default: "false"
description: Determines if build will be executed without network access.
name: HERMETIC
Expand Down Expand Up @@ -157,6 +161,8 @@ spec:
value: $(params.DOCKERFILE)
- name: ENTITLEMENT_SECRET
value: $(params.ENTITLEMENT_SECRET)
- name: ACTIVATION_KEY
value: $(params.ACTIVATION_KEY)
- name: HERMETIC
value: $(params.HERMETIC)
- name: IMAGE
Expand Down Expand Up @@ -238,6 +244,7 @@ spec:
rsync -ra /shared/ "$SSH_HOST:$BUILD_DIR/volumes/shared/"
rsync -ra /var/workdir/ "$SSH_HOST:$BUILD_DIR/volumes/workdir/"
rsync -ra /entitlement/ "$SSH_HOST:$BUILD_DIR/volumes/etc-pki-entitlement/"
rsync -ra /activation-key/ "$SSH_HOST:$BUILD_DIR/volumes/activation-key/"
rsync -ra /additional-secret/ "$SSH_HOST:$BUILD_DIR/volumes/additional-secret/"
rsync -ra /mnt/trusted-ca/ "$SSH_HOST:$BUILD_DIR/volumes/trusted-ca/"
rsync -ra "$HOME/.docker/" "$SSH_HOST:$BUILD_DIR/.docker/"
Expand Down Expand Up @@ -370,6 +377,13 @@ spec:
echo "Adding the entitlement to the build"
fi

ACTIVATION_KEY_PATH="/activation-key"
if [ -d "$ACTIVATION_KEY_PATH" ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key"
echo "Adding activation key to the build"
fi

ADDITIONAL_SECRET_PATH="/additional-secret"
ADDITIONAL_SECRET_TMP="/tmp/additional-secret"
if [ -d "$ADDITIONAL_SECRET_PATH" ]; then
Expand Down Expand Up @@ -413,13 +427,15 @@ spec:
chmod +x scripts/script-build.sh
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
ssh $SSH_ARGS "$SSH_HOST" $PORT_FORWARD podman run $PODMAN_PORT_FORWARD \
--tmpfs /run/secrets \
chmeliik marked this conversation as resolved.
Show resolved Hide resolved
-e ADDITIONAL_SECRET="$ADDITIONAL_SECRET" \
-e ADD_CAPABILITIES="$ADD_CAPABILITIES" \
-e BUILDAH_FORMAT="$BUILDAH_FORMAT" \
-e BUILD_ARGS_FILE="$BUILD_ARGS_FILE" \
-e CONTEXT="$CONTEXT" \
-e DOCKERFILE="$DOCKERFILE" \
-e ENTITLEMENT_SECRET="$ENTITLEMENT_SECRET" \
-e ACTIVATION_KEY="$ACTIVATION_KEY" \
-e HERMETIC="$HERMETIC" \
-e IMAGE="$IMAGE" \
-e IMAGE_EXPIRES_AFTER="$IMAGE_EXPIRES_AFTER" \
Expand All @@ -435,6 +451,7 @@ spec:
-v "$BUILD_DIR/volumes/shared:/shared:Z" \
-v "$BUILD_DIR/volumes/workdir:/var/workdir:Z" \
-v "$BUILD_DIR/volumes/etc-pki-entitlement:/entitlement:Z" \
-v "$BUILD_DIR/volumes/activation-key:/activation-key:Z" \
-v "$BUILD_DIR/volumes/additional-secret:/additional-secret:Z" \
-v "$BUILD_DIR/volumes/trusted-ca:/mnt/trusted-ca:Z" \
-v "$BUILD_DIR/.docker/:/root/.docker:Z" \
Expand All @@ -459,6 +476,8 @@ spec:
name: varlibcontainers
- mountPath: /entitlement
name: etc-pki-entitlement
- mountPath: /activation-key
name: activation-key
- mountPath: /additional-secret
name: additional-secret
- mountPath: /mnt/trusted-ca
Expand Down Expand Up @@ -644,6 +663,10 @@ spec:
secret:
optional: true
secretName: $(params.ENTITLEMENT_SECRET)
- name: activation-key
secret:
optional: false
secretName: $(params.ACTIVATION_KEY)
- emptyDir: {}
name: shared
- configMap:
Expand Down
1 change: 1 addition & 0 deletions task/buildah-remote/0.1/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ spec:
chmod +x scripts/script-build.sh
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
ssh $SSH_ARGS "$SSH_HOST" $PORT_FORWARD podman run $PODMAN_PORT_FORWARD \
--tmpfs /run/secrets \
-e BUILDAH_FORMAT="$BUILDAH_FORMAT" \
-e STORAGE_DRIVER="$STORAGE_DRIVER" \
-e HERMETIC="$HERMETIC" \
Expand Down
Loading