Skip to content
This repository has been archived by the owner on Nov 16, 2022. It is now read-only.

Commit

Permalink
feat: Adding precommit hook and changes to Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
davidffrench authored and slaskawi committed Sep 16, 2019
1 parent 90798a3 commit fa80c7c
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 7 deletions.
7 changes: 7 additions & 0 deletions .githooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

# Run some pre commit checks on the Go source code.
echo "Running pre-commit checks on your code..."

# Format the Go code
make code/fix
33 changes: 26 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,28 @@
# Image build contants
REG=quay.io
ORG=keycloak
NAMESPACE=sso
PROJECT=keycloak-operator
REG=quay.io
SHELL=/bin/bash
TAG?=latest
PKG=github.com/keycloak/keycloak-operator

#Compile constants
COMPILE_TARGET=./tmp/_output/bin/$(PROJECT)
GOOS=linux
GOARCH=amd64
CGO_ENABLED=0

#Other contants
NAMESPACE=keycloak
PKG=github.com/keycloak/keycloak-operator
OPERATOR_SDK_VERSION=v0.10.0
OPERATOR_SDK_DOWNLOAD_URL=https://github.com/operator-framework/operator-sdk/releases/download/$(OPERATOR_SDK_VERSION)/operator-sdk-$(OPERATOR_SDK_VERSION)-x86_64-linux-gnu

.PHONY: setup
setup: setup/mod setup/githooks code/gen

.PHONY: setup/githooks
setup/githooks:
@echo Setting up Git hooks:
ln -sf $$PWD/.githooks/* $$PWD/.git/hooks/

.PHONY: setup/mod
setup/mod:
Expand All @@ -16,23 +33,25 @@ setup/mod:
.PHONY: setup/travis
setup/travis:
@echo Installing Operator SDK
@curl -Lo operator-sdk https://github.com/operator-framework/operator-sdk/releases/download/v0.10.0/operator-sdk-v0.10.0-x86_64-linux-gnu && chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin/
@curl -Lo operator-sdk ${OPERATOR_SDK_DOWNLOAD_URL} && chmod +x operator-sdk && sudo mv operator-sdk /usr/local/bin/

.PHONY: code/run
code/run:
@operator-sdk up local --namespace=${NAMESPACE}

.PHONY: code/compile
code/compile:
@GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o=$(COMPILE_TARGET) ./cmd/manager
@GOOS=${GOOS} GOARCH=${GOARCH} CGO_ENABLED=${CGO_ENABLED} go build -o=$(COMPILE_TARGET) ./cmd/manager

.PHONY: code/gen
code/gen:
operator-sdk generate k8s
operator-sdk generate openapi

.PHONY: code/check
code/check:
@diff -u <(echo -n) <(gofmt -d `find . -type f -name '*.go' -not -path "./vendor/*"`)
@echo go fmt
go fmt $$(go list ./... | grep -v /vendor/)

.PHONY: code/fix
code/fix:
Expand Down

0 comments on commit fa80c7c

Please sign in to comment.