Skip to content

Commit 6ca851c

Browse files
grokspawngrokspawnanik120
authored
supporting automation to process PRs from example-operator-index (#13)
* fix existing operator catalogs; convert catalogs to YAML; update berify GH action * update to use robot on quay * add docker meta to host tags * attempting abandoning meta * correct meta version * fix tag format * fix erroneous tag * specifying git auth token * correct quay repo URI * removing the git_auth_token secret * trying approach as https://github.com/jetstack/jetstack-secure/pull/227/files * removing qemu/buildx steps * switch to docker image repo * happy morning typos * switch both ci flows to docker hub * priming ownership pump * try a different validator * primitive flow * fixing action names * wrong name? * newbie naming joys * fix ws * improved contributer vetting * fix typo * moving veneer examples to example-operator-index * adding placeholder/documentation to catalog file to preserve 'initial' case functionality in CI * formatting * formatting * Update from grokspawn/example-operator-index@a751e44 * workaround for auto-merge not working * Update from grokspawn/example-operator-index@84181b9 * rename incorrectly yaml files to json ext * draft bootstrapping * updating readme to capture branch config, protection of new forks * fixing missing nesting; consistent capitalization * cleaning up dangling directories Signed-off-by: Jordan Keister <jordan@nimblewidget.com> * bumping automerge CI version Signed-off-by: Jordan Keister <jordan@nimblewidget.com> Signed-off-by: Jordan Keister <jordan@nimblewidget.com> Co-authored-by: grokspawn <grokspawn grokspawn@users.noreply.github.com> Co-authored-by: Anik Bhattacharjee <anikbhattacharya93@gmail.com>
1 parent d33e0f2 commit 6ca851c

9 files changed

Lines changed: 185 additions & 200 deletions

File tree

.github/workflows/build-push.yml

Lines changed: 11 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,30 @@ jobs:
1414
- name: Check out
1515
uses: actions/checkout@v2
1616

17-
- name: Docker meta
18-
id: docker_meta
19-
uses: crazy-max/ghaction-docker-meta@v1
20-
with:
21-
images: docker.io/anik120/cool-catalog
22-
tag-sha: true
23-
tag-edge: false
24-
tag-latest: true
25-
26-
- name: Set up QEMU
27-
uses: docker/setup-qemu-action@v1
28-
29-
- name: Set up Docker Buildx
30-
uses: docker/setup-buildx-action@v1
31-
32-
- name: Login to DockerHub
17+
- name: login to registry
3318
uses: docker/login-action@v1
3419
with:
35-
registry: docker.io
3620
username: ${{ secrets.DOCKER_USERNAME }}
3721
password: ${{ secrets.DOCKER_PASSWORD }}
38-
22+
23+
- name: Docker meta
24+
id: docker_meta
25+
uses: docker/metadata-action@v3
26+
with:
27+
images: grokspawn/cool-catalog
28+
tags: ${{ github.event.number }}
29+
3930
- name: Build image
4031
uses: docker/build-push-action@v2
4132
with:
33+
context: .
4234
tags: ${{ steps.docker_meta.outputs.tags }}
4335
file: catalog.Dockerfile
44-
context: .
4536

4637
- name: Push image
4738
uses: docker/build-push-action@v2
4839
with:
40+
context: .
4941
push: true
5042
tags: ${{ steps.docker_meta.outputs.tags }}
5143
file: catalog.Dockerfile
52-
context: .

.github/workflows/build-verify-on-PR.yml

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,38 +6,33 @@ on:
66
- '**'
77

88
jobs:
9-
10-
build:
9+
build:
1110
runs-on: ubuntu-latest
1211

1312
steps:
1413
- name: Check out
1514
uses: actions/checkout@v2
1615

17-
- name: Docker meta
18-
id: docker_meta
19-
uses: crazy-max/ghaction-docker-meta@v2
16+
# models a future action where the submittor is validated against auth access for the
17+
# catalog contribution
18+
- name: Validate Contributor
19+
run: |
20+
NUM_OWNERS=`grep -c ${{ github.actor }} CODEOWNERS`
21+
if [ $NUM_OWNERS -gt 0 ] ; then
22+
echo "validated user found in database"
23+
else
24+
exit 1
25+
fi
26+
27+
- name: Validate Contribution
28+
uses: joelanford/opm-validate@main
2029
with:
21-
images: docker.io/anik120/cool-catalog
22-
tag-sha: true
23-
tag-edge: false
24-
tags: ${{ github.event.number }}
25-
26-
- name: Set up QEMU
27-
uses: docker/setup-qemu-action@v1
30+
catalog: catalog
2831

29-
- name: Set up Docker Buildx
30-
uses: docker/setup-buildx-action@v1
31-
32-
- name: Build image
33-
uses: docker/build-push-action@v2
32+
- name: automerge PRs that pass checks
33+
uses: peter-evans/enable-pull-request-automerge@v2.2.1
3434
with:
35-
tags: ${{ steps.docker_meta.outputs.tags }}
36-
file: catalog.Dockerfile
37-
context: .
35+
token: ${{ secrets.GH_PAT }}
36+
pull-request-number: ${{ github.event.pull_request.number }}
37+
merge-method: merge
3838

39-
validate:
40-
runs-on: quay.io/operator-framework/opm:latest
41-
steps:
42-
- uses: actions/checkout@v2
43-
- run: opm validate $GITHUB_WORKSPACE/catalog/

CODEOWNERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* @grokspawn
2+

README.md

Lines changed: 125 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,126 @@
11
# CoolCatalog
2-
Repository that showcases example workflows for building OLM Catalogs via Declarative Configurations
2+
Welcome! This repository showcases example workflows for building OLM Catalogs via Declarative Configurations
3+
4+
## Quickstart
5+
1. fork this repository
6+
2. determine the desired storage format of the resulting FBC catalog hierarchy (unversioned per-operator partitions? nested versions? etc.)
7+
3. add/modify/adjust action CI configurations in [.github/workflows](.github/workflows)
8+
4. communicate your desired storage format to contributors
9+
5. push changes
10+
11+
12+
## Detailed HOWTO
13+
14+
### Actors and Terms
15+
- [`File-Based Catalog`](https://olm.operatorframework.io/docs/reference/file-based-catalogs/) (FBC) is the declarative expression of operators and their relationships with other operators, other versions of themselves.
16+
- [`Veneers`](https://olm.operatorframework.io/docs/reference/veneers/) are a general class of objects which can provide a simplified interaction with FBC.
17+
- `Operator Author` is the role related to expressing an individual operator versions, channels, properties, etc. in a destination catalog.
18+
- `Catalog` is the FBC-based catalog composed of the FBC contributions of one or more operators.
19+
- `Catalog Owner` is the role related to integrating Operator Authors' catalog contributions.
20+
- `Catalog Contribution` is the FBC that a Catalog Ownder receives from an Operator Author. The format needs to be negotiated with the Operator Author.
21+
For this example, the Catalog Owner receives contributions of a single, unversioned directory named after the operator which contain all FBC files, e.g.:
22+
23+
```tree
24+
catalog
25+
├── .indexignore (to make `opm validate` ignore README.md)
26+
├── README.md
27+
├── testoperator
28+
│   ├── .indexignore
29+
│   ├── OWNERS
30+
│   └── catalog.yaml
31+
└── testoperator2
32+
├── .indexignore
33+
├── OWNERS
34+
└── catalog.yaml
35+
```
36+
37+
### Lifecycle
38+
39+
This repository models an operator catalog which receives contributions from one or more Operator Authors, merges and organizes those contributions. This repository has pre-configured GitHub actions to validate contributed content, validate FBC contributions, auto-merge contribution PRs, and push updated catalog images capable of serving as [Catalog Sources](https://olm.operatorframework.io/docs/concepts/crds/catalogsource/).
40+
41+
42+
```mermaid
43+
%%{init: {'securityLevel': 'strict', 'theme':'forest'}}%%
44+
sequenceDiagram
45+
autonumber
46+
participant CatalogOwner
47+
participant Catalog
48+
participant GHAction
49+
participant ImageRepo
50+
CatalogOwner--xCatalog: fork repo
51+
CatalogOwner--xCatalog: adjust CI
52+
CatalogOwner--xCatalog: push updates to remote
53+
CatalogOwner->>+Catalog: Approves PR, merges (auto-merge trivial case)
54+
activate CatalogOwner
55+
activate Catalog
56+
Catalog->>+GHAction: Integrate contribution to catalog
57+
activate GHAction
58+
GHAction->>GHAction: validate contribution's Operator Author
59+
GHAction->>GHAction: generate image contiaining updated catalog
60+
GHAction->>GHAction: validate catalog in image
61+
GHAction->>+ ImageRepo: push catalog image to repo
62+
activate ImageRepo
63+
deactivate ImageRepo
64+
deactivate GHAction
65+
deactivate Catalog
66+
deactivate CatalogOwner
67+
```
68+
69+
1. Fork and Clone Remote Repository
70+
IMPORTANT! Failure to customize could result in unwanted contributions.
71+
72+
2. Determine Storage Strategy and Adjust CI
73+
The default configuration for this repository is a collection of operator-titled directories which individually and collectively validate successfully via [`opm validate`](https://olm.operatorframework.io/docs/reference/file-based-catalogs/#opm-validate). The storage strategy must be communicated to any contributing Operator Authors.
74+
75+
3. Customize CI workflows in [.github/workflows](.github/workflows) to suit your authorization, validation, organization, and publication needs. At a minimum, to suit the "as-is" for this repository, you must:
76+
1. define a [Personal Access Token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token) (PAT) `GH_PAT` for the [auto-merge action](https://github.com/marketplace/actions/enable-pull-request-automerge)
77+
78+
2. Set branch protection rules for the fork (`Settings --> Branches`):
79+
1. Add a new rule
80+
2. Set the following fields:
81+
- `Require a pull request before merging`
82+
- `Require status checks to pass before merging`
83+
- `Require branches to be up to date before merging`
84+
3. Set `Status Checks that are required` by searching for `build` and selecting it from the search results. (Note: you may have to attempt a submission action before this will be available.)
85+
86+
3. Set general settings for the fork (`Settings --> General`):
87+
1. `Allow merge commits`
88+
2. `Allow squash merging`
89+
3. `Allow auto-merge`
90+
4. (optional) `Automatically delete head branches`
91+
92+
4. (Optional) If you wish to push images to other than docker's image repository
93+
1. Add a `repository` field to the docker/login-action, for e.g. quay.io:
94+
```
95+
- name: login to registry
96+
uses: docker/login-action@v1
97+
with:
98+
registry: "quay.io"
99+
username: ${{ secrets.DOCKER_USERNAME }}
100+
password: ${{ secrets.DOCKER_PASSWORD }}
101+
```
102+
103+
2. Add a corresponding `images` field to the docker/metadata-action (e.g. quay.io/exampleuser/cool-catalog)
104+
105+
```
106+
- name: Docker meta
107+
id: docker_meta
108+
uses: docker/metadata-action@v3
109+
with:
110+
images: quay.io/exampleuser/cool-catalog
111+
tags: ${{ github.event.number }}
112+
```
113+
114+
4. Push Changes to Remote
115+
Once finishing customization, push changes to the remote repo to ready it to receive contributions.
116+
117+
5. Catalog Contribution Approval
118+
The default configuration of this repo will auto-approve an Operator Author's contribution if:
119+
120+
1. the Operator Author is listed in the CODEOWNERS file
121+
2. the Catalog Contribution passes validation. This is currently just `opm validate`.
122+
3. the Catalog Contribution can be automerged without conflict.
123+
124+
6. Catalog Publication
125+
Once a PR merges, a GitHub action will be triggered to build and push a Docker catalog image.
126+

catalog.Dockerfile

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ FROM quay.io/operator-framework/opm:latest
44

55
# Configure the entrypoint and command
66
ENTRYPOINT ["/bin/opm"]
7-
CMD ["serve", "/catalog"]
7+
CMD ["serve", "/configs", "--cache-dir=/tmp/cache"]
88

9-
# Copy declarative config root into image at /configs
10-
ADD catalog /catalog
9+
# Copy declarative config root into image at /configs and pre-populate serve cache
10+
ADD catalog /configs
11+
RUN ["/bin/opm", "serve", "/configs", "--cache-dir=/tmp/cache", "--cache-only"]
1112

12-
# Set label for the location of the catalog root directory
13+
# Set DC-specific label for the location of the DC root directory
1314
# in the image
14-
LABEL operators.operatorframework.io.index.configs.v1=/catalog
15+
LABEL operators.operatorframework.io.index.configs.v1=/configs

catalog/.indexignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
README.md

catalog/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
## Catalog Directory
3+
4+
This directory serves to contain individual operator catalogs. Each operator will be contained in
5+
a sub-directory named after it.
6+
For example, for the operator catalog for 'example-operator', we would anticipate the following directory structure:
7+
8+
```tree
9+
catalog/
10+
└── example-operator
11+
├── catalog.yaml
12+
└── OWNERS
13+
```
14+
15+
## NB:
16+
Because all levels of the catalog hierarchy need to be able to pass an opm validation attempt, it may be necessary to include `.indexignore` files to exclude non-catalog files from the attempt.
17+
18+
[See the OpenShift documentation for more information on these files.](https://docs.openshift.com/container-platform/4.10/operators/understanding/olm-packaging-format.html)
19+
20+

catalog/etcd/operator.json

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)