Skip to content

Commit d0882f1

Browse files
authored
feat(registry_gcr): supporting workload identity (#12)
* feat(registry_gcr): supporting workload identity * update dockerfile
1 parent a3955dc commit d0882f1

36 files changed

+478
-907
lines changed

.devcontainer/devcontainer.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"name": "Go",
3+
"image": "mcr.microsoft.com/devcontainers/go:1-1.23-bookworm",
4+
"features": {
5+
"golang": "1.23.1"
6+
},
7+
"postCreateCommand": "make dev-tools"
8+
}

.github/workflows/release.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- v*
66

77
env:
8-
GO_VERSION: 1.18
8+
GO_VERSION: 1.23
99

1010
jobs:
1111
github-release:
@@ -16,13 +16,11 @@ jobs:
1616
- uses: actions/setup-go@v2
1717
with:
1818
go-version: ${{ env.GO_VERSION }}
19-
- name: install upx
20-
run: sudo apt install upx-ucl -y
2119
- name: GoReleaser
22-
uses: goreleaser/goreleaser-action@v1
20+
uses: goreleaser/goreleaser-action@v6
2321
with:
24-
version: latest
25-
args: release --rm-dist
22+
version: '~> v2'
23+
args: release --clean
2624
env:
2725
GITHUB_TOKEN: ${{ secrets.GORELEASER_GITHUB_TOKEN }}
2826

.github/workflows/tests.yml renamed to .github/workflows/test.yml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
name: tests
32
on:
43
push:
@@ -9,8 +8,8 @@ on:
98
- '**'
109

1110
env:
12-
GO_VERSION: 1.18
13-
LINTER_VERSION: 1.46.0
11+
GO_VERSION: 1.23
12+
LINTER_VERSION: 1.61.0
1413
CGO_ENABLED: 0
1514

