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

chore: Inject COLLECTOR_VERSION into Konflux-built images #1694

Merged
merged 7 commits into from
Jun 5, 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: 10 additions & 0 deletions .tekton/collector-component-pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ spec:
- description: Output Image Repository
name: output-image-repo
type: string
- default: "-fast"
description: Suffix that will be appended to the output image tag.
name: output-tag-suffix
type: string
- default: .
description: Path to the source code of an application's component from where
to build image.
Expand Down Expand Up @@ -177,6 +181,9 @@ spec:
workspace: git-auth

- name: determine-image-tag
params:
- name: tag-suffix
value: $(params.output-tag-suffix)
runAfter:
# This task must run on a freshly cloned repository to prevent seeing any changes from other tasks.
- clone-repository
Expand Down Expand Up @@ -238,6 +245,9 @@ spec:
value: $(tasks.clone-repository.results.commit)
- name: TARGET_STAGE
value: $(params.build-target-stage)
- name: BUILD_ARGS
value:
- COLLECTOR_TAG=$(tasks.determine-image-tag.results.image-tag)
runAfter:
- prefetch-dependencies
- prepare-rhel-rpm-subscriptions
Expand Down
5 changes: 4 additions & 1 deletion .tekton/determine-image-tag-task.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ metadata:
spec:
description: Determines the tag for the output image using the StackRox convention from 'make tag' output.
params:
- name: tag-suffix
description: Suffix to append to generated image tag.
type: string
results:
- name: image-tag
description: Image Tag determined by custom logic.
Expand All @@ -20,7 +23,7 @@ spec:
dnf -y install git make
cd "$(workspaces.source.path)/source"
.konflux/scripts/fail-build-if-git-is-dirty.sh
echo -n "$(make --quiet --no-print-directory tag)-fast" | tee "$(results.image-tag.path)"
echo -n "$(make --quiet --no-print-directory tag)$(params.tag-suffix)" | tee "$(results.image-tag.path)"
workspaces:
- name: source
description: The workspace where source code is included.
8 changes: 4 additions & 4 deletions collector/container/konflux.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ RUN ./builder/install/install-dependencies.sh && \
-DUSE_VALGRIND=${USE_VALGRIND} \
-DADDRESS_SANITIZER=${ADDRESS_SANITIZER} \
-DTRACE_SINSP_EVENTS=${TRACE_SINSP_EVENTS} && \
cmake --build ${CMAKE_BUILD_DIR} --target all -- -j "${NPROCS:-2}" && \
cmake --build ${CMAKE_BUILD_DIR} --target all -- -j "${NPROCS:-4}" && \
ctest -V --test-dir ${CMAKE_BUILD_DIR} && \
strip -v --strip-unneeded "${CMAKE_BUILD_DIR}/collector/collector"

Expand Down Expand Up @@ -116,8 +116,7 @@ FROM scratch

COPY --from=rpm-implanter-app /mnt /

# TODO(ROX-20236): configure injection of dynamic version value when it becomes possible.
ARG COLLECTOR_VERSION=0.0.1-todo
ARG COLLECTOR_TAG

WORKDIR /

Expand All @@ -133,12 +132,13 @@ LABEL \
source-location="https://github.com/stackrox/collector" \
summary="Runtime data collection for Red Hat Advanced Cluster Security for Kubernetes" \
url="https://catalog.redhat.com/software/container-stacks/detail/60eefc88ee05ae7c5b8f041c" \
version=${COLLECTOR_VERSION} \
version="${COLLECTOR_TAG}" \
vendor="Red Hat, Inc."

ARG BUILD_DIR
ARG CMAKE_BUILD_DIR

ENV COLLECTOR_VERSION="${COLLECTOR_TAG}"
ENV COLLECTOR_HOST_ROOT=/host

COPY kernel-modules/MODULE_VERSION /kernel-modules/MODULE_VERSION.txt
Expand Down
Loading