Skip to content

Commit

Permalink
feat: single namespace (#65)
Browse files Browse the repository at this point in the history
Closes #64
Closes #63
  • Loading branch information
Demonsthere authored May 13, 2021
1 parent 2658f82 commit 0d726dd
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 194 deletions.
308 changes: 148 additions & 160 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,173 +1,161 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.15
working_directory: /go/src/github.com/ory/hydra-maester
steps:
- run:
name: Enable go1.11 modules
command: |
echo 'export GO111MODULE=on' >> $BASH_ENV
source $BASH_ENV
- checkout
- run:
name: Fetch kube-builder
command: |
os=$(go env GOOS)
arch=$(go env GOARCH)
build:
docker:
- image: circleci/golang:1.15
working_directory: /go/src/github.com/ory/hydra-maester
steps:
- checkout
- run:
name: Fetch kube-builder
command: |
os=$(go env GOOS)
arch=$(go env GOARCH)
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.3.2/${os}/${arch} | tar -xz -C /tmp/
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.3.2/${os}/${arch} | tar -xz -C /tmp/
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.3.2_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.3.2_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
- run: make
test:
docker:
- image: circleci/golang:1.15
working_directory: /go/src/github.com/ory/hydra-maester
steps:
- checkout
- run:
name: Fetch kube-builder
command: |
os=$(go env GOOS)
arch=$(go env GOARCH)
- run: make
test:
docker:
- image: circleci/golang:1.15
working_directory: /go/src/github.com/ory/hydra-maester
steps:
- checkout
- run:
name: Fetch kube-builder
command: |
os=$(go env GOOS)
arch=$(go env GOARCH)
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.3.2/${os}/${arch} | tar -xz -C /tmp/
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.3.2/${os}/${arch} | tar -xz -C /tmp/
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.3.2_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
- run: make test
test-integration:
machine: true
steps:
- checkout
- run:
name: Update golang
command: |
sudo rm -rf /usr/local/go/
curl -LO https://dl.google.com/go/go1.15.11.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.15.11.linux-amd64.tar.gz
sudo echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile
go version
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.3.2_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
- run: make test
test-integration:
machine: true
steps:
- checkout
- run:
name: Update golang
command: |
sudo rm -rf /usr/local/go/
curl -LO https://dl.google.com/go/go1.15.11.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.15.11.linux-amd64.tar.gz
sudo echo "export PATH=$PATH:/usr/local/go/bin" >> $HOME/.profile
go version
- run:
name: Download kube-builder
command: |
os=$(go env GOOS)
arch=$(go env GOARCH)
- run:
name: Download kube-builder
command: |
os=$(go env GOOS)
arch=$(go env GOARCH)
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.3.2/${os}/${arch} | tar -xz -C /tmp/
# download kubebuilder and extract it to tmp
curl -sL https://go.kubebuilder.io/dl/2.3.2/${os}/${arch} | tar -xz -C /tmp/
# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.3.2_${os}_${arch} /usr/local/kubebuilder
sudo echo "export PATH=$PATH:/usr/local/kubebuilder/bin" >> $HOME/.profile
- run:
name: Install kustomize
command: |
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv4.1.2/kustomize_v4.1.2_linux_amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kustomize /usr/local/bin/kustomize
kustomize version
- run:
name: Install Kind
command: |
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.10.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- run:
name: Install kubectl
command: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
export KUBECONFIG=$(kind get kubeconfig-path)
- run:
name: Run integration tests
command: make test-integration

# move to a long-term location and put it on your path
# (you'll need to set the KUBEBUILDER_ASSETS env var if you put it somewhere else)
sudo mv /tmp/kubebuilder_2.3.2_${os}_${arch} /usr/local/kubebuilder
sudo echo "export PATH=$PATH:/usr/local/kubebuilder/bin" >> $HOME/.profile
release:
docker:
- image: circleci/golang:1.15
working_directory: /go/src/github.com/ory/hydra-maester
steps:
- checkout
- run:
command: |
echo 'export DOCKER_FULL_TAG=$(echo $CIRCLE_TAG | tr '+' '_')' >> $BASH_ENV
echo 'export DOCKER_SHORT_TAG=$(echo $CIRCLE_TAG | cut -d '+' -f1)' >> $BASH_ENV
./.circleci/release_name.bash
source $BASH_ENV
- setup_remote_docker
- run: docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD"
- run: curl -sL https://git.io/goreleaser | bash

- run:
name: Install kustomize
command: |
curl -sL https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize%2Fv3.3.0/kustomize_v3.3.0_linux_amd64.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kustomize /usr/local/bin/kustomize
kustomize version
- run:
name: Install ginkgo,controller-gen
command: |
go get github.com/onsi/ginkgo/ginkgo
go get sigs.k8s.io/controller-tools/cmd/[email protected]
- run:
name: Install Kind
command: |
curl -Lo ./kind https://github.com/kubernetes-sigs/kind/releases/download/v0.10.0/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind
- run:
name: Install kubectl
command: |
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
chmod +x ./kubectl
sudo mv ./kubectl /usr/local/bin/kubectl
export KUBECONFIG=$(kind get kubeconfig-path)
- run:
name: Run integration tests
command: make test-integration

release:
docker:
- image: circleci/golang:1.15
working_directory: /go/src/github.com/ory/hydra-maester
steps:
- checkout
- run:
command: |
echo 'export DOCKER_FULL_TAG=$(echo $CIRCLE_TAG | tr '+' '_')' >> $BASH_ENV
echo 'export DOCKER_SHORT_TAG=$(echo $CIRCLE_TAG | cut -d '+' -f1)' >> $BASH_ENV
./.circleci/release_name.bash
source $BASH_ENV
- setup_remote_docker
- run: docker login --username "$DOCKER_USERNAME" --password "$DOCKER_PASSWORD"
- run: curl -sL https://git.io/goreleaser | bash

release-changelog:
docker:
- image: circleci/ruby:2.6-node
steps:
- checkout
- run: gem install github_changelog_generator
- run: sudo npm i -g doctoc
- run: github_changelog_generator -u ory -p hydra-maester -o CHANGELOG.md --token $GITHUB_TOKEN
- run: doctoc CHANGELOG.md
- run: doctoc README.md
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "ORY Continuous Integration"
- run: git add CHANGELOG.md
- run: git add README.md
- run: |
git commit -a -m "docs: Incorporates changes from version $(git describe --tags)" || true
- run: git remote rm origin
- run: git remote add origin https://arekkas:[email protected]/ory/hydra-maester.git
- run: git push origin HEAD:master || true
release-changelog:
docker:
- image: circleci/ruby:2.5-node
steps:
- checkout
- run: gem install github_changelog_generator -v 1.14.3
- run: sudo npm i -g doctoc
- run: github_changelog_generator -u ory -p hydra-maester -o CHANGELOG.md --token $GITHUB_TOKEN
- run: doctoc CHANGELOG.md
- run: doctoc README.md
- run: git config --global user.email "[email protected]"
- run: git config --global user.name "ORY Continuous Integration"
- run: git add CHANGELOG.md
- run: git add README.md
- run: |
git commit -a -m "docs: Incorporates changes from version $(git describe --tags)" || true
- run: git remote rm origin
- run: git remote add origin https://arekkas:[email protected]/ory/hydra-maester.git
- run: git push origin HEAD:master || true

workflows:
version: 2
"test, build and release":
jobs:
- build:
filters:
tags:
only: /.*/
- test-integration:
filters:
tags:
only: /.*/
- test:
filters:
tags:
only: /.*/
- release:
requires:
- test
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- release-changelog:
requires:
- release
filters:
tags:
only: /.*/
branches:
ignore: /.*/
version: 2
"test, build and release":
jobs:
- build:
filters:
tags:
only: /.*/
- test-integration:
filters:
tags:
only: /.*/
- test:
filters:
tags:
only: /.*/
- release:
requires:
- build
- test
- test-integration
filters:
tags:
only: /.*/
branches:
ignore: /.*/
- release-changelog:
requires:
- release
filters:
tags:
only: /.*/
branches:
ignore: /.*/
33 changes: 29 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,39 @@ IMG ?= controller:latest
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true,crdVersions=v1"

run-with-cleanup = $(1) && $(2) || (ret=$$?; $(2) && exit $$ret)

all: manager

# Run tests
test: generate fmt vet manifests
go test ./api/... ./controllers/... ./hydra/... ./helpers/... -coverprofile cover.out

# Start KIND pseudo-cluster
kind-start:
GO111MODULE=on go get "sigs.k8s.io/[email protected]" && kind create cluster

# Stop KIND pseudo-cluster
kind-stop:
GO111MODULE=on go get "sigs.k8s.io/[email protected]" && kind delete cluster

# Deploy on KIND
# Ensures the controller image is built, deploys the image to KIND cluster along with necessary configuration
kind-deploy: manager manifests docker-build-notest kind-start
kubectl config set-context kind-kind
kind load docker-image controller:latest
kubectl apply -f config/crd/bases
kustomize build config/default | kubectl apply -f -

# private
kind-test: kind-deploy
kubectl config set-context kind-kind
go get github.com/onsi/ginkgo/ginkgo
ginkgo -v ./controllers/...

# Run integration tests on local KIND cluster
# TODO: modify once integration tests have been implemented
test-integration:
ginkgo -v ./controllers/...
$(call run-with-cleanup, $(MAKE) kind-test, $(MAKE) kind-stop)

# Build manager binary
manager: generate fmt vet
Expand Down Expand Up @@ -49,11 +72,13 @@ generate: controller-gen
$(CONTROLLER_GEN) object:headerFile=./hack/boilerplate.go.txt paths=./api/...

# Build the docker image
docker-build: test manager
docker-build-notest: manager
docker build . -t ${IMG}
@echo "updating kustomize image patch file for manager resource"
sed -i'' -e 's@image: .*@image: '"${IMG}"'@' ./config/default/manager_image_patch.yaml

docker-build: test docker-build-notest

# Push the docker image
docker-push:
docker push ${IMG}
Expand All @@ -63,7 +88,7 @@ docker-push:
controller-gen:
ifeq (, $(shell which controller-gen))
go get sigs.k8s.io/controller-tools/cmd/[email protected]
CONTROLLER_GEN=$(shell go env GOPATH)/bin/controller-gen
CONTROLLER_GEN=$(shell which controller-gen)
else
CONTROLLER_GEN=$(shell which controller-gen)
endif
Loading

0 comments on commit 0d726dd

Please sign in to comment.