Skip to content

Commit

Permalink
feat: Create editors definitions configmaps (#1838)
Browse files Browse the repository at this point in the history
* feat: Create editors definitions configmaps

Signed-off-by: Anatolii Bazko <[email protected]>
  • Loading branch information
tolusha authored May 20, 2024
1 parent 5ad8b51 commit 634c622
Show file tree
Hide file tree
Showing 82 changed files with 1,280 additions and 1,615 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,10 @@ jobs:
registry: quay.io
- name: Build catalog source
run: |
${GITHUB_WORKSPACE}/build/scripts/release/addDigests.sh -s $(make csv-path CHANNEL=next) -t next
${GITHUB_WORKSPACE}/build/scripts/olm/release-catalog.sh \
./build/scripts/release/editors-definitions.sh add-env-vars
make update-dev-resources
./build/scripts/release/addDigests.sh -s $(make csv-path CHANNEL=next) -t next
./build/scripts/olm/release-catalog.sh \
--channel next \
--catalog-image quay.io/eclipse/eclipse-che-olm-catalog:next-digest \
--bundle-image quay.io/eclipse/eclipse-che-olm-bundle:$(make bundle-version CHANNEL=next)-digest
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ COPY go.sum go.sum
# Copy the go source
COPY main.go main.go
COPY vendor/ vendor/
COPY mocks/ mocks/
COPY api/ api/
COPY config/ config/
COPY controllers/ controllers/
COPY pkg/ pkg/
COPY editors-definitions /tmp/editors-definitions

# build operator
# to test FIPS compliance, run https://github.com/openshift/check-payload#scan-a-container-or-operator-image against a built image
Expand All @@ -53,6 +53,7 @@ RUN export ARCH="$(uname -m)" && if [[ ${ARCH} == "x86_64" ]]; then export ARCH=
FROM registry.access.redhat.com/ubi8-minimal:8.9-1161

COPY --from=builder /tmp/header-rewrite-traefik-plugin /tmp/header-rewrite-traefik-plugin
COPY --from=builder /tmp/editors-definitions /tmp/editors-definitions
COPY --from=builder /che-operator/che-operator /manager

ENTRYPOINT ["/manager"]
Expand Down
8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ genenerate-env:
cat $(BASH_ENV_FILE)

install-che-operands: SHELL := /bin/bash
install-che-operands: generate manifests download-kustomize download-gateway-resources
install-che-operands: generate manifests download-kustomize download-gateway-resources copy-editors-definitions
echo "[INFO] Running on $(PLATFORM)"
if [[ ! "$$($(K8S_CLI) get checluster eclipse-che -n $(ECLIPSE_CHE_NAMESPACE) || false )" ]]; then
[[ $(PLATFORM) == "kubernetes" ]] && $(MAKE) install-certmgr
Expand All @@ -378,6 +378,12 @@ install-che-operands: generate manifests download-kustomize download-gateway-res
$(MAKE) store_tls_cert
$(MAKE) create-checluster-cr


# Copy editors definitions to /tmp/editors-definitions
copy-editors-definitions:
mkdir -p /tmp/editors-definitions
cp -r $(PROJECT_DIR)/editors-definitions/* /tmp/editors-definitions

# Downloads Gateway resources
download-gateway-resources:
GATEWAY_RESOURCES=/tmp/header-rewrite-traefik-plugin
Expand Down
2 changes: 1 addition & 1 deletion api/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion api/v2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion build/scripts/release/addDigests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ do
tagOrDigest="${source#*:}"
fi

if [[ ${imageLabel} == "plugin-registry-image" ]] || [[ ${imageLabel} == "devfile-registry-image" ]]; then
if [[ ${imageLabel} == "devfile-registry-image" ]]; then
# Image tag could contains invalid for Env variable name characters, so let's encode it using base32.
# But alphabet of base32 uses one invalid for env variable name character '=' at the end of the line, so let's replace it by '_'.
# To recovery original tag should be done opposite actions: replace '_' to '=', and decode string using 'base32 -d'.
Expand Down
14 changes: 0 additions & 14 deletions build/scripts/release/buildDigestMap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,6 @@ setOperatorImage() {
OPERATOR_IMAGE=$(yq -r '.spec.install.spec.deployments[].spec.template.spec.containers[0].image' "${CSV}")
}

setPluginRegistryList() {
registry=$(yq -r '.spec.install.spec.deployments[].spec.template.spec.containers[].env[] | select(.name | test("RELATED_IMAGE_.*plugin_registry"; "g")) | .value' "${CSV}")
setRegistryImages "${registry}"

PLUGIN_REGISTRY_LIST=${registryImages}
}

setDevfileRegistryList() {
registry=$(yq -r '.spec.install.spec.deployments[].spec.template.spec.containers[].env[] | select(.name | test("RELATED_IMAGE_.*devfile_registry"; "g")) | .value' "${CSV}")

Expand Down Expand Up @@ -150,9 +143,6 @@ setImagesFromDeploymentEnv
setOperatorImage
echo "${OPERATOR_IMAGE}"

setPluginRegistryList
echo "${PLUGIN_REGISTRY_LIST}"

setDevfileRegistryList
echo "${DEVFILE_REGISTRY_LIST}"

Expand All @@ -166,10 +156,6 @@ for image in ${REQUIRED_IMAGES}; do
writeDigest "${image}" "required-image"
done

for image in ${PLUGIN_REGISTRY_LIST}; do
writeDigest "${image}" "plugin-registry-image"
done

for image in ${DEVFILE_REGISTRY_LIST}; do
writeDigest "${image}" "devfile-registry-image"
done
80 changes: 80 additions & 0 deletions build/scripts/release/editors-definitions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/bash
#
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
#
# SPDX-License-Identifier: EPL-2.0
#
# Contributors:
# Red Hat, Inc. - initial API and implementation
#

set -e

OPERATOR_REPO=$(dirname "$(dirname "$(dirname "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")")")")
EDITORS_DEFINITIONS_DIR="${OPERATOR_REPO}/editors-definitions"
MANAGER_YAML="${OPERATOR_REPO}/config/manager/manager.yaml"

init() {
unset VERSION
unset ENVS

COMMAND=$1
shift

while [[ "$#" -gt 0 ]]; do
case $1 in
'--version') VERSION=$2; shift 1;;
esac
shift 1
done
}

usage () {
echo "Editor definitions utils."
echo
echo "Usage:"
echo -e "\t$0 release --version RELEASE_VERSION"
echo -e "\t$0 add-env-vars"
}

release() {
if [[ ! ${VERSION} ]]; then usage; exit 1; fi

yq -riY ".metadata.attributes.version = \"${VERSION}\"" "${EDITORS_DEFINITIONS_DIR}/che-code-latest.yaml"
yq -riY "(.components[] | select(.name==\"che-code-injector\") | .container.image) = \"quay.io/che-incubator/che-code:${VERSION}\"" "${EDITORS_DEFINITIONS_DIR}/che-code-latest.yaml"
}

addEnvVars() {
for EDITOR_DEFINITION_FILE in $(find "${EDITORS_DEFINITIONS_DIR}" -name "*.yaml"); do
NAME=$(yq -r '.metadata.name' "${EDITOR_DEFINITION_FILE}")
VERSION=$(yq -r '.metadata.attributes.version' "${EDITOR_DEFINITION_FILE}")
for COMPONENT in $(yq -r '.components[] | .name' "${EDITOR_DEFINITION_FILE}"); do
ENV_VALUE=$(yq -r ".components[] | select(.name==\"${COMPONENT}\") | .container.image" "${EDITOR_DEFINITION_FILE}")
ENV_NAME=$(echo "RELATED_IMAGE_editor_definition_${NAME}_${VERSION}_${COMPONENT}" | sed 's|[-\.]|_|g')

if [[ ! ${ENV_VALUE} == "null" ]]; then
ENV="{ name: \"${ENV_NAME}\", value: \"${ENV_VALUE}\"}"
if [[ -z ${ENVS} ]]; then
ENVS="${ENV}"
else
ENVS="${ENVS}, ${ENV}"
fi
fi
done
done

yq -riY "(.spec.template.spec.containers[0].env ) += [${ENVS}]" "${MANAGER_YAML}"
}

init "$@"

pushd "${OPERATOR_REPO}" >/dev/null
case $COMMAND in
'release') release;;
'add-env-vars') addEnvVars;;
*) usage; exit 1;;
esac
popd >/dev/null
14 changes: 13 additions & 1 deletion build/scripts/release/make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,17 @@ replaceTag() {
echo "${1}" | sed -e "s/\(.*:\).*/\1${2}/"
}

