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

issue-1249: entitlements cert not working using buildah task with support for activation keys #1269

Merged
merged 1 commit into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
10 changes: 3 additions & 7 deletions task/buildah-oci-ta/0.1/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ spec:
emptyDir: {}
stepTemplate:
env:
- name: ACTIVATION_KEY
value: $(params.ACTIVATION_KEY)
- name: ADDITIONAL_SECRET
value: $(params.ADDITIONAL_SECRET)
- name: ADD_CAPABILITIES
Expand Down Expand Up @@ -366,15 +364,13 @@ spec:
ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >>null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down
8 changes: 5 additions & 3 deletions task/buildah-oci-ta/0.2/buildah-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -367,14 +367,16 @@ spec:
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.
# when activation keys are used an empty directory on shared emptydir volume to "/etc/pki/entitlement" to prevent certificates from being included in the produced container
# To use activation key file 'org' must exist, which means the key 'org' must exist in the key/value secret

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >>null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down
11 changes: 3 additions & 8 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 @@ -147,8 +147,6 @@ spec:
stepTemplate:
computeResources: {}
env:
- name: ACTIVATION_KEY
value: $(params.ACTIVATION_KEY)
- name: ADDITIONAL_SECRET
value: $(params.ADDITIONAL_SECRET)
- name: ADD_CAPABILITIES
Expand Down Expand Up @@ -378,15 +376,13 @@ spec:
ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >>null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down Expand Up @@ -436,7 +432,6 @@ spec:
rsync -ra scripts "$SSH_HOST:$BUILD_DIR"
ssh $SSH_ARGS "$SSH_HOST" $PORT_FORWARD podman run $PODMAN_PORT_FORWARD \
--tmpfs /run/secrets \
-e ACTIVATION_KEY="$ACTIVATION_KEY" \
-e ADDITIONAL_SECRET="$ADDITIONAL_SECRET" \
-e ADD_CAPABILITIES="$ADD_CAPABILITIES" \
-e BUILDAH_FORMAT="$BUILDAH_FORMAT" \
Expand Down
8 changes: 5 additions & 3 deletions task/buildah-remote-oci-ta/0.2/buildah-remote-oci-ta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,16 @@ spec:
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.
# when activation keys are used an empty directory on shared emptydir volume to "/etc/pki/entitlement" to prevent certificates from being included in the produced container
# To use activation key file 'org' must exist, which means the key 'org' must exist in the key/value secret

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >>null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down
11 changes: 3 additions & 8 deletions task/buildah-remote/0.1/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,6 @@ spec:
value: $(params.BUILDER_IMAGE)
- name: ENTITLEMENT_SECRET
value: $(params.ENTITLEMENT_SECRET)
- name: ACTIVATION_KEY
value: $(params.ACTIVATION_KEY)
- name: ADDITIONAL_SECRET
value: $(params.ADDITIONAL_SECRET)
- name: BUILD_ARGS_FILE
Expand Down Expand Up @@ -370,15 +368,13 @@ spec:
ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >> null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down Expand Up @@ -442,7 +438,6 @@ spec:
-e TARGET_STAGE="$TARGET_STAGE" \
-e PARAM_BUILDER_IMAGE="$PARAM_BUILDER_IMAGE" \
-e ENTITLEMENT_SECRET="$ENTITLEMENT_SECRET" \
-e ACTIVATION_KEY="$ACTIVATION_KEY" \
-e ADDITIONAL_SECRET="$ADDITIONAL_SECRET" \
-e BUILD_ARGS_FILE="$BUILD_ARGS_FILE" \
-e ADD_CAPABILITIES="$ADD_CAPABILITIES" \
Expand Down
8 changes: 5 additions & 3 deletions task/buildah-remote/0.2/buildah-remote.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -361,14 +361,16 @@ spec:
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.
# when activation keys are used an empty directory on shared emptydir volume to "/etc/pki/entitlement" to prevent certificates from being included in the produced container
# To use activation key file 'org' must exist, which means the key 'org' must exist in the key/value secret

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >> null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down
10 changes: 3 additions & 7 deletions task/buildah/0.1/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,6 @@ spec:
value: $(params.BUILDER_IMAGE)
- name: ENTITLEMENT_SECRET
value: $(params.ENTITLEMENT_SECRET)
- name: ACTIVATION_KEY
value: $(params.ACTIVATION_KEY)
- name: ADDITIONAL_SECRET
value: $(params.ADDITIONAL_SECRET)
- name: BUILD_ARGS_FILE
Expand Down Expand Up @@ -313,15 +311,13 @@ spec:
ACTIVATION_KEY_PATH="/activation-key"
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >> null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down
8 changes: 5 additions & 3 deletions task/buildah/0.2/buildah.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,16 @@ spec:
ENTITLEMENT_PATH="/entitlement"

# do not enable activation key and entitlement at same time. If both vars are provided, prefer activation key.
# when activation keys are used, an empty directory on shared emptydir volume to /etc/pki/entitlement to prevent certificates from being included in the produced container.
# when activation keys are used an empty directory on shared emptydir volume to "/etc/pki/entitlement" to prevent certificates from being included in the produced container
# To use activation key file 'org' must exist, which means the key 'org' must exist in the key/value secret

if [ -d "$ACTIVATION_KEY_PATH" ]; then
if [ -e /activation-key/org ]; then
cp -r --preserve=mode "$ACTIVATION_KEY_PATH" /tmp/activation-key
mkdir /shared/rhsm-tmp
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/activation-key:/activation-key -v /shared/rhsm-tmp:/etc/pki/entitlement:Z"
echo "Adding activation key to the build"
elif [ -d "$ENTITLEMENT_PATH" ]; then

elif find /entitlement -name "*.pem" >> null; then
cp -r --preserve=mode "$ENTITLEMENT_PATH" /tmp/entitlement
VOLUME_MOUNTS="${VOLUME_MOUNTS} --volume /tmp/entitlement:/etc/pki/entitlement"
echo "Adding the entitlement to the build"
Expand Down
Loading