-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Dale Haiducek <[email protected]>
- Loading branch information
Showing
7 changed files
with
137 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: github-actions | ||
directory: / | ||
schedule: | ||
interval: weekly | ||
groups: | ||
github-actions: | ||
patterns: | ||
- "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"schedule": "before 8am on Monday", | ||
"timezone": "America/New_York" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Preflight Test | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
name: Image build and test | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install OPM | ||
run: | | ||
make opm | ||
- name: Validate catalog | ||
run: | | ||
make validate-catalog | ||
- name: Build and verify image | ||
run: | | ||
make build-image | ||
make run-image & | ||
pid=$! | ||
make test-image | ||
make stop-image | ||
wait ${pid} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
LOCAL_BIN ?= $(PWD)/bin | ||
export PATH := $(LOCAL_BIN):$(PATH) | ||
GOOS := $(shell go env GOOS) | ||
GOARCH := $(shell go env GOARCH) | ||
|
||
.PHONY: clean | ||
clean: | ||
-rm -rf bin/ | ||
|
||
OPM = $(LOCAL_BIN)/opm | ||
|
||
$(OPM): | ||
mkdir -p $(@D) | ||
|
||
.PHONY: opm | ||
opm: $(OPM) | ||
# Checking installation of opm | ||
@current_release_json=$$(curl -s "https://api.github.com/repos/operator-framework/operator-registry/releases/latest"); \ | ||
current_release=$$(printf '%s\n' "$${current_release_json}" | jq -r '.tag_name'); \ | ||
if ! $(OPM) version || [ "$$($(OPM) version | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+" | head -1)" != "$${current_release}" ]; then \ | ||
echo "Installing opm $${current_release}"; \ | ||
download_url=$$(printf '%s\n' "$${current_release_json}" | jq -r '.assets[] | select(.name == "$(GOOS)-$(GOARCH)-opm").browser_download_url'); \ | ||
curl --fail -Lo $(OPM) $${download_url}; \ | ||
chmod +x $(OPM); \ | ||
fi | ||
|
||
.PHONY: validate-catalog | ||
validate-catalog: | ||
$(OPM) validate catalog | ||
|
||
VERSION_TAG ?= latest | ||
IMG_REPO ?= quay.io/strolostron | ||
IMAGE_TAG_BASE ?= $(IMG_REPO)/gatekeeper-operator-fbc | ||
IMG ?= $(IMAGE_TAG_BASE):$(VERSION_TAG) | ||
|
||
.PHONY: build-image | ||
build-image: | ||
podman build -t $(IMG) -f catalog.Dockerfile . | ||
|
||
# ref: https://github.com/operator-framework/operator-registry?tab=readme-ov-file#using-the-catalog-locally | ||
.PHONY: run-image | ||
run-image: | ||
podman run -p 50051:50051 $(IMG) | ||
|
||
.PHONY: stop-image | ||
stop-image: | ||
podman stop --filter "ancestor=$(IMG)" | ||
|
||
GRPCURL := $(LOCAL_BIN)/grpcurl | ||
|
||
$(GRPCURL): | ||
mkdir -p $(@D) | ||
|
||
# gRPCurl Repo: https://github.com/fullstorydev/grpcurl | ||
.PHONY: grpcurl | ||
grpcurl: $(GRPCURL) | ||
# Checking installation of grpcurl | ||
@current_release_json=$$(curl -s "https://api.github.com/repos/fullstorydev/grpcurl/releases/latest"); \ | ||
current_release=$$(printf '%s\n' "$${current_release_json}" | jq -r '.tag_name'); \ | ||
if ! $(GRPCURL) --version || [ "$$($(GRPCURL) --version 2>&1 | grep -o "v[0-9]\+\.[0-9]\+\.[0-9]\+" | head -1)" != "$${current_release}" ]; then \ | ||
echo "Installing grpcurl $${current_release}"; \ | ||
[ "$(GOOS)" = "darwin" ] && go_os="osx" || go_os=$(GOOS); \ | ||
download_file=grpcurl_$${current_release#v}_$${go_os}_$(GOARCH).tar.gz; \ | ||
mkdir $${download_file%.tar.gz}; \ | ||
download_url=$$(printf '%s\n' "$${current_release_json}" | jq -r '.assets[] | select(.name == "'$${download_file}'").browser_download_url'); echo $${download_url}; \ | ||
if curl --fail -Lo $${download_file%.tar.gz}/$${download_file} $${download_url}; then \ | ||
tar xvzf $${download_file%.tar.gz}/$${download_file} -C $${download_file%.tar.gz}; \ | ||
mv $${download_file%.tar.gz}/grpcurl $(GRPCURL); \ | ||
chmod +x $(GRPCURL); \ | ||
rm -rf $${download_file%.tar.gz}; \ | ||
else exit 1; fi; \ | ||
fi | ||
|
||
.PHONY: test-image | ||
test-image: grpcurl | ||
# Validate package list against build/packageList.json | ||
$(GRPCURL) -plaintext localhost:50051 api.Registry.ListPackages | diff test/packageList.json - && echo "Success!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,9 @@ | ||
# Gatekeeper Operator File-Based Catalog | ||
|
||
This repository houses the File-Based Catalog (FBC) for the | ||
[Gatekeeper Operator](https://github.com/stolostron/gatekeeper-operator). | ||
|
||
See the Operator Lifecycle Manager (OLM) | ||
[File-based Catalogs documentation](https://olm.operatorframework.io/docs/reference/file-based-catalogs/) | ||
and the [operator-registry repository](https://github.com/operator-framework/operator-registry) for | ||
additional information. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"name": "gatekeeper-operator" | ||
} |