From 177a2668e8b4287b84f3f4b9cad0a5c25a7d4d45 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Mon, 10 Jun 2024 10:47:50 +0200 Subject: [PATCH 1/4] chore: update flake.nix Signed-off-by: Bence Csati --- flake.lock | 14 +++++++------- flake.nix | 52 +++++++--------------------------------------------- 2 files changed, 14 insertions(+), 52 deletions(-) diff --git a/flake.lock b/flake.lock index 7920d7f5..e34170ce 100644 --- a/flake.lock +++ b/flake.lock @@ -39,11 +39,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1717245169, - "narHash": "sha256-+mW3rTBjGU8p1THJN0lX/Dd/8FbnF+3dB+mJuSaxewE=", + "lastModified": 1718001032, + "narHash": "sha256-kaL1/ruHEEm5+4OCaFfspCyaguUVrbmkad7A3fXaGF0=", "owner": "cachix", "repo": "devenv", - "rev": "c3f9f053c077c6f88a3de5276d9178c62baa3fc3", + "rev": "50e981f8a08cc06553ac591c658f347f6087d836", "type": "github" }, "original": { @@ -362,16 +362,16 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1717372969, - "narHash": "sha256-cyFuF5+g59NjOAkx7+oUrQfzzvWwzJvZTMTsl85JgJk=", + "lastModified": 1717868076, + "narHash": "sha256-c83Y9t815Wa34khrux81j8K8ET94ESmCuwORSKm2bQY=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0fc0a545f5efbc7dbc3bbd6a2ec8280bff01d73e", + "rev": "cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9", "type": "github" }, "original": { "owner": "NixOS", - "ref": "master", + "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 7021947d..90e271da 100644 --- a/flake.nix +++ b/flake.nix @@ -2,8 +2,7 @@ description = "Go libraries for interacting with Hashicorp Vault"; inputs = { - # nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; - nixpkgs.url = "github:NixOS/nixpkgs/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; flake-parts.url = "github:hercules-ci/flake-parts"; devenv.url = "github:cachix/devenv"; }; @@ -40,16 +39,20 @@ packages = with pkgs; [ gnumake - # golangci-lint goreleaser + # golangci-lint + # TODO: remove once https://github.com/NixOS/nixpkgs/pull/254878 hits unstable + (golangci-lint.override (prev: { + buildGoModule = pkgs.buildGo121Module; + })) + kubectl yamllint hadolint ] ++ [ self'.packages.licensei - self'.packages.golangci-lint ]; env = { @@ -116,47 +119,6 @@ "-X github.com/hashicorp/vault/sdk/version.VersionPrerelease=" ]; }; - - golangci-lint = pkgs.buildGo121Module rec { - pname = "golangci-lint"; - version = "1.54.2"; - - src = pkgs.fetchFromGitHub { - owner = "golangci"; - repo = "golangci-lint"; - rev = "v${version}"; - hash = "sha256-7nbgiUrp7S7sXt7uFXX8NHYbIRLZZQcg+18IdwAZBfE="; - }; - - vendorHash = "sha256-IyH5lG2a4zjsg/MUonCUiAgMl4xx8zSflRyzNgk8MR0="; - - subPackages = [ "cmd/golangci-lint" ]; - - nativeBuildInputs = [ pkgs.installShellFiles ]; - - ldflags = [ - "-s" - "-w" - "-X main.version=${version}" - "-X main.commit=v${version}" - "-X main.date=19700101-00:00:00" - ]; - - postInstall = '' - for shell in bash zsh fish; do - HOME=$TMPDIR $out/bin/golangci-lint completion $shell > golangci-lint.$shell - installShellCompletion golangci-lint.$shell - done - ''; - - meta = with pkgs.lib; { - description = "Fast linters Runner for Go"; - homepage = "https://golangci-lint.run/"; - changelog = "https://github.com/golangci/golangci-lint/blob/v${version}/CHANGELOG.md"; - license = licenses.gpl3Plus; - maintainers = with maintainers; [ anpryl manveru mic92 ]; - }; - }; }; }; }; From 3881f94f5801c7878189355bafd79e1e8c347bfa Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Mon, 10 Jun 2024 10:57:57 +0200 Subject: [PATCH 2/4] chore: lint Signed-off-by: Bence Csati --- main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.go b/main.go index 4627de57..f803c8b8 100644 --- a/main.go +++ b/main.go @@ -149,7 +149,7 @@ func main() { } levelFilter := func(levels ...slog.Level) func(ctx context.Context, r slog.Record) bool { - return func(ctx context.Context, r slog.Record) bool { + return func(_ context.Context, r slog.Record) bool { return slices.Contains(levels, r.Level) } } From a6bd32ec8768d56ce7b10f9c7da591933eb928f2 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Mon, 10 Jun 2024 11:18:28 +0200 Subject: [PATCH 3/4] fix(ci) Signed-off-by: Bence Csati --- .github/workflows/artifacts.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 22ba1730..2ef6797b 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -179,7 +179,7 @@ jobs: with: cond: ${{ inputs.release }} if_true: goreleaser release - if_false: goreleaser release --skip-publish --snapshot + if_false: goreleaser release --skip=publish --snapshot - name: Build run: nix develop --impure .#ci -c ${{ steps.build-command.outputs.value }} From 29f8336ae1306600350da9915ef69ceb2e37eda7 Mon Sep 17 00:00:00 2001 From: Bence Csati Date: Mon, 10 Jun 2024 11:44:50 +0200 Subject: [PATCH 4/4] chore: update goreleaser to version 2 Signed-off-by: Bence Csati --- .goreleaser.yaml | 29 +++++++++++++++++++---------- Makefile | 2 +- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index 554dfb9c..f743af73 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -1,12 +1,16 @@ +version: 2 + +project_name: vault-env + dist: build/dist +before: + hooks: + - go mod tidy builds: - - main: . - env: + - env: - CGO_ENABLED=0 - flags: - - -trimpath - ldflags: "-s -w -X main.version={{ .Version }}" + main: . goos: - linux - darwin @@ -15,13 +19,18 @@ builds: - arm64 archives: - - name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}" - format_overrides: - - goos: windows - format: zip + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of uname. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} checksum: name_template: "checksums.txt" changelog: - skip: false + disable: true diff --git a/Makefile b/Makefile index 35916ec8..4450e594 100644 --- a/Makefile +++ b/Makefile @@ -84,7 +84,7 @@ deps: ## Install dependencies GOLANGCI_VERSION = 1.53.3 COSIGN_VERSION = 2.2.2 LICENSEI_VERSION = 0.8.0 -GORELEASER_VERSION = 1.18.2 +GORELEASER_VERSION = 2.0.0 # Dependency binaries GOLANGCI_LINT_BIN := golangci-lint