Skip to content

Commit

Permalink
chore: bump go version, packages, dependencies
Browse files Browse the repository at this point in the history
Signed-off-by: Bence Csati <[email protected]>

chore: bump go version, packages, dependencies

Signed-off-by: Bence Csati <[email protected]>

chore: bump go version, packages, dependencies

Signed-off-by: Bence Csati <[email protected]>

chore: bump go version, packages, dependencies

Signed-off-by: Bence Csati <[email protected]>
  • Loading branch information
csatib02 committed Aug 21, 2024
1 parent d977a50 commit ba019cc
Show file tree
Hide file tree
Showing 16 changed files with 271 additions and 305 deletions.
48 changes: 0 additions & 48 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,6 @@ jobs:
test:
name: Test
runs-on: ubuntu-latest
strategy:
matrix:
vault_version: ["1.11.12", "1.12.8", "1.13.4", "1.14.1"]

services:
vault:
image: hashicorp/vault:${{ matrix.vault_version }}
env:
SKIP_SETCAP: "true"
VAULT_ADDR: http://127.0.0.1:8200
VAULT_TOKEN: 227e1cce-6bf7-30bb-2d2a-acc854318caf
VAULT_DEV_ROOT_TOKEN_ID: 227e1cce-6bf7-30bb-2d2a-acc854318caf
ports:
- 8200:8200
bao:
image: quay.io/openbao/openbao@sha256:a015ae0adb1af5b45b33632e29879ff87063d0878e9359584a50b2706e500e9a # 2.0.0-alpha20240329
env:
SKIP_SETCAP: "true"
BAO_ADDR: http://127.0.0.1:8200
BAO_TOKEN: 227e1cce-6bf7-30bb-2d2a-acc854318caf
BAO_DEV_ROOT_TOKEN_ID: 227e1cce-6bf7-30bb-2d2a-acc854318caf
ports:
- 8300:8200

steps:
- name: Checkout repository
Expand Down Expand Up @@ -234,29 +211,6 @@ jobs:
e2e-test:
name: E2E test
runs-on: ubuntu-latest
strategy:
matrix:
vault_version: ["1.11.12", "1.12.8", "1.13.4", "1.14.1"]

services:
vault:
image: hashicorp/vault:${{ matrix.vault_version }}
env:
SKIP_SETCAP: "true"
VAULT_ADDR: http://127.0.0.1:8200
VAULT_TOKEN: 227e1cce-6bf7-30bb-2d2a-acc854318caf
VAULT_DEV_ROOT_TOKEN_ID: 227e1cce-6bf7-30bb-2d2a-acc854318caf
ports:
- 8200:8200
bao:
image: quay.io/openbao/openbao@sha256:a015ae0adb1af5b45b33632e29879ff87063d0878e9359584a50b2706e500e9a # 2.0.0-alpha20240329
env:
SKIP_SETCAP: "true"
BAO_ADDR: http://127.0.0.1:8200
BAO_TOKEN: 227e1cce-6bf7-30bb-2d2a-acc854318caf
BAO_DEV_ROOT_TOKEN_ID: 227e1cce-6bf7-30bb-2d2a-acc854318caf
ports:
- 8300:8200

steps:
- name: Checkout repository
Expand Down Expand Up @@ -286,5 +240,3 @@ jobs:

- name: Test
run: nix develop --impure .#ci -c make test-e2e
env:
VAULT_VERSION: ${{ matrix.vault_version }}
11 changes: 10 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,25 @@ linters-settings:
misspell:
locale: US
nolintlint:
allow-leading-space: false # require machine-readable nolint directives (with no leading space)
allow-unused: false # report any unused nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
revive:
confidence: 0

linters:
enable:
- bodyclose
- errcheck
- gci
- gofmt
- gofumpt
- goimports
- gosimple
- ineffassign
- misspell
- nolintlint
- revive
- unconvert
- unparam
- unused
- whitespace
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM --platform=$BUILDPLATFORM tonistiigi/xx:1.4.0@sha256:0cd3f05c72d6c9b038eb135f91376ee1169ef3a330d34e418e65e2a5c2e9c0d4 AS xx