1615
jobs:
@@ -36,12 +35,4 @@ jobs:
3635
go-version: ${{ env.GO_VERSION }}
3736
- name: install required packages
3837
run: sudo apt install -y make
39-
- run: make test
40-
# code coverage update
41-
- name: Upload coverage to Codecov
42-
uses: codecov/codecov-action@v3
43-
with:
44-
token: ${{ secrets.CODECOV_TOKEN }}
45-
fail_ci_if_error: true
46-
files: coverage.txt
47-
verbose: true
38+
- run: make test

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
bin/*
44
dist/*
55
vendor/
6-
coverage.txt
6+
coverage.*

.golangci.yml

Lines changed: 56 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,65 @@
11
run:
2-
timeout: 3m
3-
4-
linters-settings:
5-
gocyclo:
6-
min-complexity: 15
7-
gocritic:
8-
disabled-checks:
9-
- ifElseChain
10-
2+
timeout: 10m
3+
114
linters:
125
enable:
13-
- megacheck
14-
- govet
15-
- revive
6+
- bodyclose
7+
- copyloopvar
8+
- dogsled
9+
- errcheck
10+
- exhaustive
11+
- funlen
12+
- goconst
13+
- gocritic
1614
- gocyclo
15+
- gofmt
16+
- goimports
17+
- goprintffuncname
1718
- gosec
18-
- unconvert
19-
- dupl
19+
- gosimple
20+
- govet
21+
- ineffassign
2022
- nakedret
21-
- prealloc
22-
- exportloopref
23-
- gocritic
24-
- goimports
25-
- whitespace
26-
- misspell
27-
- depguard
28-
- importas
29-
- contextcheck
23+
- noctx
3024
- nolintlint
25+
- prealloc
3126
- revive
27+
- rowserrcheck
28+
- staticcheck
29+
- stylecheck
30+
- typecheck
31+
- unconvert
32+
- unparam
33+
- unused
34+
- whitespace
35+
36+
linters-settings:
37+
funlen:
38+
lines: 100
39+
statements: 60
40+
lll:
41+
line-length: 200
42+
gosec:
43+
excludes:
44+
- G101
45+
revive:
46+
rules:
47+
- name: exported
48+
disabled: true
49+
- name: package-comments
50+
disabled: true
51+
stylecheck:
52+
checks:
53+
- all
54+
- -ST1000
55+
3256

57+
issues:
58+
exclude-use-default: false
59+
exclude-rules:
60+
- path: (.+)_test.go
61+
linters:
62+
- goconst
63+
- lll
64+
- funlen
65+
- errcheck

.goreleaser.yml

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: 2
12
project_name: cir-rotator
23
before:
34
hooks:
@@ -11,25 +12,23 @@ builds:
1112
goos:
1213
- darwin
1314
- linux
14-
- windows
1515
goarch:
1616
- amd64
17-
hooks:
18-
post:
19-
- upx --brute "{{ .Path }}"
17+
- arm64
18+
ignore:
19+
- goos: linux
20+
goarch: arm64
21+
ldflags:
22+
- -s -w -X github.com/iomarmochtar/cir-rotator/app/cmd.BuildHash={{.Commit}} -X github.com/iomarmochtar/cir-rotator/app/cmd.Version={{.Version}}
23+
tags:
24+
- static_build
2025

2126
checksum:
2227
name_template: 'checksums.txt'
2328

2429
archives:
25-
- name_template: '{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}_{{ .Version }}'
30+
- files:
31+
# Only include built binary in archive
32+
- 'none*'
2633
format: tar.gz
27-
replacements:
28-
darwin: Darwin
29-
linux: Linux
30-
windows: Windows
31-
386: i386
32-
amd64: x86_64
33-
format_overrides:
34-
- goos: windows
35-
format: zip
34+
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# 0.3.0
2+
3+
### Features and enhancements
4+
5+
- feat(registry_gcr): supporting workload identity
6+
- chore(go): bump go version to `1.23.1`
7+
- chore(gomock): change mock framework to the active fork (uber's gomock)
8+
- docs: prepare for gcr deprecation to artifact registry
9+
- docs: update description and fix broken links
10+
11+
# 0.2.0
12+
13+
### Features and enhancements
14+
15+
- feat(http): parallel execution with adjustable pool size
16+
- feat(delete/read_repo_list): read repository list json file in delete action
17+
18+
# 0.1.2
19+
20+
### Bug Fixes
21+
22+
- fix(jwt): set adjustable jwt token expiry for fixing deletion action fails if more than one hour in duration
23+
24+
25+
# 0.1.1
26+
27+
### Bug Fixes
28+
29+
- fix(app_flow): centralized deletion logic
30+
31+
# 0.1.0
32+
33+
initial release
34+
35+
### Features and enhancements
36+
37+
- feat(registry): supporting GCR

Dockerfile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
FROM golang:1.18.3-alpine3.15 as builder
1+
FROM goreleaser/goreleaser:v2.3.2 AS builder
22
WORKDIR /build
33
COPY . .
4-
RUN apk --update add make && make compile
4+
RUN goreleaser build --clean --single-target
55

6-
FROM alpine:3.15.4
6+
FROM alpine:3.20.3
77
RUN apk --no-cache add ca-certificates
8-
COPY --from=builder /build/dist/cir-rotator /usr/bin/cir-rotator
9-
ENTRYPOINT ["cir-rotator"]
8+
COPY --from=builder /build/dist/cir-rotator_linux_amd64_v1/cir-rotator /usr/bin/cir-rotator
9+
ENTRYPOINT ["gitlab-token-updater"]
1010
CMD ["--help"]

Makefile

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,48 @@
1-
NAME ?= "cir-rotator"
2-
LINTER_VERSION = 1.46.0
3-
LINTER_BIN = ./bin/golangci-lint
4-
COVERAGE_OUT = coverage.txt
5-
6-
.PHONY: setup-linter
7-
export LINTER_VERSION
8-
setup-linter:
9-
test ! -f ${LINTER_BIN} && curl -sfL https://raw.githubusercontent.com/bukalapak/toolkit-installer/master/golangci-lint.sh | sh || true
10-
11-
.PHONY: lint
12-
lint: setup-linter
13-
${LINTER_BIN} run -v
1+
GO111MODULE = on
2+
CGO_ENABLED = 0
3+
GO_FILES = $(shell go list ./... | grep -v mocks)
144

155
.PHONY: test
166
test:
17-
go test -v -cover -coverprofile=${COVERAGE_OUT} -covermode=atomic ./...
7+
go test -v $(GO_FILES) -coverprofile=coverage.out
8+
9+
.PHONY: test-s
10+
test-s:
11+
go test -v $(pkg)
12+
13+
.PHONY: gen-mocks
14+
gen-mocks:
15+
go generate $(GO_FILES)
16+
17+
.PHONY: cleantestcache
18+
cleantestcache:
19+
go clean -testcache
20+
21+
.PHONY: tidy
22+
tidy:
23+
GO111MODULE=$(GO111MODULE) go mod tidy
24+
25+
.PHONY: cover
26+
cover: cleantestcache test
27+
go tool cover -html=coverage.out -o coverage.html
28+
go tool cover -func coverage.out
29+
30+
.PHONY: cleanlintcache
31+
cleanlintcache:
32+
golangci-lint cache clean
33+
34+
.PHONY: lint
35+
lint: cleanlintcache
36+
golangci-lint run --timeout 20m ./...
1837

19-
.PHONY: coverage-html
20-
coverage-html: test
21-
go tool cover -html=${COVERAGE_OUT}
38+
.PHONY: dev-tools
39+
dev-tools:
40+
go install go.uber.org/mock/[email protected]
41+
./scripts/install_goreleaser.sh
2242

2343
.PHONY: test-all
24-
test-all: test lint
44+
test-all: cover lint
2545

26-
.PHONY: compile
27-
compile:
28-
GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -o dist/${NAME} main.go
46+
.PHONY: dist-dev
47+
dist-dev:
48+
goreleaser build --snapshot --clean --single-target

0 commit comments

Comments
 (0)