Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e23fd98
generated scripts/openshift/terraform.tfstate
Mar 8, 2021
1b9dfe8
CLOUDP-82782: flexible push
Mar 8, 2021
10c56a2
wip
Mar 8, 2021
ad8a5ad
wip
Mar 8, 2021
4527b7f
wip
Mar 8, 2021
460af03
CLOUDP-84352: generate OLM bundle during release process
Mar 9, 2021
c006e22
renamed to `PATH_TO_COMMIT`
Mar 9, 2021
3178c20
Merge branch 'CLOUDP-82782_release-commit-dir' into CLOUDP-84352-olm-…
Mar 9, 2021
716d678
wip
Mar 9, 2021
5a84c7e
adding bundle.Dockerfile
Mar 9, 2021
98dfdde
Pushing deploy/all-in-one.yaml using GitHub API
github-actions[bot] Mar 9, 2021
8643ca4
Pushing deploy/crds/atlas.mongodb.com_atlasprojects.yaml using GitHub…
github-actions[bot] Mar 9, 2021
e41eb7e
Pushing deploy/crds/atlas.mongodb.com_atlasclusters.yaml using GitHub…
github-actions[bot] Mar 9, 2021
8f5efbb
Pushing deploy/crds/atlas.mongodb.com_atlasdatabaseusers.yaml using G…
github-actions[bot] Mar 9, 2021
07bbfc6
Pushing deploy/clusterwide/clusterwide-config.yaml using GitHub API
github-actions[bot] Mar 9, 2021
5f256ec
Pushing deploy/clusterwide/crds.yaml using GitHub API
github-actions[bot] Mar 9, 2021
8ddf8ef
Pushing deploy/namespaced/namespaced-config.yaml using GitHub API
github-actions[bot] Mar 9, 2021
ba9f072
Pushing deploy/namespaced/crds.yaml using GitHub API
github-actions[bot] Mar 9, 2021
8626ca7
Pushing bundle/tests/scorecard/config.yaml using GitHub API
github-actions[bot] Mar 9, 2021
31cf629
Pushing bundle/metadata/annotations.yaml using GitHub API
github-actions[bot] Mar 9, 2021
d77607e
Pushing bundle/manifests/atlas.mongodb.com_atlasprojects.yaml using G…
github-actions[bot] Mar 9, 2021
949680f
Pushing bundle/manifests/mongodb-atlas-kubernetes.clusterserviceversi…
github-actions[bot] Mar 9, 2021
df9f3c4
Pushing bundle/manifests/atlas.mongodb.com_atlasclusters.yaml using G…
github-actions[bot] Mar 9, 2021
42482da
Pushing bundle/manifests/atlas.mongodb.com_atlasdatabaseusers.yaml us…
github-actions[bot] Mar 9, 2021
dcd51fa
Pushing bundle/manifests/mongodb-atlas-metrics-reader_rbac.authorizat…
github-actions[bot] Mar 9, 2021
18c3d24
Pushing bundle/manifests/mongodb-atlas-controller-manager-metrics-ser…
github-actions[bot] Mar 9, 2021
a9348c0
Pushing bundle.Dockerfile using GitHub API
github-actions[bot] Mar 9, 2021
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
6 changes: 6 additions & 0 deletions .github/actions/gen-install-scripts/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ ENV KUBECTL_VERSION 1.18.12
# Install
RUN curl -L https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl -o /usr/bin/kubectl && \
chmod +x /usr/bin/kubectl

RUN cd /usr/local/bin &&\
curl -L https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh | bash

RUN CONTROLLER_GEN_TMP_DIR=$(mktemp -d) && \
cd $CONTROLLER_GEN_TMP_DIR && \
go mod init tmp && \
go get sigs.k8s.io/controller-tools/cmd/controller-gen@v0.4.1 && \
rm -rf $CONTROLLER_GEN_TMP_DIR && \
CONTROLLER_GEN=${GOBIN}/controller-gen

RUN curl -LO https://github.com/operator-framework/operator-sdk/releases/download/v1.4.2/operator-sdk_linux_amd64 && \
chmod +x operator-sdk_linux_amd64 && \
mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk

# Copies your code file from your action repository to the filesystem path `/` of the container
COPY entrypoint.sh /home/entrypoint.sh
RUN chmod +x /home/entrypoint.sh
Expand Down
3 changes: 3 additions & 0 deletions .github/actions/gen-install-scripts/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ inputs:
IMAGE_URL:
description: "Operator image"
required: true
VERSION:
description: "Version of the Operator"
required: true
ENV:
description: "Kustomize patch name (enviroment configuration patch)"
required: true
Expand Down
6 changes: 5 additions & 1 deletion .github/actions/gen-install-scripts/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ cd -

which kustomize
kustomize version

