Skip to content

Commit 7146397

Browse files
abayertekton-robot
authored andcommitted
Bump Pipeline, k8s, and Knative dependencies
This change uses non-tagged commits from `knative.dev/serving` and `knative.dev/eventing` because their `v0.31.0` releases require a minimum k8s cluster version of 1.22, and I wanted to avoid requiring that if at all possible. Instead, we depend on the latest commit in each before they changed to depending on a `knative.dev/pkg` commit newer than the one Pipeline depends on. Also add a Makefile, sync `.golangci.yml` with Pipeline's (other than requiring comments for exported functions/types/etc, which I'll come back and do in a followup), and fix some new-as-a-result linter issues. Signed-off-by: Andrew Bayer <[email protected]>
1 parent 693f951 commit 7146397

File tree

819 files changed

+60754
-8827
lines changed

Some content is hidden

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

819 files changed

+60754
-8827
lines changed

.gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,15 @@
3939

4040
# Python
4141
*.pyc
42+
43+
# Release-generated source archives, just in case they get committed
44+
# accidentally.
45+
cmd/*/kodata/source.tar.gz
46+
47+
# binaries
48+
/.bin/
49+
/bin/
50+
51+
# Temporary GOPATH used during code gen if user's Tekton checkout is
52+
# not already in GOPATH.
53+
.gopath

.golangci.yml

+16
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,30 @@ run:
55
- vendor
66
- pkg/client/clientset/(.*)/fake
77
- pkg/client/injection
8+
skip-files:
9+
- .*/zz_generated.deepcopy.go
10+
- pkg/apis/triggers/v1beta1/openapi_generated.go
811
linters-settings:
912
errcheck:
1013
exclude: .errcheck.txt
1114
linters:
1215
enable:
16+
- deadcode
1317
- errcheck
1418
- gofmt
1519
- goimports
20+
- gomodguard
1621
- gosec
1722
- gocritic
1823
- revive
24+
- misspell
25+
- unconvert
26+
issues:
27+
exclude-rules:
28+
- path: _test\.go
29+
linters:
30+
- errcheck
31+
- gosec
32+
max-issues-per-linter: 0
33+
max-same-issues: 0
34+
# TODO(abayer): Enable off-by-default rules for revive requiring that all exported elements have a properly formatted comment, like we do in Pipeline.

Makefile

