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

Refactor the bundle build #133

Merged
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
879 changes: 437 additions & 442 deletions .tekton/gatekeeper-operator-3-17-pull-request.yaml

Large diffs are not rendered by default.

875 changes: 435 additions & 440 deletions .tekton/gatekeeper-operator-3-17-push.yaml

Large diffs are not rendered by default.

914 changes: 455 additions & 459 deletions .tekton/gatekeeper-operator-bundle-3-17-pull-request.yaml

Large diffs are not rendered by default.

910 changes: 453 additions & 457 deletions .tekton/gatekeeper-operator-bundle-3-17-push.yaml

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,15 @@ update-bindata: go-bindata ## Update bindata.go file.
rm -rf ./$(GATEKEEPER_MANIFEST_DIR)-rendered
$(MAKE) fmt

GATEKEEPER_IMAGE ?= quay.io/gatekeeper/gatekeeper
GATEKEEPER_IMG_BASE ?= quay.io/gatekeeper/gatekeeper
GATEKEEPER_IMG ?= $(GATEKEEPER_IMAGE_BASE):v$(GATEKEEPER_VERSION)

.PHONY: update-gatekeeper-image
update-gatekeeper-image: ## Update Gatekeeper image in manifests.
yq 'select(.kind == "Deployment") \
|= .spec.template.spec.containers[] \
|= select(.name == "manager").env[] \
|= select(.name == "RELATED_IMAGE_GATEKEEPER").value = "$(GATEKEEPER_IMAGE):v$(GATEKEEPER_VERSION)"' \
|= select(.name == "RELATED_IMAGE_GATEKEEPER").value = "$(GATEKEEPER_IMG)"' \
-i config/manager/manager.yaml

# Set version variables for LDFLAGS
Expand Down
5 changes: 3 additions & 2 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ COPY pkg/ pkg/
# Build
RUN CGO_ENABLED=1 GOOS=${GOOS} GOARCH=${GOARCH} go build -mod=readonly -a -ldflags "${LDFLAGS}" -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
# Copy to base image
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
WORKDIR /
COPY --from=builder /workspace/manager .
RUN mkdir licenses/
COPY LICENSE licenses/
USER 65532:65532

ENTRYPOINT ["/manager"]
5 changes: 3 additions & 2 deletions build/Dockerfile.rhtap
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,12 @@ COPY pkg/ pkg/
# Build
RUN CGO_ENABLED=1 GOOS=${GOOS} GOARCH=${GOARCH} go build -mod=readonly -a -ldflags "${LDFLAGS}" -o manager main.go

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
# Copy to base image
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
WORKDIR /
COPY --from=builder /workspace/manager .
RUN mkdir licenses/
COPY LICENSE licenses/
USER 65532:65532

ENTRYPOINT ["/manager"]
8 changes: 4 additions & 4 deletions build/bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ LABEL com.redhat.delivery.operator.bundle=true
LABEL com.redhat.openshift.versions=v4.12
# Bundle metadata
LABEL name=gatekeeper/gatekeeper-operator-bundle
LABEL description=gatekeeper-operator-bundle
LABEL io.k8s.description=gatekeeper-operator-bundle
LABEL summary="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
LABEL description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
LABEL io.k8s.description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
LABEL summary="Red Hat Gatekeeper Operator"
LABEL version=v3.17.0
LABEL release=""
LABEL distribution-scope=public
LABEL maintainer="[email protected]"
LABEL url=https://github.com/stolostron/gatekeeper-operator
LABEL vendor="Red Hat"
LABEL vendor="Red Hat, Inc."
38 changes: 38 additions & 0 deletions build/bundle.Dockerfile.rhtap
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
FROM registry.redhat.io/openshift4/ose-cli-rhel9:v4.17 as builder

WORKDIR /gatekeeper-operator
COPY . .
RUN /gatekeeper-operator/build/konflux-patch.sh

FROM scratch

# Copy files to locations specified by labels.
COPY --from=builder /gatekeeper-operator/bundle/manifests /manifests/
COPY --from=builder /gatekeeper-operator/bundle/metadata /metadata/

# Core bundle annotations.
LABEL operators.operatorframework.io.bundle.channel.default.v1=stable
LABEL operators.operatorframework.io.bundle.channels.v1="stable,3.17"
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=gatekeeper-operator
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.34.1
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
# Red Hat annotations.
LABEL com.redhat.component=gatekeeper-operator-bundle-container
LABEL com.redhat.delivery.backport=false
LABEL com.redhat.delivery.operator.bundle=true
LABEL com.redhat.openshift.versions=v4.12
# Bundle metadata
LABEL name=gatekeeper/gatekeeper-operator-bundle
LABEL description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
LABEL io.k8s.description="The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
LABEL summary="Red Hat Gatekeeper Operator"
LABEL version=v3.17.0
LABEL release=""
LABEL distribution-scope=public
LABEL maintainer="[email protected]"
LABEL url=https://github.com/stolostron/gatekeeper-operator
LABEL vendor="Red Hat, Inc."
29 changes: 29 additions & 0 deletions build/konflux-patch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#! /bin/bash

set -e

# Gatekeeper Operator image
operator_img="registry.redhat.io/gatekeeper/gatekeeper-rhel9-operator@sha256:6e386be134d928bdb03b702e399c97e7aedecacaa3d0813183a8c5ecf13c7bc2"
# Gatekeeper image
gatekeeper_img="registry.redhat.io/gatekeeper/gatekeeper-rhel9@sha256:3095f68c12c5dc3b00ce84e1c37d516d96cbcb06d42eaef5372358786956bd62"
Comment on lines +6 to +8

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will these get updated by nudges?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct--that's the next piece I need to work out. That and the FBC.


build_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"

csv_file=${build_dir}/../bundle/manifests/gatekeeper-operator.clusterserviceversion.yaml

csv_patch=$(printf '[{
"op": "replace",
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/env/0/value",
"value": "%s",
},{
"op": "replace",
"path": "/spec/install/spec/deployments/0/spec/template/spec/containers/0/image",
"value": "%s",
},{
"op": "replace",
"path": "/spec/relatedImages/0/image",
"value": "%s",
}]' ${gatekeeper_img} ${operator_img} ${gatekeeper_img})

kubectl patch --local=true -f ${csv_file} --type=json --patch="${csv_patch}" --output=yaml >${csv_file}.bk
mv ${csv_file}.bk ${csv_file}
8 changes: 4 additions & 4 deletions bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ annotations:
com.redhat.openshift.versions: v4.12
# Bundle metadata
name: gatekeeper/gatekeeper-operator-bundle
description: gatekeeper-operator-bundle
io.k8s.description: gatekeeper-operator-bundle
summary: "The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
description: "The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
io.k8s.description: "The Gatekeeper Operator installs and configures Open Policy Agent Gatekeeper."
summary: "Red Hat Gatekeeper Operator"
version: v3.17.0
release: ""
distribution-scope: public
maintainer: "[email protected]"
url: https://github.com/stolostron/gatekeeper-operator
vendor: "Red Hat"
vendor: "Red Hat, Inc."
Loading