# all-in-one
kustomize build --load-restrictor LoadRestrictionsNone "config/release/${INPUT_ENV}/allinone" > "${target_dir}/all-in-one.yaml"
echo "Created all-in-one config"
Expand All @@ -36,4 +37,7 @@ echo "Created namespaced config"
# crds
cp config/crd/bases/* "${crds_dir}"


# CSV bundle
operator-sdk generate kustomize manifests -q --apis-dir=pkg/api
kustomize build --load-restrictor LoadRestrictionsNone config/manifests | operator-sdk generate bundle -q --overwrite --version "${VERSION}"
operator-sdk bundle validate ./bundle
3 changes: 1 addition & 2 deletions .github/actions/push-files/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#TODO change to alpine
FROM alpine/git:latest

# Install GitHub CLI
RUN apk update && \
apk add --no-cache libc6-compat
apk add --no-cache libc6-compat bash
RUN mkdir ghcli && cd ghcli && \
wget https://github.com/cli/cli/releases/download/v1.5.0/gh_1.5.0_linux_386.tar.gz -O ghcli.tar.gz --no-check-certificate && \
tar --strip-components=1 -xf ghcli.tar.gz -C /usr/local
Expand Down
2 changes: 1 addition & 1 deletion .github/actions/push-files/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ inputs:
GITHUB_TOKEN:
description: "Action token"
required: true
FILE_TO_COMMIT:
PATH_TO_COMMIT:
description: "Target file which will be committed"
required: true
DESTINATION_BRANCH:
Expand Down
56 changes: 32 additions & 24 deletions .github/actions/push-files/entrypoint.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,28 +1,36 @@
#!/bin/sh
#!/bin/bash

#set -eou pipefail
set -eou pipefail

#commit file to the destination branch
commit_single_file() {
# Commit to the branch
file="$1"
sha=$(git rev-parse "$DESTINATION_BRANCH:$file") || true
content=$(base64 "$file")
message="Pushing $file using GitHub API"

MESSAGE="generated $FILE_TO_COMMIT"
SHA=$(git rev-parse "$DESTINATION_BRANCH:$FILE_TO_COMMIT")
CONTENT=$(base64 "$FILE_TO_COMMIT")
echo "$DESTINATION_BRANCH:$FILE_TO_COMMIT:$SHA"
echo "$DESTINATION_BRANCH:$file:$sha"
if [ "$sha" = "$DESTINATION_BRANCH:$file" ]; then
echo "File does not exist"
gh api --method PUT "/repos/:owner/:repo/contents/$file" \
--field message="$message" \
--field content="$content" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH"
else
echo "File exists"
gh api --method PUT "/repos/:owner/:repo/contents/$file" \
--field message="$message" \
--field content="$content" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH" \
--field sha="$sha"
fi
}

# simple 'for loop' does not work correctly, see https://github.com/koalaman/shellcheck/wiki/SC2044#correct-code
while IFS= read -r -d '' file
do
commit_single_file "$file"
done < <(find "${PATH_TO_COMMIT}" -type f -print0)

# Commit to the branch
if [ "$SHA" = "$DESTINATION_BRANCH:$FILE_TO_COMMIT" ]; then
echo "File does not exist"
gh api --method PUT "/repos/:owner/:repo/contents/$FILE_TO_COMMIT" \
--field message="$MESSAGE" \
--field content="$CONTENT" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH"
else
echo "File exists"
gh api --method PUT "/repos/:owner/:repo/contents/$FILE_TO_COMMIT" \
--field message="$MESSAGE" \
--field content="$CONTENT" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH" \
--field sha="$SHA"
fi
44 changes: 9 additions & 35 deletions .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ on:
description: "Release version:"
required: true


jobs:
create-release-branch:
name: Create Release
Expand All @@ -25,64 +26,37 @@ jobs:
with:
fetch-depth: 0 #required for tags

- name: Create all-in-one installation script
- name: Create deploy configurations
uses: ./.github/actions/gen-install-scripts
with:
IMAGE_URL: ${{ env.DOCKER_RELEASE_REPO }}:${{ env.VERSION }}
VERSION: ${{ env.VERSION }}
ENV: prod

- name: Create branch and push it
run: |
git checkout -b "release/${VERSION}"
git push origin "release/${VERSION}"

- name: Commit all-in-one
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/all-in-one.yaml"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Commit crd project
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/crds/atlas.mongodb.com_atlasprojects.yaml"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Commit crd cluster
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/crds/atlas.mongodb.com_atlasclusters.yaml"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Commit namespaced crds
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/namespaced/crds.yaml"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Commit namespaced config
- name: Commit and push deploy directory
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/namespaced/namespaced-config.yaml"
PATH_TO_COMMIT: "deploy"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Commit clusterwide crds
- name: Commit and push bundle directory
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/clusterwide/crds.yaml"
PATH_TO_COMMIT: "bundle"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Commit clusterwide config
- name: Commit and push bundle dockerfile
uses: ./.github/actions/push-files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: "deploy/clusterwide/clusterwide-config.yaml"
PATH_TO_COMMIT: "bundle.Dockerfile"
DESTINATION_BRANCH: "release/${{ env.VERSION }}"

- name: Create PR
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ jobs:
uses: ./.github/actions/gen-install-scripts
with:
IMAGE_URL: ${{ env.DOCKER_REPO }}:${{ steps.prepare.outputs.tag }}
VERSION: ${{ steps.prepare.outputs.tag }}
ENV: dev

- name: Set properties
Expand Down
15 changes: 15 additions & 0 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM scratch

LABEL operators.operatorframework.io.bundle.mediatype.v1=registry+v1
LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=mongodb-atlas-kubernetes
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.4.2
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/
Loading