FROM --platform=$BUILDPLATFORM golang:1.22.3-alpine3.18@sha256:d1a601b64de09e2fa38c95e55838961811d5ca11062a8f4230a5c434b3ae2a34 AS builder
FROM --platform=$BUILDPLATFORM golang:1.23.0-alpine3.20@sha256:d0b31558e6b3e4cc59f6011d79905835108c919143ebecc58f35965bf79948f4 AS builder

COPY --from=xx / /

Expand Down
76 changes: 46 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@

export PATH := $(abspath bin/):${PATH}

# Dependency versions
GOLANGCI_VERSION = 1.53.3
LICENSEI_VERSION = 0.8.0
COSIGN_VERSION = 2.2.2
GORELEASER_VERSION = 2.0.0
BATS_VERSION = 1.2.1

##@ General

# Targets commented with ## will be visible in "make help" info.
Expand All @@ -25,10 +18,6 @@ help: ## Display this help
up: ## Start development environment
docker compose up -d

.PHONY: stop
stop: ## Stop development environment
docker compose stop

.PHONY: down
down: ## Destroy development environment
docker compose down -v
Expand All @@ -50,55 +39,82 @@ container-image: ## Build container image

.PHONY: binary-snapshot
binary-snapshot: ## Build binary snapshot
VERSION=v${GORELEASER_VERSION} goreleaser release --clean --skip=publish --snapshot
VERSION=v${GORELEASER_VERSION} $(GORELEASER_BIN) release --clean --skip=publish --snapshot

##@ Checks

.PHONY: check
check: test lint ## Run checks (tests and linters)

.PHONY: test
test: ## Run tests
go test -race -v ./...

.PHONY: test-e2e
test-e2e: ## Run e2e tests
@export BATS_LIB_PATH=${PWD}/bin/bats-core/libexec/bats-core/lib && \
bats e2e
check: lint test ## Run checks (tests and linters)

.PHONY: lint
lint: lint-go lint-docker lint-yaml
lint: ## Run linters

.PHONY: lint-go
lint-go:
golangci-lint run $(if ${CI},--out-format github-actions,)
GOGC=1 $(GOLANGCI_LINT_BIN) run $(if ${CI},--out-format colored-line-number,) --verbose

.PHONY: lint-docker
lint-docker:
hadolint Dockerfile
$(HADOLINT_BIN) Dockerfile

.PHONY: lint-yaml
lint-yaml:
yamllint $(if ${CI},-f github,) --no-warnings .
$(YAMLLINT_BIN) $(if ${CI},-f github,) --no-warnings .

.PHONY: test
test: ## Run tests
go test -race -v ./...

.PHONY: test-e2e
test-e2e: ## Run e2e tests
@export BATS_LIB_PATH=${PWD}/bin/bats-core/libexec/bats-core/lib && \
$(BATS_BIN) e2e

.PHONY: fmt
fmt: ## Format code
golangci-lint run --fix
$(GOLANGCI_LINT_BIN) run --fix

.PHONY: license-check
license-check: ## Run license check
licensei check
licensei header
$(LICENSEI_BIN) check
$(LICENSEI_BIN) header

##@ Dependencies

# Dependency versions
GOLANGCI_LINT_VERSION = 1.60.2
LICENSEI_VERSION = 0.9.0
COSIGN_VERSION = 2.4.0
GORELEASER_VERSION = 2.2.0
BATS_VERSION = 1.11.0

# Dependency binaries
GOLANGCI_LINT_BIN := golangci-lint
LICENSEI_BIN := licensei
COSIGN_BIN := cosign
GORELEASER_BIN := goreleaser
BATS_BIN := bats

# TODO: add support for hadolint and yamllint dependencies
HADOLINT_BIN := hadolint
YAMLLINT_BIN := yamllint

