diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f921591..d438cd1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,10 +1,10 @@ { "name": "Go", - "image": "golang:1.21.5", + "image": "golang:1.22.1", "containerUser": "root", "features": { - "ghcr.io/devcontainers/features/common-utils:1": {}, - "ghcr.io/devcontainers/features/go:1": {"version": "none", "golangciLintVersion": "1.55.2"} + "ghcr.io/devcontainers/features/common-utils:2": {}, + "ghcr.io/devcontainers/features/go:1": {"version": "none", "golangciLintVersion": "1.56.2"} }, "runArgs": [ "--cap-add=SYS_PTRACE", diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 11aeddd..f98258a 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1,4 +1,4 @@ # All files * @mia-platform/sig-cli # Actions must also be checked by security -.github/actions @mia-platform/sig-cli @mia-platform/sig-security +.github/workflows @mia-platform/sig-cli @mia-platform/sig-security diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 03e0009..6e87a0a 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -22,3 +22,9 @@ updates: interval: daily time: "07:00" timezone: Europe/Rome + +# keep up to date devcontainers +- package-ecosystem: devcontainers + directory: "/" + schedule: + interval: monthly diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index e699e78..1ecf59c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -14,9 +14,7 @@ on: - examples/** env: - GO_VERSION: 1.21.5 - GORELEASER_VERSION: v1.22.1 - GO_CACHE: true + GORELEASER_VERSION: v1.24.0 jobs: lint: name: Lint Code @@ -29,7 +27,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} + go-version-file: go.mod cache: false - name: Set golangci-lint Cache Key id: create-sha @@ -62,7 +60,7 @@ jobs: - "1.26" - "1.27" - "1.28" - # - "1.29" + - "1.29" runs-on: ${{ matrix.os }} env: ENVTEST_K8S_VERSION: ${{matrix.k8s_version}} @@ -74,8 +72,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: true + go-version-file: go.mod - name: Run Test Coverage run: make ci @@ -94,8 +91,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: true + go-version-file: go.mod - name: Setup Goreleaser uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: @@ -119,8 +115,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: true + go-version-file: go.mod - name: Setup Goreleaser uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: @@ -135,7 +130,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }} - name: Upload Binaries Artifacts - uses: actions/upload-artifact@26f96dfa697d77e81fd5907df203aa23a56210a8 # v4.3.0 + uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: name: artifacts path: bin/ diff --git a/.github/workflows/codeql.yaml b/.github/workflows/codeql.yaml index c3b65c2..20d10e8 100644 --- a/.github/workflows/codeql.yaml +++ b/.github/workflows/codeql.yaml @@ -16,12 +16,11 @@ on: - cron: 0 5 * * 1 # Run every monday at 5 UTC env: - GO_VERSION: 1.21.5 - GORELEASER_VERSION: v1.22.1 + GORELEASER_VERSION: v1.24.0 jobs: codeql: - runs-on: ubuntu-latest + runs-on: macos-latest permissions: security-events: write steps: @@ -32,8 +31,7 @@ jobs: - name: Setup Golang uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0 with: - go-version: ${{ env.GO_VERSION }} - cache: false + go-version-file: go.mod - name: Setup Goreleaser uses: goreleaser/goreleaser-action@7ec5c2b0c6cdda6e8bbb49444bc797dd33d74dd8 # v5.0.0 with: diff --git a/.go-version b/.go-version index ce2dd53..6245bee 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.21.5 +1.22.1 diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bafda6f..7b4c5f0 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -7,7 +7,6 @@ builds: {{- .Arch }}/ {{- with .Arm }}v{{ . }}/{{ end }} {{- .ProjectName }} - no_unique_dist_dir: true env: - CGO_ENABLED=0 diff --git a/.markdownlint.yaml b/.markdownlint.yaml index 630c819..04f7511 100644 --- a/.markdownlint.yaml +++ b/.markdownlint.yaml @@ -17,5 +17,8 @@ MD029: MD033: allowed_elements: - center + - picture + - source + - img MD046: style: fenced diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1e62f19..80d338e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -30,7 +30,7 @@ repos: name: Trims trailing whitespace args: [--markdown-linebreak-ext=md] # add exception for markdown linebreaks - repo: https://github.com/gitleaks/gitleaks - rev: v8.18.1 + rev: v8.18.2 hooks: - id: gitleaks name: Protect and discover secrets using Gitleaks diff --git a/cmd/mlp/main.go b/cmd/mlp/main.go index aa2d66e..bb85507 100644 --- a/cmd/mlp/main.go +++ b/cmd/mlp/main.go @@ -48,7 +48,7 @@ func main() { Use: "version", Short: "Show mlp version", Long: "Show mlp version", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { fmt.Println(versionOutput) }, }) diff --git a/go.mod b/go.mod index 27a5f14..cab00c6 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/mia-platform/mlp -go 1.21 +go 1.22.1 require ( github.com/MakeNowJust/heredoc/v2 v2.0.1 diff --git a/internal/cli/deploy.go b/internal/cli/deploy.go index 8a212c6..43eaf97 100644 --- a/internal/cli/deploy.go +++ b/internal/cli/deploy.go @@ -30,7 +30,7 @@ func DeploySubcommand(cmd *cobra.Command, options *utils.Options) { Use: "deploy", Short: "deploy Mia-Platform created resource on K8S", Long: "", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { deploy.Run(inputPaths, deployConfig, options) }, } diff --git a/internal/cli/generate.go b/internal/cli/generate.go index d273227..29a380c 100644 --- a/internal/cli/generate.go +++ b/internal/cli/generate.go @@ -30,7 +30,7 @@ func GenerateSubcommand(cmd *cobra.Command) { Use: "generate", Short: "Generate configmaps and secrets", Long: `Generate configmaps and secrets described in YAML files passed as input`, - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { generate.Run(configPath, prefixes, outputPath) }, } diff --git a/internal/cli/interpolate.go b/internal/cli/interpolate.go index a3c4b1f..8b57b50 100644 --- a/internal/cli/interpolate.go +++ b/internal/cli/interpolate.go @@ -30,7 +30,7 @@ func InterpolateSubcommand(cmd *cobra.Command) { Use: "interpolate", Short: "Interpolate variables in file", Long: "Interpolate the environment variables inside {{}} in file and substitutes them with the corresponding value", - Run: func(cmd *cobra.Command, args []string) { + Run: func(_ *cobra.Command, _ []string) { interpolate.Run(prefixes, inputPaths, outputPath) }, } diff --git a/internal/cli/kustomize.go b/internal/cli/kustomize.go index 27522e8..9ec9aa9 100644 --- a/internal/cli/kustomize.go +++ b/internal/cli/kustomize.go @@ -50,7 +50,7 @@ func HydrateSubcommand(cmd *cobra.Command) { Short: "Adds passed resource and patches to kustomization.yaml", Long: "Adds passed resource and patches to kustomization.yaml. The PATH argument must be a path to a directory containing 'kustomization.yaml'", Example: "$ mlp hydrate configuration/ overlays/production/", - Args: func(cmd *cobra.Command, args []string) error { + Args: func(_ *cobra.Command, args []string) error { if len(args) < 1 { return errors.New("at least one directory is required") } @@ -65,7 +65,7 @@ func HydrateSubcommand(cmd *cobra.Command) { } return nil }, - RunE: func(cmd *cobra.Command, paths []string) error { + RunE: func(_ *cobra.Command, paths []string) error { return kustomize.HydrateRun(paths) }, } diff --git a/pkg/deploy/apply_test.go b/pkg/deploy/apply_test.go index 40616c1..c7b7cf2 100644 --- a/pkg/deploy/apply_test.go +++ b/pkg/deploy/apply_test.go @@ -683,7 +683,7 @@ func TestWithAwaitableResource(t *testing.T) { } expectedErr := errors.New("Some apply error") - actualErr := withAwaitableResource(func(clients *k8sClients, res resourceutil.Resource, deployConfig utils.DeployConfig) error { + actualErr := withAwaitableResource(func(_ *k8sClients, _ resourceutil.Resource, _ utils.DeployConfig) error { return expectedErr })(&clients, res, deployConfig) @@ -746,7 +746,7 @@ func TestWithDeletableResource(t *testing.T) { annotations: map[string]interface{}{ deleteBeforeApplyAnnotation: "true", }, - setup: func(t *testing.T, clients *k8sClients, res resourceutil.Resource) { t.Helper() }, + setup: func(t *testing.T, _ *k8sClients, _ resourceutil.Resource) { t.Helper() }, requireFn: requireResourceExists(false), }, } @@ -776,7 +776,7 @@ func TestWithDeletableResource(t *testing.T) { tC.setup(t, &clients, res) applyCalled := false - err := withDeletableResource(func(clients *k8sClients, res resourceutil.Resource, deployConfig utils.DeployConfig) error { + err := withDeletableResource(func(clients *k8sClients, res resourceutil.Resource, _ utils.DeployConfig) error { applyCalled = true tC.requireFn(t, clients, res) return nil @@ -806,7 +806,7 @@ func TestWithDeletableResource(t *testing.T) { } expectedErr := errors.New("Some apply error") - actualErr := withAwaitableResource(func(clients *k8sClients, res resourceutil.Resource, deployConfig utils.DeployConfig) error { + actualErr := withAwaitableResource(func(_ *k8sClients, _ resourceutil.Resource, _ utils.DeployConfig) error { return expectedErr })(&clients, res, deployConfig) diff --git a/tools/DEEPCOPY_GEN_VERSION b/tools/DEEPCOPY_GEN_VERSION index 91d002b..678c94d 100644 --- a/tools/DEEPCOPY_GEN_VERSION +++ b/tools/DEEPCOPY_GEN_VERSION @@ -1 +1 @@ -v0.29.0 +v0.29.2 diff --git a/tools/ENVTEST_K8S_VERSION b/tools/ENVTEST_K8S_VERSION index b0c101e..e0250ea 100644 --- a/tools/ENVTEST_K8S_VERSION +++ b/tools/ENVTEST_K8S_VERSION @@ -1 +1 @@ -1.27 +1.28 diff --git a/tools/GOLANGCI_LINT_VERSION b/tools/GOLANGCI_LINT_VERSION index 21fed05..fe1df05 100644 --- a/tools/GOLANGCI_LINT_VERSION +++ b/tools/GOLANGCI_LINT_VERSION @@ -1 +1 @@ -v1.55.2 +v1.56.2 diff --git a/tools/GORELEASER_VERSION b/tools/GORELEASER_VERSION index 1f3000c..de8c3cf 100644 --- a/tools/GORELEASER_VERSION +++ b/tools/GORELEASER_VERSION @@ -1 +1 @@ -v1.22.1 +v1.24.0 diff --git a/tools/make/build.mk b/tools/make/build.mk index c0b86e0..00a2b02 100644 --- a/tools/make/build.mk +++ b/tools/make/build.mk @@ -63,12 +63,6 @@ go/build/multiarch: .PHONY: build-deps build-deps: -$(TOOLS_BIN)/goreleaser: $(TOOLS_DIR)/GORELEASER_VERSION - $(eval GORELEASER_VERSION:= $(shell cat $<)) - mkdir -p $(TOOLS_BIN) - $(info Installing goreleaser $(GORELEASER_VERSION) bin in $(TOOLS_BIN)) - GOBIN=$(TOOLS_BIN) go install github.com/goreleaser/goreleaser@$(GORELEASER_VERSION) - build-deps: $(GORELEASER_PATH) build: build-deps @@ -80,3 +74,9 @@ endif .PHONY: build build: go/build/$(GOOS)/$(GOARCH)/$(GOARM) + +$(TOOLS_BIN)/goreleaser: $(TOOLS_DIR)/GORELEASER_VERSION + $(eval GORELEASER_VERSION:= $(shell cat $<)) + mkdir -p $(TOOLS_BIN) + $(info Installing goreleaser $(GORELEASER_VERSION) bin in $(TOOLS_BIN)) + GOBIN=$(TOOLS_BIN) go install github.com/goreleaser/goreleaser@$(GORELEASER_VERSION) diff --git a/tools/make/test.mk b/tools/make/test.mk index fd20f85..e7f4ca2 100644 --- a/tools/make/test.mk +++ b/tools/make/test.mk @@ -32,7 +32,7 @@ test/unit: .PHONY: test/integration test/integration: $(info Running integration tests...) - KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test $(GO_TEST_DEBUG_FLAG) -tags=integration -race ./... + go test $(GO_TEST_DEBUG_FLAG) -tags=integration -race ./... .PHONY: test/coverage test/coverage: @@ -42,13 +42,13 @@ test/coverage: .PHONY: test/integration/coverage test/integration/coverage: $(info Running ci tests with coverage on...) - KUBEBUILDER_ASSETS=$(KUBEBUILDER_ASSETS) go test -tags=integration -race -coverprofile=coverage.txt -covermode=atomic ./... + go test -tags=integration -race -coverprofile=coverage.txt -covermode=atomic ./... .PHONY: test/conformance test/conformance/setup test/conformance/teardown test/conformance/setup: test/conformance: $(info Running conformance tests...) - go test -tags=conformance -race $(GO_TEST_DEBUG_FLAG) $(CONFORMANCE_TEST_PATH) + go test -count=1 -tags=conformance -race $(GO_TEST_DEBUG_FLAG) $(CONFORMANCE_TEST_PATH) test/conformance/teardown: test/show/coverage: