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

OperatorHub Release CLI / Moving OperatorHub release to Buildkite #6281

Merged
merged 109 commits into from
Feb 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
109 commits
Select commit Hold shift + click to select a range
b5cad6a
Add sub-commands: bundle, container, operatorhub
naemono Dec 15, 2021
52be31f
wip
naemono Nov 16, 2022
e7148ec
Minimally functional build with preflight.
naemono Nov 16, 2022
fafc063
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Nov 16, 2022
5ef2a3a
wip
naemono Nov 18, 2022
2e19acc
wip
naemono Nov 22, 2022
4f112dd
removing pterm
naemono Nov 29, 2022
87ce09a
move -enable-vault to global
naemono Dec 13, 2022
59da0dc
Vault work to automatically retrieve sensitive data.
naemono Dec 13, 2022
f9a1c46
wip
naemono Dec 15, 2022
f35c5c7
wip
naemono Dec 15, 2022
13ff70b
wip
naemono Dec 15, 2022
db4006d
Move some flags to persistent flags in parent commands.
naemono Dec 16, 2022
85c6aaf
docs update
naemono Dec 21, 2022
8007980
code cleanup
naemono Dec 27, 2022
24dbab3
rename operatorhu package
naemono Dec 28, 2022
c788341
Add flags and manifests packages
naemono Dec 28, 2022
0f3eb2b
Cleanup and documentation
naemono Dec 29, 2022
dc26eb7
do not enable vault by default.
naemono Jan 3, 2023
82ee8cf
readme cleanup
naemono Jan 4, 2023
b90cca6
Cleanup commands
naemono Jan 4, 2023
9f02927
Move to internal instead of pkg directory.
naemono Jan 4, 2023
bdebfcd
Cleanup and fixes during testing
naemono Jan 5, 2023
36f6a94
Update buildkite steps.
naemono Jan 5, 2023
68bb75b
Add buildkite command
naemono Jan 5, 2023
d99cdf9
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Jan 5, 2023
0320673
Fix merge to main with 'go mod tidy'
naemono Jan 5, 2023
3f73b68
Remove comments from pipeline, and add newline
naemono Jan 5, 2023
5728382
Rename cli commands in pipeline
naemono Jan 5, 2023
3ce1d35
Newline to makefile
naemono Jan 5, 2023
015ac3a
Uppercase HTTP
naemono Jan 5, 2023
360de55
Remove submitpullrequest flag remnants.
naemono Jan 5, 2023
9e44735
Remove comment
naemono Jan 5, 2023
bb4c4fd
Use const for errors
naemono Jan 5, 2023
07feaec
Move error format to common package.
naemono Jan 5, 2023
37a848c
Use common error fmt in root cmd.
naemono Jan 5, 2023
e024247
Adjust wording in errors
naemono Jan 5, 2023
b299ef1
Move to a common config struct.
naemono Jan 5, 2023
942a898
Removing unused test
naemono Jan 5, 2023
aacc731
Use certification instead of catalog throughout.
naemono Jan 5, 2023
8df98f7
Fix error format in github package.
naemono Jan 5, 2023
6541fb2
Fixing errors in github package
naemono Jan 5, 2023
7e2cc97
Fixing errors in opm package.
naemono Jan 5, 2023
5b12fb9
revert changes in license package
naemono Jan 5, 2023
e1b8d95
Fixing errors in operatorhub package.
naemono Jan 5, 2023
6ecb9dc
Fix use of common config
naemono Jan 9, 2023
62bd60c
remove "v" prefix from .tpl files and move logic to code
naemono Jan 9, 2023
a61e9a1
Support additional BK cmd flags
naemono Jan 10, 2023
74a88cf
Branch/Commit are required.
naemono Jan 10, 2023
00c6a64
Add format description to pr repository flag.
naemono Jan 10, 2023
237b9ae
Add git branch flag for bk command.
naemono Jan 10, 2023
6cef2b4
make errors in bk when flags are missing accurate.
naemono Jan 10, 2023
3a65610
Use artifacts properly
naemono Jan 10, 2023
ad5f8ed
No preceding '/' on artifacts
naemono Jan 10, 2023
cec8d5f
Attempt different download style
naemono Jan 10, 2023
221c193
Try different artifact download style
naemono Jan 10, 2023
a42409d
Use artifacts properly
naemono Jan 10, 2023
81c036d
Try different artifact style.
naemono Jan 10, 2023
0a5216c
Ensure operatorhub binary is executable.
naemono Jan 10, 2023
9529dca
Don't use preflight image, just grab the binary.
naemono Jan 10, 2023
0ac984d
Agent contianer doesn't have wget, use curl
naemono Jan 10, 2023
446f71b
Download file properly
naemono Jan 10, 2023
8b0fe58
Debug vault
naemono Jan 10, 2023
b3dcf72
Debugging
naemono Jan 10, 2023
56c01f7
Debug again.
naemono Jan 10, 2023
dbf0c04
Use double $$
naemono Jan 10, 2023
cc3433d
$$ ftw
naemono Jan 10, 2023
2ab0296
remove debugging
naemono Jan 10, 2023
2fb7648
debugging
naemono Jan 10, 2023
76659fb
Don't use format=json when setting env vars
naemono Jan 10, 2023
c010c94
Exit early and don't run preflight if data already exists in api
naemono Jan 10, 2023
92d7390
download jq
naemono Jan 10, 2023
fc92a42
escape curl cmd
naemono Jan 10, 2023
5783237
Debugging
naemono Jan 11, 2023
f738297
Fix typo
naemono Jan 11, 2023
f24ab14
Debugging curl cmd
naemono Jan 11, 2023
67bcef4
Try removing double $$ inside quotes
naemono Jan 11, 2023
5985998
Move setting of env vars before calling api.
naemono Jan 11, 2023
6ba96ca
revert back to $$
naemono Jan 11, 2023
21f73cc
Update docs for flag's env var to be correct.
naemono Jan 11, 2023
146df95
Change description on buildkite branch flag.
naemono Jan 11, 2023
56ae577
Support setting openshift supported versions flag when running buildk…
naemono Jan 11, 2023
4a30030
Sync forks with upstream/main
naemono Jan 12, 2023
563800f
Ensure 'v' prefix is not included in 'NewVersion', as certified opera…
naemono Jan 12, 2023
e737994
Also add elastic-cloud-eck.package.yaml changes to git working tree.
naemono Jan 12, 2023
0750afc
5 minutes, not 10 minutes
naemono Jan 17, 2023
1c0c397
Ensure end of directories yaml marker.
naemono Jan 17, 2023
2e47fbb
JQ is not contained within the BK image we use.
naemono Jan 18, 2023
40fb7a4
Just defer the closing of the response body, no nil check.
naemono Jan 21, 2023
b9e870d
Optimize container package.
naemono Jan 21, 2023
7e13c98
Move large commands to a script in buildkite.
naemono Jan 23, 2023
b92e744
Update README for generate-manifests.
naemono Jan 23, 2023
ab22eed
Move operatorhub steps to a custom pipline yaml
naemono Jan 23, 2023
b7f9859
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Jan 27, 2023
9368f9c
Go mod tidy
naemono Jan 27, 2023
d1ec9c6
Fix shellcheck issues
naemono Jan 27, 2023
dfb1fe9
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Feb 6, 2023
dd3e3d1
Remove if statements in custom pipeline as not needed.
naemono Feb 10, 2023
3b4ad17
Make script executable.
naemono Feb 10, 2023
73f35a0
Stack/Prev version flags removed for ohub cmd.
naemono Feb 13, 2023
da31c9c
Keep the 'v' in the ohub package template.
naemono Feb 13, 2023
ce138f6
Remove need for cli flag --tag, just use `newVersion` in config file.
naemono Feb 14, 2023
f902e09
Remove supported-openshift-versions flag
naemono Feb 14, 2023
c50792a
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Feb 16, 2023
36196b4
Add back fake failing tests.
naemono Feb 20, 2023
2002363
Revert "Add back fake failing tests."
naemono Feb 22, 2023
2ee5b58
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Feb 22, 2023
2db9415
go mod tidy
naemono Feb 22, 2023
5134424
Merge branch 'main' into 258-simpify-redhat-publishing
naemono Feb 24, 2023
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
50 changes: 50 additions & 0 deletions .buildkite/pipeline-release-operatorhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@

