-
Notifications
You must be signed in to change notification settings - Fork 20
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
Yu Cao
committed
May 5, 2020
1 parent
2feedbc
commit 40ede04
Showing
18 changed files
with
869 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
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 @@ | ||
governance-policy-spec-sync |
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 @@ | ||
1.0.0 |
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,144 @@ | ||
# Copyright 2019 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. | ||
|
||
# This repo is build in Travis-ci by default; | ||
# Override this variable in local env. | ||
TRAVIS_BUILD ?= 1 | ||
|
||
# Image URL to use all building/pushing image targets; | ||
# Use your own docker registry and image name for dev/test by overridding the IMG and REGISTRY environment variable. | ||
IMG ?= $(shell cat COMPONENT_NAME 2> /dev/null) | ||
REGISTRY ?= quay.io/open-cluster-management | ||
|
||
# Github host to use for checking the source tree; | ||
# Override this variable ue with your own value if you're working on forked repo. | ||
GIT_HOST ?= github.com/open-cluster-management | ||
|
||
PWD := $(shell pwd) | ||
BASE_DIR := $(shell basename $(PWD)) | ||
|
||
# Keep an existing GOPATH, make a private one if it is undefined | ||
GOPATH_DEFAULT := $(PWD)/.go | ||
export GOPATH ?= $(GOPATH_DEFAULT) | ||
GOBIN_DEFAULT := $(GOPATH)/bin | ||
export GOBIN ?= $(GOBIN_DEFAULT) | ||
TESTARGS_DEFAULT := "-v" | ||
export TESTARGS ?= $(TESTARGS_DEFAULT) | ||
DEST ?= $(GOPATH)/src/$(GIT_HOST)/$(BASE_DIR) | ||
VERSION ?= $(shell cat COMPONENT_VERSION 2> /dev/null) | ||
IMAGE_NAME_AND_VERSION ?= $(REGISTRY)/$(IMG) | ||
|
||
|
||
LOCAL_OS := $(shell uname) | ||
ifeq ($(LOCAL_OS),Linux) | ||
TARGET_OS ?= linux | ||
XARGS_FLAGS="-r" | ||
else ifeq ($(LOCAL_OS),Darwin) | ||
TARGET_OS ?= darwin | ||
XARGS_FLAGS= | ||
else | ||
$(error "This system's OS $(LOCAL_OS) isn't recognized/supported") | ||
endif | ||
|
||
.PHONY: fmt lint test coverage build build-images | ||
|
||
ifneq ("$(realpath $(DEST))", "$(realpath $(PWD))") | ||
$(error Please run 'make' from $(DEST). Current directory is $(PWD)) | ||
endif | ||
|
||
# GITHUB_USER containing '@' char must be escaped with '%40' | ||
GITHUB_USER := $(shell echo $(GITHUB_USER) | sed 's/@/%40/g') | ||
GITHUB_TOKEN ?= | ||
|
||
USE_VENDORIZED_BUILD_HARNESS ?= | ||
|
||
ifndef USE_VENDORIZED_BUILD_HARNESS | ||
ifeq ($(TRAVIS_BUILD),1) | ||
-include $(shell curl -H 'Authorization: token ${GITHUB_TOKEN}' -H 'Accept: application/vnd.github.v4.raw' -L https://api.github.com/repos/open-cluster-management/build-harness-extensions/contents/templates/Makefile.build-harness-bootstrap -o .build-harness-bootstrap; echo .build-harness-bootstrap) | ||
endif | ||
else | ||
-include vbh/.build-harness-vendorized | ||
endif | ||
|
||
default:: | ||
@echo "Build Harness Bootstrapped" | ||
|
||
include build/common/Makefile.common.mk | ||
|
||
############################################################ | ||
# work section | ||
############################################################ | ||
$(GOBIN): | ||
@echo "create gobin" | ||
@mkdir -p $(GOBIN) | ||
|
||
work: $(GOBIN) | ||
|
||
############################################################ | ||
# format section | ||
############################################################ | ||
|
||
# All available format: format-go format-protos format-python | ||
# Default value will run all formats, override these make target with your requirements: | ||
# eg: fmt: format-go format-protos | ||
fmt: format-go format-protos format-python | ||
|
||
############################################################ | ||
# check section | ||
############################################################ | ||
|
||
check: lint | ||
|
||
# All available linters: lint-dockerfiles lint-scripts lint-yaml lint-copyright-banner lint-go lint-python lint-helm lint-markdown lint-sass lint-typescript lint-protos | ||
# Default value will run all linters, override these make target with your requirements: | ||
# eg: lint: lint-go lint-yaml | ||
lint: lint-all | ||
|
||
############################################################ | ||
# test section | ||
############################################################ | ||
|
||
test: | ||
@go test ${TESTARGS} ./... | ||
|
||
############################################################ | ||
# coverage section | ||
############################################################ | ||
|
||
coverage: | ||
@build/common/scripts/codecov.sh | ||
|
||
############################################################ | ||
# build section | ||
############################################################ | ||
|
||
build: | ||
@build/common/scripts/gobuild.sh build/_output/bin/$(IMG) ./cmd/manager | ||
|
||
local: | ||
@GOOS=darwin build/common/scripts/gobuild.sh build/_output/bin/$(IMG) ./cmd/manager | ||
|
||
############################################################ | ||
# images section | ||
############################################################ | ||
|
||
build-images: | ||
@operator-sdk build ${IMAGE_NAME_AND_VERSION} | ||
@docker tag ${IMAGE_NAME_AND_VERSION} $(REGISTRY)/$(IMG):latest | ||
|
||
############################################################ | ||
# clean section | ||
############################################################ | ||
clean:: | ||
rm -f build/_output/bin/$(IMG) |
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,63 @@ | ||
# Copyright 2019 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. | ||
|
||
############################################################ | ||
# GKE section | ||
############################################################ | ||
PROJECT ?= oceanic-guard-191815 | ||
ZONE ?= us-west1-a | ||
CLUSTER ?= prow | ||
|
||
activate-serviceaccount: | ||
ifdef GOOGLE_APPLICATION_CREDENTIALS | ||
gcloud auth activate-service-account --key-file="$(GOOGLE_APPLICATION_CREDENTIALS)" | ||
endif | ||
|
||
get-cluster-credentials: activate-serviceaccount | ||
gcloud container clusters get-credentials "$(CLUSTER)" --project="$(PROJECT)" --zone="$(ZONE)" | ||
|
||
config-docker: get-cluster-credentials | ||
@build/common/scripts/config_docker.sh | ||
|
||
FINDFILES=find . \( -path ./.git -o -path ./.github \) -prune -o -type f | ||
XARGS = xargs -0 ${XARGS_FLAGS} | ||
CLEANXARGS = xargs ${XARGS_FLAGS} | ||
|
||
|
||
lint-dockerfiles: | ||
@${FINDFILES} -name 'Dockerfile*' -print0 | ${XARGS} hadolint -c ./build/common/config/.hadolint.yml | ||
|
||
lint-scripts: | ||
@${FINDFILES} -name '*.sh' -print0 | ${XARGS} shellcheck -e SC2001 | ||
|
||
lint-yaml: | ||
@${FINDFILES} \( -name '*.yml' -o -name '*.yaml' \) -print0 | ${XARGS} grep -L -e "{{" | ${CLEANXARGS} yamllint -c ./build/common/config/.yamllint.yml | ||
|
||
lint-copyright-banner: | ||
@${FINDFILES} \( -name '*.go' -o -name '*.cc' -o -name '*.h' -o -name '*.proto' -o -name '*.py' -o -name '*.sh' \) \( ! \( -name '*.gen.go' -o -name '*.pb.go' -o -name '*_pb2.py' \) \) -print0 |\ | ||
${XARGS} build/common/scripts/lint_copyright_banner.sh | ||
|
||
lint-go: | ||
@${FINDFILES} -name '*.go' \( ! \( -name '*.gen.go' -o -name '*.pb.go' \) \) -print0 | ${XARGS} build/common/scripts/lint_go.sh | ||
|
||
lint-markdown: | ||
@${FINDFILES} -name '*.md' -print0 | ${XARGS} mdl --ignore-front-matter --style build/common/config/mdl.rb | ||
@${FINDFILES} -name '*.md' -print0 | ${XARGS} awesome_bot --skip-save-results --allow_ssl --allow-timeout --allow-dupe --allow-redirect --white-list ${MARKDOWN_LINT_WHITELIST} | ||
|
||
lint-all: lint-yaml lint-go | ||
|
||
format-go: | ||
@${FINDFILES} -name '*.go' \( ! \( -name '*.gen.go' -o -name '*.pb.go' \) \) -print0 | ${XARGS} goimports -w -local "github.com/open-cluster-management" | ||
|
||
.PHONY: lint-dockerfiles lint-scripts lint-yaml lint-copyright-banner lint-go lint-markdown lint-all format-go config-docker |
Oops, something went wrong.