# If we have "bin" dir, use those binaries instead
ifneq ($(wildcard ./bin/.),)
GOLANGCI_LINT_BIN := bin/$(GOLANGCI_LINT_BIN)
LICENSEI_BIN := bin/$(LICENSEI_BIN)
COSIGN_BIN := bin/$(COSIGN_BIN)
GORELEASER_BIN := bin/$(GORELEASER_BIN)
BATS_BIN := bin/$(BATS_BIN)
endif

deps: bin/golangci-lint bin/licensei bin/cosign bin/goreleaser bin/bats
deps: ## Install dependencies

bin/golangci-lint:
@mkdir -p bin
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_VERSION}
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | bash -s -- v${GOLANGCI_LINT_VERSION}

bin/licensei:
@mkdir -p bin
Expand Down Expand Up @@ -129,7 +145,7 @@ bin/goreleaser:
bin/bats:
@mkdir -p bin/bats-core
@mkdir -p tmpbats
git clone https://github.com/bats-core/bats-core.git tmpbats
git clone --branch v${BATS_VERSION} --depth 1 https://github.com/bats-core/bats-core.git tmpbats
bash tmpbats/install.sh bin/bats-core
@ln -sF ${PWD}/bin/bats-core/bin/bats ${PWD}/bin
@rm -rf tmpbats
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
vault:
container_name: secret-init-vault
image: hashicorp/vault:1.14.1
image: hashicorp/vault:1.14.8
ports:
- 127.0.0.1:8200:8200
environment:
Expand All @@ -12,7 +12,7 @@ services:

bao:
container_name: secret-init-bao
image: quay.io/openbao/openbao@sha256:a015ae0adb1af5b45b33632e29879ff87063d0878e9359584a50b2706e500e9a # 2.0.0-alpha20240329
image: openbao/openbao:latest
ports:
- 127.0.0.1:8300:8200
environment:
Expand Down
4 changes: 2 additions & 2 deletions env_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ func (s *EnvStore) workaroundForBao(ctx context.Context, vaultPaths []string) ([
}

// ConvertProviderSecrets converts the loaded secrets to environment variables
func (s *EnvStore) ConvertProviderSecrets(providerSecrets []provider.Secret) ([]string, error) {
func (s *EnvStore) ConvertProviderSecrets(providerSecrets []provider.Secret) []string {
var secretsEnv []string

for _, secret := range providerSecrets {
secretsEnv = append(secretsEnv, fmt.Sprintf("%s=%s", secret.Key, secret.Value))
}

return secretsEnv, nil
return secretsEnv
}

// Returns the detected provider name and path with removed prefix
Expand Down
7 changes: 2 additions & 5 deletions env_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,10 +240,7 @@ func TestEnvStore_ConvertProviderSecrets(t *testing.T) {
t.Run(ttp.name, func(t *testing.T) {
createEnvsForProvider(ttp.addvault, secretFile)

secretsEnv, err := NewEnvStore(&common.Config{}).ConvertProviderSecrets(ttp.providerSecrets)
if err != nil {
assert.EqualError(t, ttp.err, err.Error(), "Unexpected error message")
}
secretsEnv := NewEnvStore(&common.Config{}).ConvertProviderSecrets(ttp.providerSecrets)
if ttp.wantSecretsEnv != nil {
assert.Equal(t, ttp.wantSecretsEnv, secretsEnv, "Unexpected secrets")
}
Expand All @@ -261,7 +258,7 @@ func createEnvsForProvider(addVault bool, secretFile string) {

func newSecretFile(t *testing.T, content string) string {
dir := t.TempDir() + "/test/secrets"
err := os.MkdirAll(dir, 0755)
err := os.MkdirAll(dir, 0o755)
assert.Nil(t, err, "Failed to create directory")

file, err := os.CreateTemp(dir, "secret.txt")
Expand Down
26 changes: 13 additions & 13 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ba019cc

Please sign in to comment.