agents:
image: docker.elastic.co/ci-agent-images/cloud-k8s-operator/buildkite-agent:latest
cpu: "4"
memory: "2G"

steps:

- group: redhat-release

steps:

- label: "build operatorhub tool"
key: "build-operatorhub-tool"
commands:
- cd hack/operatorhub
- make build
- chmod u+x bin/operatorhub
- buildkite-agent artifact upload "bin/operator*"
naemono marked this conversation as resolved.
Show resolved Hide resolved

- label: "Generate CRDs"
key: "generate-crds"
depends_on:
- "build-operatorhub-tool"
commands:
- make generate-crds-v1
artifact_paths:
- "config/*.yaml"

- label: "run container push"
key: "redhat-container-push"
depends_on:
- "generate-crds"
commands:
- buildkite-agent artifact download "bin/operator*" /usr/local/
- /usr/local/bin/operatorhub container push --dry-run=false

- label: "run container preflight"
key: "redhat-preflight"
depends_on:
- "redhat-container-push"
commands:
- .buildkite/scripts/operatorhub/operations.sh preflight

- label: "run remaining release"
key: "redhat-release"
depends_on:
- "redhat-preflight"
commands:
- .buildkite/scripts/operatorhub/operations.sh release
9 changes: 9 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -143,3 +143,12 @@ steps:
if: build.message == "release all helm charts"
commands:
- buildkite-agent pipeline upload .buildkite/pipeline-helm-release-all.yml

