From 29403771effad826bfe0d79e6b89a34536c0c049 Mon Sep 17 00:00:00 2001 From: Antoni Segura Puimedon Date: Mon, 23 Dec 2024 14:48:55 +0100 Subject: [PATCH] Separate CPO containerfiles This PR separates the container files into: - Containerfile.control-plane: For Konflux, using RH catalog/brew - Dockerfile.control-plane: For ART/release-payload To help developers avoid the situation where one changes one but not the other, this commit adds a git pre-commit hook that enforces the only differences to be in the "^FROM" lines. In order to install this pre-commit hook, one can run: pipx install pre-commit pre-commit install Then, any new commit that the developer attempts will have to conform to the new hook (and a couple more I added like no whitespace at the end). Signed-off-by: Antoni Segura Puimedon --- .pre-commit-config.yaml | 21 +++++++++++++++ Containerfile.control-plane | 27 +++++++++++++++++++ .../git-hooks/cpo-containerfiles-in-sync.sh | 9 +++++++ 3 files changed, 57 insertions(+) create mode 100644 .pre-commit-config.yaml create mode 100644 Containerfile.control-plane create mode 100755 hack/tools/git-hooks/cpo-containerfiles-in-sync.sh diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000000..d3ba3129c1 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,21 @@ +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: check-merge-conflict + - id: check-yaml + - id: trailing-whitespace + args: + - --markdown-linebreak-ext=md + - repo: local + hooks: + - id: cpo-containerfiles-in-sync + name: cpo-containerfiles-in-sync + entry: ./hack/tools/git-hooks/cpo-containerfiles-in-sync.sh + language: script + pass_filenames: false + args: + - Containerfile.control-plane + - Dockerfile.control-plane + description: Ensures the CPO container files stay in sync +exclude: '^vendor/|^hack/tools/vendor/|^api/vendor/' diff --git a/Containerfile.control-plane b/Containerfile.control-plane new file mode 100644 index 0000000000..b7c9b7a978 --- /dev/null +++ b/Containerfile.control-plane @@ -0,0 +1,27 @@ +FROM brew.registry.redhat.io/rh-osbs/openshift-golang-builder:rhel_9_1.22 AS builder + +WORKDIR /hypershift + +COPY . . + +RUN make control-plane-operator control-plane-pki-operator + +FROM registry.redhat.io/rhel9-2-els/rhel:9.2 +COPY --from=builder /hypershift/bin/control-plane-operator /usr/bin/control-plane-operator +COPY --from=builder /hypershift/bin/control-plane-pki-operator /usr/bin/control-plane-pki-operator + +ENTRYPOINT /usr/bin/control-plane-operator + +LABEL io.openshift.release.operator=true +LABEL io.openshift.hypershift.control-plane-operator-subcommands=true +LABEL io.openshift.hypershift.control-plane-operator-skips-haproxy=true +LABEL io.openshift.hypershift.ignition-server-healthz-handler=true +LABEL io.openshift.hypershift.control-plane-operator-manages-ignition-server=true +LABEL io.openshift.hypershift.control-plane-operator-manages.cluster-machine-approver=true +LABEL io.openshift.hypershift.control-plane-operator-manages.cluster-autoscaler=true +LABEL io.openshift.hypershift.control-plane-operator-manages.decompress-decode-config=true +LABEL io.openshift.hypershift.control-plane-operator-creates-aws-sg=true +LABEL io.openshift.hypershift.control-plane-operator-applies-management-kas-network-policy-label=true +LABEL io.openshift.hypershift.restricted-psa=true +LABEL io.openshift.hypershift.control-plane-pki-operator-signs-csrs=true +LABEL io.openshift.hypershift.hosted-cluster-config-operator-reports-node-count=true diff --git a/hack/tools/git-hooks/cpo-containerfiles-in-sync.sh b/hack/tools/git-hooks/cpo-containerfiles-in-sync.sh new file mode 100755 index 0000000000..2f55d5b509 --- /dev/null +++ b/hack/tools/git-hooks/cpo-containerfiles-in-sync.sh @@ -0,0 +1,9 @@ +#!/bin/bash +echo >&2 "Processing " "$@" + +eval_cmd=("diff") +for f in "$@"; do + eval_cmd+=("<(sed -e '/^FROM /d' \"$f\")") +done + +eval "${eval_cmd[*]}"