diff --git a/Makefile b/Makefile index 764ba4de5..e4876139b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,6 @@ -VERSION=v0.0.9 +VERSION=v0.0.10 OUT_DIR=dist +YEAR?=$(shell date +"%Y") CLI_NAME?=cf IMAGE_REPOSITORY?=quay.io @@ -115,11 +116,12 @@ lint: $(GOBIN)/golangci-lint tidy .PHONY: test test: - ./hack/test.sh + @./hack/test.sh .PHONY: codegen codegen: $(GOBIN)/mockery go generate ./... + go run ./hack/license.go --license ./hack/boilerplate.txt --year $(YEAR) . .PHONY: pre-commit pre-commit: lint @@ -137,7 +139,7 @@ serve-docs: .PHONY: release release: tidy check-worktree - ./hack/release.sh + @./hack/release.sh .PHONY: clean clean: @@ -167,10 +169,3 @@ $(GOBIN)/golangci-lint: @mkdir dist || true @echo installing: golangci-lint @curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOBIN) v1.36.0 - -$(GOBIN)/interfacer: cwd=$(shell pwd) -$(GOBIN)/interfacer: - @cd /tmp - @echo installing: interfacer - @GO111MODULE=on go get -v github.com/rjeczalik/interfaces/cmd/interfacer@v0.1.1 - @cd ${cwd} diff --git a/build/Dockerfile.helper b/build/Dockerfile.helper deleted file mode 100644 index 88e9fb916..000000000 --- a/build/Dockerfile.helper +++ /dev/null @@ -1,4 +0,0 @@ -FROM golang:1.16.3-alpine3.13 -RUN apk -U add --no-cache ca-certificates git make gcc g++ curl bash openssl && update-ca-certificates -RUN curl -L https://github.com/cli/cli/releases/download/v1.9.2/gh_1.9.2_linux_amd64.tar.gz | tar zx && mv ./gh_1.9.2_linux_amd64/bin/gh /usr/local/bin -ENTRYPOINT [ "/bin/bash" ] \ No newline at end of file diff --git a/cmd/commands/common.go b/cmd/commands/common.go index 32c4e4868..a5bf58d0a 100644 --- a/cmd/commands/common.go +++ b/cmd/commands/common.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package commands import ( diff --git a/cmd/commands/config.go b/cmd/commands/config.go index 77e5d1c23..dc2281ef2 100644 --- a/cmd/commands/config.go +++ b/cmd/commands/config.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package commands import ( diff --git a/cmd/commands/root.go b/cmd/commands/root.go index e0e13f531..5277810e3 100644 --- a/cmd/commands/root.go +++ b/cmd/commands/root.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package commands import ( diff --git a/cmd/commands/runtime.go b/cmd/commands/runtime.go index 45fb01b67..35dded6b7 100644 --- a/cmd/commands/runtime.go +++ b/cmd/commands/runtime.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package commands import ( diff --git a/cmd/commands/version.go b/cmd/commands/version.go index d816e41f4..fe9b70a49 100644 --- a/cmd/commands/version.go +++ b/cmd/commands/version.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package commands import ( diff --git a/cmd/main.go b/cmd/main.go index 10f0441b3..0e8fb3dab 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package main import ( diff --git a/hack/boilerplate.txt b/hack/boilerplate.txt new file mode 100644 index 000000000..a2a85f42c --- /dev/null +++ b/hack/boilerplate.txt @@ -0,0 +1,14 @@ +// Copyright YEAR The Codefresh 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. + diff --git a/hack/cmd-docs/main.go b/hack/cmd-docs/main.go index 6b2b56b5c..90db11d40 100644 --- a/hack/cmd-docs/main.go +++ b/hack/cmd-docs/main.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package main import ( diff --git a/hack/license.go b/hack/license.go new file mode 100644 index 000000000..37ab029e6 --- /dev/null +++ b/hack/license.go @@ -0,0 +1,86 @@ +// Copyright 2021 The Codefresh 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. + +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "log" + "os" + "path/filepath" + "strings" +) + +func main() { + var ( + licenseFile string + year int + ) + + flag.StringVar(&licenseFile, "license", "", "license file path") + flag.IntVar(&year, "year", 0, "year") + flag.Parse() + + if licenseFile == "" { + panic("--license required") + } + + if year <= 0 { + panic("--year positive int required") + } + + d, err := ioutil.ReadFile(licenseFile) + die(err) + + license := string(d) + + license = strings.ReplaceAll(license, "YEAR", fmt.Sprintf("%d", year)) + + die(filepath.Walk(flag.Arg(0), func(path string, info os.FileInfo, err error) error { + die(err) + if info.IsDir() { + return nil + } + if filepath.Ext(path) != ".go" { + return nil + } + f, err := os.OpenFile(path, os.O_RDWR, info.Mode()) + die(err) + defer f.Close() + + data, err := ioutil.ReadAll(f) + die(err) + + s := string(data) + + if strings.HasPrefix(strings.TrimSpace(s), strings.TrimSpace(license)) { + return nil + } + + log.Print(path) + + s = license + s + _, err = f.WriteAt([]byte(s), 0) + die(err) + return nil + })) +} + +func die(err error) { + if err != nil { + log.Fatal(err) + } +} diff --git a/pkg/config/config.go b/pkg/config/config.go index 1ce8646f5..5875f32dd 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package config import ( diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 4620d4158..b526fb8fb 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package config import ( diff --git a/pkg/log/log.go b/pkg/log/log.go index a4ae2120b..8a0970810 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package log import ( diff --git a/pkg/log/logrus.go b/pkg/log/logrus.go index bc4d6828a..12b0c9bad 100644 --- a/pkg/log/logrus.go +++ b/pkg/log/logrus.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package log import ( diff --git a/pkg/store/store.go b/pkg/store/store.go index 7a99cdefb..75cc9cf12 100644 --- a/pkg/store/store.go +++ b/pkg/store/store.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package store import ( diff --git a/pkg/util/assets/assets.go b/pkg/util/assets/assets.go deleted file mode 100644 index 42194bca1..000000000 --- a/pkg/util/assets/assets.go +++ /dev/null @@ -1,14 +0,0 @@ -// Code generated by github.com/gobuffalo/packr. DO NOT EDIT. -package assets - -import "github.com/gobuffalo/packr" - -// You can use the "packr clean" command to clean up this, -// and any other packr generated files. -func init() { - packr.PackJSONBytes("../../assets", "README.md", "\"dGhpcyBpcyBoZXJlIGp1c3QgdG8gZml4IHRoaXMgaXNzdWU6IGh0dHBzOi8vZ2l0aHViLmNvbS9hcmdvcHJvai9hcmdvLWNkL2lzc3Vlcy8yOTA3\"") - packr.PackJSONBytes("../../assets", "badge.svg", "\"bW9jaw==\"") - packr.PackJSONBytes("../../assets", "builtin-policy.csv", "\"bW9jaw==\"") - packr.PackJSONBytes("../../assets", "model.conf", "\"bW9jaw==\"") - packr.PackJSONBytes("../../assets", "swagger.json", "\"Im1vY2si\"") -} diff --git a/pkg/util/util.go b/pkg/util/util.go index 650b59b39..8761800e7 100644 --- a/pkg/util/util.go +++ b/pkg/util/util.go @@ -1,3 +1,17 @@ +// Copyright 2021 The Codefresh 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. + package util import ( diff --git a/util/assets/assets.go b/util/assets/assets.go new file mode 100644 index 000000000..7ade18710 --- /dev/null +++ b/util/assets/assets.go @@ -0,0 +1,27 @@ +// Copyright 2021 The Codefresh 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. + +package assets + +import "github.com/gobuffalo/packr" + +// You can use the "packr clean" command to clean up this, +// and any other packr generated files. +func init() { + _ = packr.PackJSONBytes("../../assets", "README.md", "\"dGhpcyBpcyBoZXJlIGp1c3QgdG8gZml4IHRoaXMgaXNzdWU6IGh0dHBzOi8vZ2l0aHViLmNvbS9hcmdvcHJvai9hcmdvLWNkL2lzc3Vlcy8yOTA3\"") + _ = packr.PackJSONBytes("../../assets", "badge.svg", "\"bW9jaw==\"") + _ = packr.PackJSONBytes("../../assets", "builtin-policy.csv", "\"bW9jaw==\"") + _ = packr.PackJSONBytes("../../assets", "model.conf", "\"bW9jaw==\"") + _ = packr.PackJSONBytes("../../assets", "swagger.json", "\"Im1vY2si\"") +}