Skip to content

Commit

Permalink
Fix naming and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuckal777 committed Sep 10, 2024
1 parent 57da6a1 commit 3696b6a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 29 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.23.0
go-version: 1.23.1
- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.23.0
go-version: 1.23.1
- name: Build all binaries
run: make build-all
test:
Expand All @@ -43,6 +43,6 @@ jobs:
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.23.0
go-version: 1.23.1
- name: Run tests and generate coverage report
run: make build/cover.out
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
uses: actions/setup-go@v5
with:
check-latest: true
go-version: 1.23.0
go-version: 1.23.1
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ linters-settings:
- ^http\.Handle(?:Func)?$
# Forbid usage of old and archived square/go-jose
- pkg: ^gopkg\.in/square/go-jose\.v2$
msg: "gopk.in/square/go-jose is arcived and has CVEs. Replace it with gopkg.in/go-jose/go-jose.v2"
msg: "gopk.in/square/go-jose is archived and has CVEs. Replace it with gopkg.in/go-jose/go-jose.v2"
- pkg: ^github.com/coreos/go-oidc$
msg: "github.com/coreos/go-oidc depends on gopkg.in/square/go-jose which has CVEs. Replace it with github.com/coreos/go-oidc/v3"

Expand Down
7 changes: 7 additions & 0 deletions .license-scan-overrides.jsonl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{"name": "github.com/chzyer/logex", "licenceType": "MIT"}
{"name": "github.com/hashicorp/vault/api/auth/approle", "licenceType": "MPL-2.0"}
{"name": "github.com/jpillora/longestcommon", "licenceType": "MIT"}
{"name": "github.com/spdx/tools-golang", "licenceTextOverrideFile": "vendor/github.com/spdx/tools-golang/LICENSE.code"}
{"name": "github.com/xeipuuv/gojsonpointer", "licenceType": "Apache-2.0"}
{"name": "github.com/xeipuuv/gojsonreference", "licenceType": "Apache-2.0"}
{"name": "github.com/xeipuuv/gojsonschema", "licenceType": "Apache-2.0"}
11 changes: 11 additions & 0 deletions .license-scan-rules.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"allowlist": [
"Apache-2.0",
"BSD-2-Clause",
"BSD-3-Clause",
"ISC",
"MIT",
"MPL-2.0",
"Unlicense"
]
}
53 changes: 35 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ default: build-all

prepare-static-check: FORCE
@if ! hash golangci-lint 2>/dev/null; then printf "\e[1;36m>> Installing golangci-lint (this may take a while)...\e[0m\n"; go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; fi
@if ! hash go-licence-detector 2>/dev/null; then printf "\e[1;36m>> Installing go-licence-detector...\e[0m\n"; go install go.elastic.co/go-licence-detector@latest; fi
@if ! hash addlicense 2>/dev/null; then printf "\e[1;36m>> Installing addlicense...\e[0m\n"; go install github.com/google/addlicense@latest; fi

install-controller-gen: FORCE
@if ! hash controller-gen 2>/dev/null; then printf "\e[1;36m>> Installing controller-gen...\e[0m\n"; go install sigs.k8s.io/controller-tools/cmd/controller-gen@latest; fi
Expand Down Expand Up @@ -81,7 +83,7 @@ build/cover.html: build/cover.out
@printf "\e[1;36m>> go tool cover > build/cover.html\e[0m\n"
@go tool cover -html $< -o $@

static-check: FORCE run-golangci-lint
static-check: FORCE run-golangci-lint check-dependency-licenses check-license-headers

build:
@mkdir $@
Expand All @@ -90,6 +92,18 @@ tidy-deps: FORCE
go mod tidy
go mod verify

license-headers: FORCE prepare-static-check
@printf "\e[1;36m>> addlicense\e[0m\n"
@addlicense -c "SAP SE" -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))