- group: redhat-release

steps:

- label: "redhat operatorhub"
if: build.message == "run operatorhub release"
commands:
- buildkite-agent pipeline upload .buildkite/pipeline-release-operatorhub.yml
74 changes: 74 additions & 0 deletions .buildkite/scripts/operatorhub/operations.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/env bash
naemono marked this conversation as resolved.
Show resolved Hide resolved

# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.

# Required environment variables:
# For 'preflight' command:
# OHUB_TAG

set -euo pipefail

preflight() {
if [[ -z ${OHUB_TAG} ]]; then
echo "OHUB_TAG environment variable is required"
exit 1
fi

OHUB_API_KEY="$(vault read -field=api-key secret/ci/elastic-cloud-on-k8s/operatorhub-release-redhat)"
export OHUB_API_KEY
OHUB_PROJECT_ID="$(vault read -field=project-id secret/ci/elastic-cloud-on-k8s/operatorhub-release-redhat)"
export OHUB_PROJECT_ID

curl -s -G "https://catalog.redhat.com/api/containers/v1/projects/certification/id/$OHUB_PROJECT_ID/images?filter=repositories.tags.name==$OHUB_TAG" -H "X-API-KEY: $OHUB_API_KEY" > /tmp/redhat.json

# The following command will fail if no data was returned, so preflight will not run if it's already run
jq -e '.data[0]' /tmp/redhat.json && exit 0

# Install known working version of preflight tool.
curl -sL -o /tmp/preflight https://github.com/redhat-openshift-ecosystem/openshift-preflight/releases/download/1.2.1/preflight-linux-amd64
chmod u+x /tmp/preflight

# Pull authentication information for quay.io from vault
vault read -format=json -field=data secret/ci/elastic-cloud-on-k8s/operatorhub-release-preflight > /tmp/auth.json

/tmp/preflight check container "quay.io/redhat-isv-containers/$OHUB_PROJECT_ID:$OHUB_TAG" --pyxis-api-token="$OHUB_API_KEY" --certification-project-id="$OHUB_PROJECT_ID" --submit -d /tmp/auth.json
}

release() {
buildkite-agent artifact download "bin/operator*" /usr/local/
buildkite-agent artifact download "config/*.yaml" .
cd hack/operatorhub
/usr/local/bin/operatorhub container publish --dry-run=false
/usr/local/bin/operatorhub generate-manifests --yaml-manifest=../../config/crds.yaml --yaml-manifest=../../config/operator.yaml
/usr/local/bin/operatorhub bundle generate --dir="$(pwd)"
/usr/local/bin/operatorhub bundle create-pr --dir="$(pwd)"
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have kept these release commands in the pipeline and just use this script for the preflight commands.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I figured since I was cleaning up the pipeline, I might as well keep it as clean as possible, hence moving all of this to a script. Lmk if you need me to move it back.

}

usage() {
echo "Usage: $0 preflight|release"
echo "preflight: Runs the operatorhub preflight operations in buildkite"
echo "release: Runs the last steps of the operatorhub release steps in buildkite"
exit 2
}

if [[ "$#" -ne 1 ]]; then
usage
fi

case "$1" in
preflight)
preflight
;;
release)
release
;;
help)
usage
;;
*)
echo "Unknown action '$1'"
usage
;;
esac
6 changes: 6 additions & 0 deletions hack/operatorhub/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License 2.0;
# you may not use this file except in compliance with the Elastic License 2.0.

build:
go build -o bin/operatorhub main.go
Loading