Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2b8dddb
commit d113fe4
Showing
7 changed files
with
165 additions
and
0 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 |
---|---|---|
|
@@ -79,6 +79,7 @@ anaconda-mode/ | |
*.dll | ||
*.so | ||
*.dylib | ||
bin/ | ||
|
||
# Test binary, build with 'go test -c' | ||
*.test | ||
|
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,32 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# Reproducible builder image | ||
FROM openshift/origin-release:golang-1.10 as builder | ||
|
||
# Workaround a bug in imagebuilder (some versions) where this dir will not be auto-created. | ||
RUN mkdir -p /go/src/github.com/openshift/cluster-autoscaler-operator | ||
WORKDIR /go/src/github.com/openshift/cluster-autoscaler-operator | ||
|
||
# This expects that the context passed to the docker build command is | ||
# the cluster-autoscaler-operator directory. | ||
# e.g. docker build -t <tag> -f <this_Dockerfile> <path_to_cluster-autoscaler-operator> | ||
COPY . . | ||
RUN GOPATH=/go CGO_ENABLED=0 go install ./cmd/cluster-autoscaler-operator | ||
|
||
# Final container | ||
FROM openshift/origin-base | ||
RUN yum install -y ca-certificates | ||
|
||
COPY --from=builder /go/bin/cluster-autoscaler-operator / |
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,79 @@ | ||
# Copyright 2018 The Kubernetes Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
DBG ?= 0 | ||
VERSION ?= $(shell git describe --always --abbrev=7) | ||
MUTABLE_TAG ?= latest | ||
IMAGE = origin-cluster-autoscaler-operator | ||
|
||
ifeq ($(DBG),1) | ||
GOGCFLAGS ?= -gcflags=all="-N -l" | ||
endif | ||
|
||
.PHONY: all | ||
all: build images check | ||
|
||
NO_DOCKER ?= 0 | ||
ifeq ($(NO_DOCKER), 1) | ||
DOCKER_CMD = | ||
IMAGE_BUILD_CMD = imagebuilder | ||
else | ||
DOCKER_CMD := docker run --rm -v "$(PWD)":/go/src/github.com/openshift/cluster-autoscaler-operator:Z -w /go/src/github.com/openshift/cluster-autoscaler-operator openshift/origin-release:golang-1.10 | ||
IMAGE_BUILD_CMD = docker build | ||
endif | ||
|
||
.PHONY: depend | ||
depend: | ||
dep version || go get -u github.com/golang/dep/cmd/dep | ||
dep ensure | ||
|
||
.PHONY: depend-update | ||
depend-update: | ||
dep ensure -update | ||
|
||
.PHONY: build | ||
build: ## build binaries | ||
$(DOCKER_CMD) go build $(GOGCFLAGS) -o bin/cluster-autoscaler-operator github.com/openshift/cluster-autoscaler-operator/cmd/cluster-autoscaler-operator | ||
|
||
.PHONY: images | ||
images: ## Create images | ||
$(IMAGE_BUILD_CMD) -t "$(IMAGE):$(VERSION)" -t "$(IMAGE):$(MUTABLE_TAG)" ./ | ||
|
||
.PHONY: push | ||
push: | ||
docker push "$(IMAGE):$(VERSION)" | ||
docker push "$(IMAGE):$(MUTABLE_TAG)" | ||
|
||
.PHONY: check | ||
check: fmt vet lint test ## Check your code | ||
|
||
.PHONY: test | ||
test: # Run unit test | ||
$(DOCKER_CMD) go test -race -cover ./cmd/... ./cloud/... | ||
|
||
.PHONY: lint | ||
lint: ## Go lint your code | ||
hack/go-lint.sh -min_confidence 0.3 $(go list -f '{{ .ImportPath }}' ./...) | ||
|
||
.PHONY: fmt | ||
fmt: ## Go fmt your code | ||
hack/go-fmt.sh | ||
|
||
.PHONY: vet | ||
vet: ## Apply go vet to all go files | ||
hack/go-vet.sh ./... | ||
|
||
.PHONY: help | ||
help: | ||
@grep -E '^[a-zA-Z/0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' |
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,16 @@ | ||
#!/bin/sh | ||
|
||
REPO_NAME=$(basename "${PWD}") | ||
if [ "$IS_CONTAINER" != "" ]; then | ||
for TARGET in "${@}"; do | ||
find "${TARGET}" -name '*.go' ! -path '*/vendor/*' ! -path '*/.build/*' -exec gofmt -s -w {} \+ | ||
done | ||
git diff --exit-code | ||
else | ||
docker run -it --rm \ | ||
--env IS_CONTAINER=TRUE \ | ||
--volume "${PWD}:/go/src/github.com/openshift/${REPO_NAME}:z" \ | ||
--workdir "/go/src/github.com/openshift/${REPO_NAME}" \ | ||
openshift/origin-release:golang-1.10 \ | ||
./hack/go-fmt.sh "${@}" | ||
fi |
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,14 @@ | ||
#!/bin/sh | ||
# Example: ./hack/go-lint.sh installer/... pkg/... tests/smoke | ||
|
||
REPO_NAME=$(basename "${PWD}") | ||
if [ "$IS_CONTAINER" != "" ]; then | ||
golint -set_exit_status "${@}" | ||
else | ||
docker run --rm \ | ||
--env IS_CONTAINER=TRUE \ | ||
--volume "${PWD}:/go/src/github.com/openshift/${REPO_NAME}:z" \ | ||
--workdir "/go/src/github.com/openshift/${REPO_NAME}" \ | ||
openshift/origin-release:golang-1.10 \ | ||
./hack/go-lint.sh "${@}" | ||
fi |
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,12 @@ | ||
#!/bin/sh | ||
REPO_NAME=$(basename "${PWD}") | ||
if [ "$IS_CONTAINER" != "" ]; then | ||
go vet "${@}" | ||
else | ||
docker run --rm \ | ||
--env IS_CONTAINER=TRUE \ | ||
--volume "${PWD}:/go/src/github.com/openshift/${REPO_NAME}:z" \ | ||
--workdir "/go/src/github.com/openshift/${REPO_NAME}" \ | ||
openshift/origin-release:golang-1.10 \ | ||
./hack/go-vet.sh "${@}" | ||
fi; |
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,11 @@ | ||
#!/bin/sh | ||
if [ "$IS_CONTAINER" != "" ]; then | ||
yamllint --config-data "{extends: default, rules: {line-length: {level: warning, max: 120}}}" ./examples/ | ||
else | ||
docker run --rm \ | ||
--env IS_CONTAINER=TRUE \ | ||
--volume "${PWD}:/workdir:z" \ | ||
--entrypoint sh \ | ||
quay.io/coreos/yamllint \ | ||
./hack/yaml-lint.sh | ||
fi; |