releaseEditorsDefinitions() {
echo "[INFO] Releasing editor definitions"

. "${OPERATOR_REPO}/build/scripts/release/editors-definitions.sh" release --version "${RELEASE}"
. "${OPERATOR_REPO}/build/scripts/release/editors-definitions.sh" add-env-vars

git add editors-definitions
git add "${OPERATOR_REPO}/config/manager/manager.yaml"
git commit -m "ci: Release editors definitions to $RELEASE" --signoff
}

updateVersionFile() {
echo "[INFO] updating version.go file"
# change version/version.go file
Expand Down Expand Up @@ -268,7 +279,7 @@ createPRToMainBranch() {
resetChanges main
local tmpBranch="copy-csv-to-main"
git checkout -B $tmpBranch
git diff refs/heads/${BRANCH}...refs/heads/${RELEASE_BRANCH} ':(exclude)config/manager/manager.yaml' ':(exclude)deploy' ':(exclude)Dockerfile' | git apply -3
git diff refs/heads/${BRANCH}...refs/heads/${RELEASE_BRANCH} ':(exclude)config/manager/manager.yaml' ':(exclude)deploy' ':(exclude)editors-definitions' ':(exclude)Dockerfile' | git apply -3
if git status --porcelain; then
git add -A || true # add new generated CSV files in olm/ folder
git commit -am "ci: Copy "$RELEASE" csv to main" --signoff
Expand All @@ -291,6 +302,7 @@ run() {

checkoutToReleaseBranch
updateVersionFile
releaseEditorsDefinitions
releaseOperatorCode
if [[ $RELEASE_OLM_FILES == "true" ]]; then
releaseOlmFiles
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -100,7 +100,7 @@ metadata:
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/eclipse-che/che-operator
support: Eclipse Foundation
name: eclipse-che.v7.86.0-867.next
name: eclipse-che.v7.87.0-869.next
namespace: placeholder
spec:
apiservicedefinitions: {}
Expand Down Expand Up @@ -1032,7 +1032,7 @@ spec:
minKubeVersion: 1.19.0
provider:
name: Eclipse Foundation
version: 7.86.0-867.next
version: 7.87.0-869.next
webhookdefinitions:
- admissionReviewVersions:
- v1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
2 changes: 1 addition & 1 deletion bundle/next/eclipse-che/metadata/annotations.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
2 changes: 1 addition & 1 deletion bundle/next/eclipse-che/tests/scorecard/config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
2 changes: 1 addition & 1 deletion config/crd/bases/org.eclipse.che_checlusters.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
2 changes: 1 addition & 1 deletion deploy/deployment/kubernetes/combined.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2019-2023 Red Hat, Inc.
# Copyright (c) 2019-2024 Red Hat, Inc.
# This program and the accompanying materials are made
# available under the terms of the Eclipse Public License 2.0
# which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down
Loading

0 comments on commit 634c622

Please sign in to comment.