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

Change location-based replacement to use Go template #15

Merged
merged 3 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
52 changes: 52 additions & 0 deletions .github/workflows/controller-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Build and push controller

on:
push:
branches:
- main
- v1.0.0
paths:
- .github/workflows/**
- controllers/**
- api/**
- ./main.go
- ./go.mod
- config/**
- ./Dockerfile
- ./bundle.Dockerfile
- ./Makefile

env:
IMAGE_VERSION: '1.0.0'

jobs:
build-push-controller:
if: ${{ github.repository_owner == 'IBM' }}
runs-on: ubuntu-latest
env:
IMAGE_NAME: ghcr.io/ibm/cpe-operator/controller
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.0'
- name: Tidy
run: |
go mod tidy
make generate fmt vet
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push controller
uses: docker/build-push-action@v2
with:
context: .
push: true
tags: |
${{ env.IMAGE_NAME }}:v${{ env.IMAGE_VERSION }}
file: ./Dockerfile
41 changes: 41 additions & 0 deletions .github/workflows/parser-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build and push parser

on:
push:
branches:
- main
- v1.0.0
paths:
- .github/workflows/**
- cpe-parser/**

env:
IMAGE_VERSION: '1.0.0'

jobs:
build-push-parser:
if: ${{ github.repository_owner == 'IBM' }}
runs-on: ubuntu-latest
env:
IMAGE_NAME: ghcr.io/ibm/cpe-operator/parser
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.0'
- name: Set up Docker
uses: docker/setup-buildx-action@v1
- name: Login to Docker
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GH_TOKEN }}
- name: Build and push parser
uses: docker/build-push-action@v2
with:
context: cpe-parser
push: true
tags: |
${{ env.IMAGE_NAME }}:v${{ env.IMAGE_VERSION }}
file: ./cpe-parser/Dockerfile
32 changes: 32 additions & 0 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Perform unittest for controller

on:
pull_request:
push:

jobs:
controller-test:
env:
CLUSTER_ID: default
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-go@v2
with:
go-version: '1.17.0'
- name: set ARCH and OD
run: |
echo "ARCH=$(case $(uname -m) in x86_64) echo -n amd64 ;; aarch64) echo -n arm64 ;; *) echo -n $(uname -m) ;; esac)" >> $GITHUB_ENV
echo "OS=$(uname | awk '{print tolower($0)}')" >> $GITHUB_ENV
echo "OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.23.0" >> $GITHUB_ENV
- name: download operator-sdk
run: curl -LO ${{ env.OPERATOR_SDK_DL_URL }}/operator-sdk_${{ env.OS }}_${{ env.ARCH }}
- name: move operator-sdk to binary path
run: chmod +x operator-sdk_${{ env.OS }}_${{ env.ARCH }} && sudo mv operator-sdk_${{ env.OS }}_${{ env.ARCH }} /usr/local/bin/operator-sdk
- name: Tidy
run: |
go mod tidy
- name: Make bundle
run: make bundle
- name: Test Controller
run: make test
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ iteration/node-tuning-test
transfer.sh
kubectl
config-old/
deploy/
drawio/

benchmarks/benchmark_operator/cpe_v1_benchmark_sysbench_*
benchmarks/benchmark_operator/multi-cluster
benchmarks/*/note*

15 changes: 6 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ vet: ## Run go vet against code.
go vet ./...

ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
test: SHELL := /bin/bash
test: manifests generate fmt vet ## Run tests.
mkdir -p ${ENVTEST_ASSETS_DIR}
test -f ${ENVTEST_ASSETS_DIR}/setup-envtest.sh || curl -sSLo ${ENVTEST_ASSETS_DIR}/setup-envtest.sh https://raw.githubusercontent.com/kubernetes-sigs/controller-runtime/v0.7.2/hack/setup-envtest.sh
Expand All @@ -116,26 +117,22 @@ docker-build: test ## Build docker image with the manager.
docker-push: ## Push docker image with the manager.
docker push ${IMG}

##@ Update Environment
update-env:
envsubst < config/manager/kustomization_template.yaml > config/manager/kustomization.yaml
envsubst < config/manager/manager_template.yaml > config/manager/manager.yaml
envsubst < config/parser/parser_template.yaml > config/parser/parser.yaml

##@ Deployment
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl apply -f -

uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config.
$(KUSTOMIZE) build config/crd | kubectl delete -f -

deploy: update-env manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
cd config/parser && $(KUSTOMIZE) edit set image parser=${PARSER_IMG}
$(KUSTOMIZE) build config/default | kubectl apply -f -

yaml: update-env manifests kustomize
yaml: manifests kustomize
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
$(KUSTOMIZE) build config/default > deploy/simple-deploy.yaml
cd config/parser && $(KUSTOMIZE) edit set image parser=${PARSER_IMG}
$(KUSTOMIZE) build config/default > generated-deployment.yaml


undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config.
Expand Down
Loading