+200
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
MODULE = $(shell env GO111MODULE=on $(GO) list -m)
2+
DATE ?= $(shell date +%FT%T%z)
3+
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || \
4+
cat $(CURDIR)/.version 2> /dev/null || echo v0)
5+
PKGS = $(or $(PKG),$(shell env GO111MODULE=on $(GO) list ./... | grep -v 'github\.com\/tektoncd\/triggers\/third_party\/'))
6+
TESTPKGS = $(shell env GO111MODULE=on $(GO) list -f \
7+
'{{ if or .TestGoFiles .XTestGoFiles }}{{ .ImportPath }}{{ end }}' \
8+
$(PKGS))
9+
BIN = $(CURDIR)/.bin
10+
11+
GOLANGCI_VERSION = v1.42.0
12+
13+
GO = go
14+
TIMEOUT_UNIT = 5m
15+
TIMEOUT_E2E = 20m
16+
V = 0
17+
Q = $(if $(filter 1,$V),,@)
18+
M = $(shell printf "\033[34;1m🐱\033[0m")
19+
20+
export GO111MODULE=on
21+
22+
COMMANDS=$(patsubst cmd/%,%,$(wildcard cmd/*))
23+
BINARIES=$(addprefix bin/,$(COMMANDS))
24+
25+
.PHONY: all
26+
all: fmt $(BINARIES) | $(BIN) ; $(info $(M) building executable…) @ ## Build program binary
27+
28+
$(BIN):
29+
@mkdir -p $@
30+
$(BIN)/%: | $(BIN) ; $(info $(M) building $(PACKAGE)…)
31+
$Q tmp=$$(mktemp -d); \
32+
env GO111MODULE=off GOPATH=$$tmp GOBIN=$(BIN) $(GO) get $(PACKAGE) \
33+
|| ret=$$?; \
34+
rm -rf $$tmp ; exit $$ret
35+
36+
FORCE:
37+
38+
bin/%: cmd/% FORCE
39+
$Q $(GO) build -mod=vendor $(LDFLAGS) -v -o $@ ./$<
40+
41+
.PHONY: cross
42+
cross: amd64 arm arm64 s390x ppc64le ## build cross platform binaries
43+
44+
.PHONY: amd64
45+
amd64:
46+
GOOS=linux GOARCH=amd64 go build -mod=vendor $(LDFLAGS) ./cmd/...
47+
48+
.PHONY: arm
49+
arm:
50+
GOOS=linux GOARCH=arm go build -mod=vendor $(LDFLAGS) ./cmd/...
51+
52+
.PHONY: arm64
53+
arm64:
54+
GOOS=linux GOARCH=arm64 go build -mod=vendor $(LDFLAGS) ./cmd/...
55+
56+
.PHONY: s390x
57+
s390x:
58+
GOOS=linux GOARCH=s390x go build -mod=vendor $(LDFLAGS) ./cmd/...
59+
60+
.PHONY: ppc64le
61+
ppc64le:
62+
GOOS=linux GOARCH=ppc64le go build -mod=vendor $(LDFLAGS) ./cmd/...
63+
64+
KO = $(or ${KO_BIN},${KO_BIN},$(BIN)/ko)
65+
$(BIN)/ko: PACKAGE=github.com/google/ko
66+
67+
.PHONY: apply
68+
apply: | $(KO) ; $(info $(M) ko apply -R -f config/) @ ## Apply config to the current cluster
69+
$Q $(KO) apply -R -f config
70+
71+
.PHONY: resolve
72+
resolve: | $(KO) ; $(info $(M) ko resolve -R -f config/) @ ## Resolve config to the current cluster
73+
$Q $(KO) resolve --push=false --oci-layout-path=$(BIN)/oci -R -f config
74+
75+
.PHONY: generated
76+
generated: | vendor ; $(info $(M) update generated files) ## Update generated files
77+
$Q ./hack/update-codegen.sh
78+
79+
.PHONY: vendor
80+
vendor:
81+
$Q ./hack/update-deps.sh
82+
83+
## Tests
84+
TEST_UNIT_TARGETS := test-unit-verbose test-unit-race
85+
test-unit-verbose: ARGS=-v
86+
test-unit-race: ARGS=-race
87+
$(TEST_UNIT_TARGETS): test-unit
88+
.PHONY: $(TEST_UNIT_TARGETS) test-unit
89+
test-unit: ## Run unit tests
90+
$(GO) test -timeout $(TIMEOUT_UNIT) $(ARGS) ./...
91+
92+
TEST_E2E_TARGETS := test-e2e-short test-e2e-verbose test-e2e-race
93+
test-e2e-short: ARGS=-short
94+
test-e2e-verbose: ARGS=-v
95+
test-e2e-race: ARGS=-race
96+
$(TEST_E2E_TARGETS): test-e2e
97+
.PHONY: $(TEST_E2E_TARGETS) test-e2e
98+
test-e2e: ## Run end-to-end tests
99+
$(GO) test -timeout $(TIMEOUT_E2E) -tags e2e $(ARGS) ./test/...
100+
101+
.PHONY: test-yamls
102+
test-yamls: ## Run yaml tests
103+
./test/e2e-tests-yaml.sh --run-tests
104+
105+
.PHONY: check tests
106+
check tests: test-unit test-e2e test-yamls
107+
108+
RAM = $(BIN)/ram
109+
$(BIN)/ram: PACKAGE=go.sbr.pm/ram
110+
111+
.PHONY: watch-test
112+
watch-test: | $(RAM) ; $(info $(M) watch and run tests) @ ## Watch and run tests
113+
$Q $(RAM) -- -failfast
114+
115+
.PHONY: watch-resolve
116+
watch-resolve: | $(KO) ; $(info $(M) watch and resolve config) @ ## Watch and build to the current cluster
117+
$Q $(KO) resolve -W --push=false --oci-layout-path=$(BIN)/oci -f config 1>/dev/null
118+
119+
.PHONY: watch-config
120+
watch-config: | $(KO) ; $(info $(M) watch and apply config) @ ## Watch and apply to the current cluster
121+
$Q $(KO) apply -W -f config
122+
123+
## Linters configuration and targets
124+
# TODO(vdemeester) gofmt and goimports checks (run them with -w and make a diff)
125+
126+
GOLINT = $(BIN)/golint
127+
$(BIN)/golint: PACKAGE=golang.org/x/lint/golint
128+
129+
.PHONY: golint
130+
golint: | $(GOLINT) ; $(info $(M) running golint…) @ ## Run golint
131+
$Q $(GOLINT) -set_exit_status $(PKGS)
132+
133+
.PHONY: vet
134+
vet: | ; $(info $(M) running go vet…) @ ## Run go vet
135+
$Q go vet ./...
136+
137+
INEFFASSIGN = $(BIN)/ineffassign
138+
$(BIN)/ineffassign: PACKAGE=github.com/gordonklaus/ineffassign
139+
140+
.PHONY: ineffassign
141+
ineffassign: | $(INEFFASSIGN) ; $(info $(M) running static ineffassign…) @ ## Run ineffassign
142+
$Q $(INEFFASSIGN) .
143+
144+
STATICCHECK = $(BIN)/staticcheck
145+
$(BIN)/staticcheck: PACKAGE=honnef.co/go/tools/cmd/staticcheck
146+
147+
.PHONY: staticcheck
148+
staticcheck: | $(STATICCHECK) ; $(info $(M) running static check…) @ ## Run staticcheck
149+
$Q $(STATICCHECK) ./...
150+
151+
DUPL = $(BIN)/dupl
152+
$(BIN)/dupl: PACKAGE=github.com/mibk/dupl
153+
154+
.PHONY: dupl
155+
dupl: | $(DUPL) ; $(info $(M) running dupl…) ## Run dupl
156+
$Q $(DUPL)
157+
158+
ERRCHECK = $(BIN)/errcheck
159+
$(BIN)/errcheck: PACKAGE=github.com/kisielk/errcheck
160+
161+
.PHONY: errcheck
162+
errcheck: | $(ERRCHECK) ; $(info $(M) running errcheck…) ## Run errcheck
163+
$Q $(ERRCHECK) ./...
164+
165+
GOLANGCILINT = $(BIN)/golangci-lint
166+
$(BIN)/golangci-lint: ; $(info $(M) getting golangci-lint $(GOLANGCI_VERSION))
167+
cd tools; GOBIN=$(BIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_VERSION)
168+
169+
.PHONY: golangci-lint
170+
golangci-lint: | $(GOLANGCILINT) ; $(info $(M) running golangci-lint…) @ ## Run golangci-lint
171+
$Q $(GOLANGCILINT) run --modules-download-mode=vendor --max-issues-per-linter=0 --max-same-issues=0 --deadline 5m
172+
173+
GOIMPORTS = $(BIN)/goimports
174+
$(BIN)/goimports: PACKAGE=golang.org/x/tools/cmd/goimports
175+
176+
.PHONY: goimports
177+
goimports: | $(GOIMPORTS) ; $(info $(M) running goimports…) ## Run goimports
178+
$Q $(GOIMPORTS) -l -e -w pkg cmd test
179+
180+
.PHONY: fmt
181+
fmt: ; $(info $(M) running gofmt…) @ ## Run gofmt on all source files
182+
$Q $(GO) fmt $(PKGS)
183+
184+
# Misc
185+
186+
.PHONY: clean
187+
clean: ; $(info $(M) cleaning…) @ ## Cleanup everything
188+
@rm -rf $(BIN)
189+
@rm -rf bin
190+
@rm -rf test/tests.* test/coverage.*
191+
192+
.PHONY: help
193+
help:
194+
@grep -hE '^[ a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
195+
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-17s\033[0m %s\n", $$1, $$2}'
196+
197+
.PHONY: version
198+
version:
199+
200+
@echo $(VERSION)

cmd/controller/main.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ var (
4646
writeTimeOut = flag.Int64("el-writetimeout", elresources.DefaultWriteTimeout, "The write timeout for EventListener Server.")
4747
idleTimeOut = flag.Int64("el-idletimeout", elresources.DefaultIdleTimeout, "The idle timeout for EventListener Server.")
4848
timeOutHandler = flag.Int64("el-timeouthandler", elresources.DefaultTimeOutHandler, "The timeout for Timeout Handler of EventListener Server.")
49-
httpClientReadTimeOut = flag.Int64("el-httpclient-readtimeout", int64(elresources.DefaultHTTPClientReadTimeOut),
49+
httpClientReadTimeOut = flag.Int64("el-httpclient-readtimeout", elresources.DefaultHTTPClientReadTimeOut,
5050
"The HTTP Client read timeout for EventListener Server.")
51-
httpClientKeepAlive = flag.Int64("el-httpclient-keep-alive", int64(elresources.DefaultHTTPClientKeepAlive),
51+
httpClientKeepAlive = flag.Int64("el-httpclient-keep-alive", elresources.DefaultHTTPClientKeepAlive,
5252
"The HTTP Client read timeout for EventListener Server.")
53-
httpClientTLSHandshakeTimeout = flag.Int64("el-httpclient-tlshandshaketimeout", int64(elresources.DefaultHTTPClientTLSHandshakeTimeout),
53+
httpClientTLSHandshakeTimeout = flag.Int64("el-httpclient-tlshandshaketimeout", elresources.DefaultHTTPClientTLSHandshakeTimeout,
5454
"The HTTP Client read timeout for EventListener Server.")
55-
httpClientResponseHeaderTimeout = flag.Int64("el-httpclient-responseheadertimeout", int64(elresources.DefaultHTTPClientResponseHeaderTimeout),
55+
httpClientResponseHeaderTimeout = flag.Int64("el-httpclient-responseheadertimeout", elresources.DefaultHTTPClientResponseHeaderTimeout,
5656
"The HTTP Client read timeout for EventListener Server.")
57-
httpClientExpectContinueTimeout = flag.Int64("el-httpclient-expectcontinuetimeout", int64(elresources.DefaultHTTPClientExpectContinueTimeout),
57+
httpClientExpectContinueTimeout = flag.Int64("el-httpclient-expectcontinuetimeout", elresources.DefaultHTTPClientExpectContinueTimeout,
5858
"The HTTP Client read timeout for EventListener Server.")
5959
periodSeconds = flag.Int("period-seconds", elresources.DefaultPeriodSeconds, "The Period Seconds for the EventListener Liveness and Readiness Probes.")
6060
failureThreshold = flag.Int("failure-threshold", elresources.DefaultFailureThreshold, "The Failure Threshold for the EventListener Liveness and Readiness Probes.")

0 commit comments

Comments
 (0)