check-license-headers: FORCE prepare-static-check
@printf "\e[1;36m>> addlicense --check\e[0m\n"
@addlicense --check -- $(patsubst $(shell awk '$$1 == "module" {print $$2}' go.mod)%,.%/*.go,$(shell go list ./...))

check-dependency-licenses: FORCE prepare-static-check
@printf "\e[1;36m>> go-licence-detector\e[0m\n"
@go list -m -mod=readonly -json all | go-licence-detector -includeIndirect -rules .license-scan-rules.json -overrides .license-scan-overrides.jsonl

clean: FORCE
git clean -dxf build

Expand All @@ -108,30 +122,33 @@ help: FORCE
@printf " make \e[36m<target>\e[0m\n"
@printf "\n"
@printf "\e[1mGeneral\e[0m\n"
@printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n"
@printf " \e[36mhelp\e[0m Display this help.\n"
@printf " \e[36mvars\e[0m Display values of relevant Makefile variables.\n"
@printf " \e[36mhelp\e[0m Display this help.\n"
@printf "\n"
@printf "\e[1mPrepare\e[0m\n"
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-controller-gen\e[0m Install controller-gen required by static-check and build-all. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-setup-envtest\e[0m Install setup-envtest required by check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-ginkgo\e[0m Install ginkgo required when using it as test runner. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36mprepare-static-check\e[0m Install any tools required by static-check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-controller-gen\e[0m Install controller-gen required by static-check and build-all. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-setup-envtest\e[0m Install setup-envtest required by check. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf " \e[36minstall-ginkgo\e[0m Install ginkgo required when using it as test runner. This is used in CI before dropping privileges, you should probably install all the tools using your package manager\n"
@printf "\n"
@printf "\e[1mBuild\e[0m\n"
@printf " \e[36mbuild-all\e[0m Build all binaries.\n"
@printf " \e[36mbuild/metal-token-dealer\e[0m Build metal-token-dealer.\n"
@printf " \e[36minstall\e[0m Install all binaries. This option understands the conventional 'DESTDIR' and 'PREFIX' environment variables for choosing install locations.\n"
@printf " \e[36mbuild-all\e[0m Build all binaries.\n"
@printf " \e[36mbuild/metal-token-dealer\e[0m Build metal-token-dealer.\n"
@printf " \e[36minstall\e[0m Install all binaries. This option understands the conventional 'DESTDIR' and 'PREFIX' environment variables for choosing install locations.\n"
@printf "\n"
@printf "\e[1mTest\e[0m\n"
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
@printf " \e[36mcheck\e[0m Run the test suite (unit tests and golangci-lint).\n"
@printf " \e[36mgenerate\e[0m Generate code for Kubernetes CRDs and deepcopy.\n"
@printf " \e[36mrun-golangci-lint\e[0m Install and run golangci-lint. Installing is used in CI, but you should probably install golangci-lint using your package manager.\n"
@printf " \e[36mbuild/cover.out\e[0m Run tests and generate coverage report.\n"
@printf " \e[36mbuild/cover.html\e[0m Generate an HTML file with source code annotations from the coverage report.\n"
@printf " \e[36mstatic-check\e[0m Run static code checks\n"
@printf "\n"
@printf "\e[1mDevelopment\e[0m\n"
@printf " \e[36mtidy-deps\e[0m Run go mod tidy and go mod verify.\n"
@printf " \e[36mclean\e[0m Run git clean.\n"
@printf " \e[36mtidy-deps\e[0m Run go mod tidy and go mod verify.\n"
@printf " \e[36mlicense-headers\e[0m Add license headers to all non-vendored source code files.\n"
@printf " \e[36mcheck-license-headers\e[0m Check license headers in all non-vendored .go files.\n"
@printf " \e[36mcheck-dependency-licenses\e[0m Check all dependency licenses using go-licence-detector.\n"
@printf " \e[36mclean\e[0m Run git clean.\n"

.PHONY: FORCE
2 changes: 1 addition & 1 deletion controllers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"os"
)

const DefaultConfigPath string = "/etc/metal-auth/config.json"
const DefaultConfigPath string = "/etc/metal-token-dealer/config.json"

type Config struct {
ServiceAccountName string `json:"serviceAccountName"`
Expand Down
9 changes: 4 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ func main() {
}

mgr, err := ctrl.NewManager(gardenConfig, ctrl.Options{
Scheme: scheme,
LeaderElection: true,
LeaderElectionID: "runtime-extension-maintenance-controller",
Scheme: scheme,
LeaderElection: false,
})
if err != nil {
setupLog.Error(err, "unable to setup manager")
Expand All @@ -83,7 +82,7 @@ func main() {
secretController := controllers.SecretReconciler{
MetalClient: metalClient,
GardenClient: mgr.GetClient(),
Log: ctrl.Log.WithName("controllers").WithName("Secret"),
Log: ctrl.Log.WithName("controllers").WithName("secret"),
ConfigPath: controllers.DefaultConfigPath,
}
if err = secretController.SetupWithManager(mgr); err != nil {
Expand Down Expand Up @@ -114,7 +113,7 @@ func getKubeconfigOrDie(kubecontext string) *rest.Config {
func gardenClusterConfig(apiAddress string) (*rest.Config, error) {
const (
tokenFile = "/var/run/garden/token" //nolint:gosec
rootCAFile = "/var/run/garden/ca.crt"
rootCAFile = "/var/run/garden/bundle.crt"
)

if apiAddress == "" {
Expand Down

0 comments on commit 3696b6a

Please sign in to comment.