Skip to content

Commit a24eeca

Browse files
authored
Add license header (#36)
Signed-off-by: Tamal Saha <[email protected]>
1 parent 4186c47 commit a24eeca

File tree

194 files changed

+20995
-13973
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

194 files changed

+20995
-13973
lines changed

.github/workflows/ci.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches-ignore:
6+
- 'release-*'
7+
tags-ignore:
8+
- '*.*'
9+
10+
jobs:
11+
12+
build:
13+
name: Build
14+
runs-on: ubuntu-latest
15+
steps:
16+
17+
- name: Check out code into the Go module directory
18+
uses: actions/checkout@v1
19+
20+
- name: Run checks
21+
run: |
22+
sudo apt-get -qq update
23+
sudo apt-get install -y bzr
24+
make ci

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,8 @@ dist/
2828
**/.env
2929
.vscode/
3030
coverage.txt
31-
apiserver.local.config/
31+
32+
/bin
33+
/.go
34+
35+
apiserver.local.config/**

.travis.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

Makefile

Lines changed: 273 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,273 @@
1+
# Copyright 2019 AppsCode Inc.
2+
# Copyright 2016 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
SHELL=/bin/bash -o pipefail
17+
18+
GO_PKG := kmodules.xyz
19+
REPO := $(notdir $(shell pwd))
20+
BIN := webhook-runtime
21+
22+
# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
23+
CRD_OPTIONS ?= "crd:trivialVersions=true"
24+
# https://github.com/appscodelabs/gengo-builder
25+
CODE_GENERATOR_IMAGE ?= appscode/gengo:release-1.14
26+
API_GROUPS ?= kubedb:v1alpha1 catalog:v1alpha1 config:v1alpha1
27+
28+
# This version-strategy uses git tags to set the version string
29+
git_branch := $(shell git rev-parse --abbrev-ref HEAD)
30+
git_tag := $(shell git describe --exact-match --abbrev=0 2>/dev/null || echo "")
31+
commit_hash := $(shell git rev-parse --verify HEAD)
32+
commit_timestamp := $(shell date --date="@$$(git show -s --format=%ct)" --utc +%FT%T)
33+
34+
VERSION := $(shell git describe --tags --always --dirty)
35+
version_strategy := commit_hash
36+
ifdef git_tag
37+
VERSION := $(git_tag)
38+
version_strategy := tag
39+
else
40+
ifeq (,$(findstring $(git_branch),master HEAD))
41+
ifneq (,$(patsubst release-%,,$(git_branch)))
42+
VERSION := $(git_branch)
43+
version_strategy := branch
44+
endif
45+
endif
46+
endif
47+
48+
###
49+
### These variables should not need tweaking.
50+
###
51+
52+
SRC_PKGS := admission apis client registry runtime
53+
SRC_DIRS := $(SRC_PKGS) # directories which hold app source (not vendored)
54+
55+
DOCKER_PLATFORMS := linux/amd64 linux/arm linux/arm64
56+
BIN_PLATFORMS := $(DOCKER_PLATFORMS) windows/amd64 darwin/amd64
57+
58+
# Used internally. Users should pass GOOS and/or GOARCH.
59+
OS := $(if $(GOOS),$(GOOS),$(shell go env GOOS))
60+
ARCH := $(if $(GOARCH),$(GOARCH),$(shell go env GOARCH))
61+
62+
BASEIMAGE_PROD ?= gcr.io/distroless/static
63+
BASEIMAGE_DBG ?= debian:stretch
64+
65+
GO_VERSION ?= 1.12.12
66+
BUILD_IMAGE ?= appscode/golang-dev:$(GO_VERSION)-stretch
67+
68+
OUTBIN = bin/$(OS)_$(ARCH)/$(BIN)
69+
ifeq ($(OS),windows)
70+
OUTBIN = bin/$(OS)_$(ARCH)/$(BIN).exe
71+
endif
72+
73+
# Directories that we need created to build/test.
74+
BUILD_DIRS := bin/$(OS)_$(ARCH) \
75+
.go/bin/$(OS)_$(ARCH) \
76+
.go/cache \
77+
hack/config \
78+
$(HOME)/.credentials \
79+
$(HOME)/.kube \
80+
$(HOME)/.minikube
81+
82+
# If you want to build all binaries, see the 'all-build' rule.
83+
# If you want to build all containers, see the 'all-container' rule.
84+
# If you want to build AND push all containers, see the 'all-push' rule.
85+
all: fmt build
86+
87+
# For the following OS/ARCH expansions, we transform OS/ARCH into OS_ARCH
88+
# because make pattern rules don't match with embedded '/' characters.
89+
90+
build-%:
91+
@$(MAKE) build \
92+
--no-print-directory \
93+
GOOS=$(firstword $(subst _, ,$*)) \
94+
GOARCH=$(lastword $(subst _, ,$*))
95+
96+
all-build: $(addprefix build-, $(subst /,_, $(BIN_PLATFORMS)))
97+
98+
version:
99+
@echo version=$(VERSION)
100+
@echo version_strategy=$(version_strategy)
101+
@echo git_tag=$(git_tag)
102+
@echo git_branch=$(git_branch)
103+
@echo commit_hash=$(commit_hash)
104+
@echo commit_timestamp=$(commit_timestamp)
105+
106+
DOCKER_REPO_ROOT := /go/src/$(GO_PKG)/$(REPO)
107+
108+
# Generate a typed clientset
109+
.PHONY: clientset
110+
clientset:
111+
@docker run --rm \
112+
-u $$(id -u):$$(id -g) \
113+
-v /tmp:/.cache \
114+
-v $$(pwd):$(DOCKER_REPO_ROOT) \
115+
-w $(DOCKER_REPO_ROOT) \
116+
--env HTTP_PROXY=$(HTTP_PROXY) \
117+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
118+
$(CODE_GENERATOR_IMAGE) \
119+
deepcopy-gen \
120+
--go-header-file "./hack/license/go.txt" \
121+
--input-dirs "$(GO_PKG)/$(REPO)/apis/workload/v1" \
122+
--output-file-base zz_generated.deepcopy
123+
124+
.PHONY: gen
125+
gen: clientset
126+
127+
fmt: $(BUILD_DIRS)
128+
@docker run \
129+
-i \
130+
--rm \
131+
-u $$(id -u):$$(id -g) \
132+
-v $$(pwd):/src \
133+
-w /src \
134+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
135+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
136+
-v $$(pwd)/.go/cache:/.cache \
137+
--env HTTP_PROXY=$(HTTP_PROXY) \
138+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
139+
$(BUILD_IMAGE) \
140+
/bin/bash -c " \
141+
REPO_PKG=$(GO_PKG) \
142+
./hack/fmt.sh $(SRC_DIRS) \
143+
"
144+
145+
build: $(OUTBIN)
146+
147+
.PHONY: .go/$(OUTBIN)
148+
$(OUTBIN): $(BUILD_DIRS)
149+
@echo "making $(OUTBIN)"
150+
@docker run \
151+
-i \
152+
--rm \
153+
-u $$(id -u):$$(id -g) \
154+
-v $$(pwd):/src \
155+
-w /src \
156+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
157+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
158+
-v $$(pwd)/.go/cache:/.cache \
159+
--env HTTP_PROXY=$(HTTP_PROXY) \
160+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
161+
$(BUILD_IMAGE) \
162+
/bin/bash -c " \
163+
ARCH=$(ARCH) \
164+
OS=$(OS) \
165+
VERSION=$(VERSION) \
166+
version_strategy=$(version_strategy) \
167+
git_branch=$(git_branch) \
168+
git_tag=$(git_tag) \
169+
commit_hash=$(commit_hash) \
170+
commit_timestamp=$(commit_timestamp) \
171+
./hack/build.sh \
172+
"
173+
@echo
174+
175+
.PHONY: test
176+
test: unit-tests
177+
178+
unit-tests: $(BUILD_DIRS)
179+
@docker run \
180+
-i \
181+
--rm \
182+
-u $$(id -u):$$(id -g) \
183+
-v $$(pwd):/src \
184+
-w /src \
185+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
186+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
187+
-v $$(pwd)/.go/cache:/.cache \
188+
--env HTTP_PROXY=$(HTTP_PROXY) \
189+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
190+
$(BUILD_IMAGE) \
191+
/bin/bash -c " \
192+
ARCH=$(ARCH) \
193+
OS=$(OS) \
194+
VERSION=$(VERSION) \
195+
./hack/test.sh $(SRC_DIRS) \
196+
"
197+
198+
ADDTL_LINTERS := goconst,gofmt,goimports,unparam
199+
200+
.PHONY: lint
201+
lint: $(BUILD_DIRS)
202+
@echo "running linter"
203+
@docker run \
204+
-i \
205+
--rm \
206+
-u $$(id -u):$$(id -g) \
207+
-v $$(pwd):/src \
208+
-w /src \
209+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin \
210+
-v $$(pwd)/.go/bin/$(OS)_$(ARCH):/go/bin/$(OS)_$(ARCH) \
211+
-v $$(pwd)/.go/cache:/.cache \
212+
--env HTTP_PROXY=$(HTTP_PROXY) \
213+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
214+
--env GO111MODULE=on \
215+
--env GOFLAGS="-mod=vendor" \
216+
$(BUILD_IMAGE) \
217+
golangci-lint run --enable $(ADDTL_LINTERS) --timeout=10m --skip-files="generated.*\.go$\" --skip-dirs-use-default
218+
219+
$(BUILD_DIRS):
220+
@mkdir -p $@
221+
222+
.PHONY: dev
223+
dev: gen fmt push
224+
225+
.PHONY: verify
226+
verify: verify-modules verify-gen
227+
228+
.PHONY: verify-modules
229+
verify-modules:
230+
GO111MODULE=on go mod tidy
231+
GO111MODULE=on go mod vendor
232+
@if !(git diff --exit-code HEAD); then \
233+
echo "go module files are out of date"; exit 1; \
234+
fi
235+
236+
.PHONY: verify-gen
237+
verify-gen: gen fmt
238+
@if !(git diff --exit-code HEAD); then \
239+
echo "generated files are out of date, run make gen"; exit 1; \
240+
fi
241+
242+
.PHONY: add-license
243+
add-license:
244+
@echo "Adding license header"
245+
@docker run --rm \
246+
-u $$(id -u):$$(id -g) \
247+
-v /tmp:/.cache \
248+
-v $$(pwd):$(DOCKER_REPO_ROOT) \
249+
-w $(DOCKER_REPO_ROOT) \
250+
--env HTTP_PROXY=$(HTTP_PROXY) \
251+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
252+
$(BUILD_IMAGE) \
253+
ltag -t "./hack/license" --excludes "vendor contrib probe" -v
254+
255+
.PHONY: check-license
256+
check-license:
257+
@echo "Checking files for license header"
258+
@docker run --rm \
259+
-u $$(id -u):$$(id -g) \
260+
-v /tmp:/.cache \
261+
-v $$(pwd):$(DOCKER_REPO_ROOT) \
262+
-w $(DOCKER_REPO_ROOT) \
263+
--env HTTP_PROXY=$(HTTP_PROXY) \
264+
--env HTTPS_PROXY=$(HTTPS_PROXY) \
265+
$(BUILD_IMAGE) \
266+
ltag -t "./hack/license" --excludes "vendor contrib probe" --check -v
267+
268+
.PHONY: ci
269+
ci: verify check-license lint build unit-tests #cover
270+
271+
.PHONY: clean
272+
clean:
273+
rm -rf .go bin

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[![Go Report Card](https://goreportcard.com/badge/kmodules.xyz/webhook-runtime)](https://goreportcard.com/report/kmodules.xyz/webhook-runtime)
22
[![GoDoc](https://godoc.org/kmodules.xyz/webhook-runtime?status.svg "GoDoc")](https://godoc.org/kmodules.xyz/webhook-runtime)
3-
[![Build Status](https://travis-ci.org/kmodules/webhook-runtime.svg?branch=master)](https://travis-ci.org/kmodules/webhook-runtime)
3+
[![Build Status](https://github.com/kmodules/webhook-runtime/workflows/CI/badge.svg)](https://github.com/kmodules/webhook-runtime/actions?workflow=CI)
44
[![codecov](https://codecov.io/gh/kmodules/webhook-runtime/branch/master/graph/badge.svg)](https://codecov.io/gh/kmodules/webhook-runtime)
55
[![Slack](https://slack.appscode.com/badge.svg)](https://slack.appscode.com)
66
[![Twitter](https://img.shields.io/twitter/follow/appscodehq.svg?style=social&logo=twitter&label=Follow)](https://twitter.com/intent/follow?screen_name=AppsCodeHQ)

admission/handler.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
Copyright The Kmodules Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
116
package admission
217

318
import "k8s.io/apimachinery/pkg/runtime"

admission/v1beta1/errors.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/*
2+
Copyright The Kmodules Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
116
package v1beta1
217

318
import (

0 commit comments

Comments
 (0)