Skip to content

Commit 26c1323

Browse files
committed
Upgrade baton-sdk to v0.7.4, Go to 1.25.2, and update CI workflow
1 parent 7e84f57 commit 26c1323

File tree

738 files changed

+117041
-23763
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

738 files changed

+117041
-23763
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,36 +9,34 @@ jobs:
99
go-lint:
1010
runs-on: ubuntu-latest
1111
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
1214
- name: Install Go
1315
uses: actions/setup-go@v5
1416
with:
15-
go-version: 1.23.x
16-
- name: Checkout code
17-
uses: actions/checkout@v4
17+
go-version-file: 'go.mod'
1818
- name: Run linters
19-
uses: golangci/golangci-lint-action@v6
19+
uses: golangci/golangci-lint-action@v8
2020
with:
2121
version: latest
2222
args: --timeout=3m
2323
go-test:
2424
strategy:
2525
matrix:
26-
go-version: [1.23.x]
2726
platform: [ubuntu-latest]
2827
runs-on: ${{ matrix.platform }}
2928
steps:
29+
- name: Checkout code
30+
uses: actions/checkout@v4
3031
- name: Install Go
31-
if: success()
3232
uses: actions/setup-go@v5
3333
with:
34-
go-version: ${{ matrix.go-version }}
35-
- name: Checkout code
36-
uses: actions/checkout@v4
34+
go-version-file: 'go.mod'
3735
- name: go tests
38-
run: (set -o pipefail && go test -v -covermode=count -json ./... | tee test.json)
36+
run: go test -v -covermode=count -json ./... > test.json
3937
- name: annotate go tests
4038
if: always()
41-
uses: guyarb/golang-test-annotations@v0.5.1
39+
uses: guyarb/golang-test-annotations@v0.6.0
4240
with:
4341
test-results: test.json
4442

@@ -56,12 +54,12 @@ jobs:
5654
CONNECTOR_PRINCIPAL: '9d9a62a5b834a8c9c5cf43cd234dfd4a'
5755
CONNECTOR_PRINCIPAL_TYPE: 'user'
5856
steps:
57+
- name: Checkout code
58+
uses: actions/checkout@v4
5959
- name: Install Go
6060
uses: actions/setup-go@v5
6161
with:
62-
go-version: 1.23.x
63-
- name: Checkout code
64-
uses: actions/checkout@v4
62+
go-version-file: 'go.mod'
6563
- name: Build baton-cloudflare-zero-trust
6664
run: go build ./cmd/baton-cloudflare-zero-trust
6765
- name: Test grant/revoke

.golangci.yml

Lines changed: 118 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,122 @@
1-
#AUTO GENERATED CODE. UPDATE THE CONFIG IN BATON-TEMPLATE FIRST
2-
linters-settings:
3-
exhaustive:
4-
default-signifies-exhaustive: true
5-
gocritic:
6-
enabled-checks:
7-
- ruleguard
8-
# The list of supported checkers can be find in https://go-critic.github.io/overview.
9-
settings:
10-
underef:
11-
# Whether to skip (*x).method() calls where x is a pointer receiver.
12-
skipRecvDeref: false
13-
ruleguard:
14-
rules: "${configDir}/tools/rules.go"
15-
govet:
16-
enable-all: true
17-
disable:
18-
- fieldalignment # too strict
19-
- shadow # complains too much about shadowing errors. All research points to this being fine.
20-
nakedret:
21-
max-func-lines: 0
22-
nolintlint:
23-
allow-no-explanation: [forbidigo, tracecheck, gomnd, gochecknoinits, makezero]
24-
require-explanation: true
25-
require-specific: true
26-
revive:
27-
ignore-generated-header: true
28-
severity: error
29-
rules:
30-
- name: atomic
31-
- name: line-length-limit
32-
arguments: [200]
33-
# These are functions that we use without checking the errors often. Most of these can't return an error even
34-
# though they implement an interface that can.
35-
- name: unhandled-error
36-
arguments:
37-
- fmt.Printf
38-
- fmt.Println
39-
- fmt.Fprint
40-
- fmt.Fprintf
41-
- fmt.Fprintln
42-
- os.Stderr.Sync
43-
- sb.WriteString
44-
- buf.WriteString
45-
- hasher.Write
46-
- os.Setenv
47-
- os.RemoveAll
48-
- name: var-naming
49-
arguments: [["ID", "URL", "HTTP", "API"], []]
50-
tenv:
51-
all: true
1+
version: "2"
2+
run:
3+
modules-download-mode: readonly
524
linters:
53-
disable-all: true
5+
default: none
546
enable:
55-
- errcheck # Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases
56-
- gosimple # Linter for Go source code that specializes in simplifying a code
57-
- govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string
58-
- ineffassign # Detects when assignments to existing variables are not used
59-
- staticcheck # Staticcheck is a go vet on steroids, applying a ton of static analysis checks
60-
- typecheck # Like the front-end of a Go compiler, parses and type-checks Go code
61-
- unused # Checks Go code for unused constants, variables, functions and types
62-
- asasalint # Check for pass []any as any in variadic func(...any)
63-
- asciicheck # Simple linter to check that your code does not contain non-ASCII identifiers
64-
- bidichk # Checks for dangerous unicode character sequences
65-
- bodyclose # checks whether HTTP response body is closed successfully
66-
- durationcheck # check for two durations multiplied together
67-
- errorlint # errorlint is a linter for that can be used to find code that will cause problems with the error wrapping scheme introduced in Go 1.13.
68-
- exhaustive # check exhaustiveness of enum switch statements
69-
- forbidigo # Forbids identifiers
70-
- gochecknoinits # Checks that no init functions are present in Go code
71-
- goconst # Finds repeated strings that could be replaced by a constant
72-
- gocritic # Provides diagnostics that check for bugs, performance and style issues.
73-
- godot # Check if comments end in a period
74-
- goimports # In addition to fixing imports, goimports also formats your code in the same style as gofmt.
75-
- gomoddirectives # Manage the use of 'replace', 'retract', and 'excludes' directives in go.mod.
76-
- goprintffuncname # Checks that printf-like functions are named with f at the end
77-
- gosec # Inspects source code for security problems
78-
- nakedret # Finds naked returns in functions greater than a specified function length
79-
- nilerr # Finds the code that returns nil even if it checks that the error is not nil.
80-
- noctx # noctx finds sending http request without context.Context
81-
- nolintlint # Reports ill-formed or insufficient nolint directives
82-
- nonamedreturns # Reports all named returns
83-
- nosprintfhostport # Checks for misuse of Sprintf to construct a host with port in a URL.
84-
- predeclared # find code that shadows one of Go's predeclared identifiers
85-
- revive # Fast, configurable, extensible, flexible, and beautiful linter for Go. Drop-in replacement of golint.
86-
- tenv # tenv is analyzer that detects using os.Setenv instead of t.Setenv since Go1.17
87-
- tparallel # tparallel detects inappropriate usage of t.Parallel() method in your Go test codes
88-
- unconvert # Remove unnecessary type conversions
89-
- usestdlibvars # detect the possibility to use variables/constants from the Go standard library
90-
- whitespace # Tool for detection of leading and trailing whitespace
7+
- asasalint
8+
- asciicheck
9+
- bidichk
10+
- bodyclose
11+
- durationcheck
12+
- errcheck
13+
- errorlint
14+
- exhaustive
15+
- forbidigo
16+
- gochecknoinits
17+
- goconst
18+
- gocritic
19+
- godot
20+
- gomoddirectives
21+
- goprintffuncname
22+
- gosec
23+
- govet
24+
- ineffassign
25+
- nakedret
26+
- nilerr
27+
- noctx
28+
- nolintlint
29+
- nonamedreturns
30+
- nosprintfhostport
31+
- predeclared
32+
- revive
33+
- staticcheck
34+
- tparallel
35+
- unconvert
36+
- unused
37+
- usestdlibvars
38+
- whitespace
39+
settings:
40+
exhaustive:
41+
default-signifies-exhaustive: true
42+
gocritic:
43+
enabled-checks:
44+
- ruleguard
45+
settings:
46+
ruleguard:
47+
rules: ${base-path}/tools/rules.go
48+
underef:
49+
skipRecvDeref: false
50+
govet:
51+
disable:
52+
- fieldalignment
53+
- shadow
54+
enable-all: true
55+
nakedret:
56+
max-func-lines: 0
57+
nolintlint:
58+
require-explanation: true
59+
require-specific: true
60+
allow-no-explanation:
61+
- forbidigo
62+
- tracecheck
63+
- gomnd
64+
- gochecknoinits
65+
- makezero
66+
revive:
67+
severity: error
68+
rules:
69+
- name: atomic
70+
- name: line-length-limit
71+
arguments:
72+
- 200
73+
- name: unhandled-error
74+
arguments:
75+
- fmt.Printf
76+
- fmt.Println
77+
- fmt.Fprint
78+
- fmt.Fprintf
79+
- fmt.Fprintln
80+
- os.Stderr.Sync
81+
- sb.WriteString
82+
- buf.WriteString
83+
- hasher.Write
84+
- os.Setenv
85+
- os.RemoveAll
86+
- name: var-naming
87+
arguments:
88+
- - ID
89+
- URL
90+
- HTTP
91+
- API
92+
- []
93+
exclusions:
94+
generated: lax
95+
presets:
96+
- comments
97+
- common-false-positives
98+
- legacy
99+
- std-error-handling
100+
rules:
101+
- linters:
102+
- godot
103+
source: (TODO)
104+
- path: (.+)\.go$
105+
text: third_party$
106+
- path: (.+)\.go$
107+
text: builtin$
108+
- path: (.+)\.go$
109+
text: examples$
110+
paths:
111+
- third_party$
112+
- builtin$
113+
- examples$
91114
issues:
92115
max-same-issues: 50
93-
exclude-rules:
94-
# Don't require TODO comments to end in a period
95-
- source: "(TODO)"
96-
linters: [godot]
116+
formatters:
117+
exclusions:
118+
generated: lax
119+
paths:
120+
- third_party$
121+
- builtin$
122+
- examples$

Makefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,30 @@
11
GOOS = $(shell go env GOOS)
22
GOARCH = $(shell go env GOARCH)
33
BUILD_DIR = dist/${GOOS}_${GOARCH}
4+
GENERATED_CONF := pkg/config/conf.gen.go
45

56
ifeq ($(GOOS),windows)
67
OUTPUT_PATH = ${BUILD_DIR}/baton-cloudflare-zero-trust.exe
78
else
89
OUTPUT_PATH = ${BUILD_DIR}/baton-cloudflare-zero-trust
910
endif
1011

12+
# Set the build tag conditionally based on ENABLE_LAMBDA
13+
ifdef BATON_LAMBDA_SUPPORT
14+
BUILD_TAGS=-tags baton_lambda_support
15+
else
16+
BUILD_TAGS=
17+
endif
18+
1119
.PHONY: build
12-
build:
13-
go build -o ${OUTPUT_PATH} ./cmd/baton-cloudflare-zero-trust
20+
build: $(GENERATED_CONF)
21+
go build ${BUILD_TAGS} -o ${OUTPUT_PATH} ./cmd/baton-cloudflare-zero-trust
22+
23+
$(GENERATED_CONF): pkg/config/config.go go.mod
24+
@echo "Generating $(GENERATED_CONF)..."
25+
go generate ./pkg/config
26+
27+
generate: $(GENERATED_CONF)
1428

1529
.PHONY: update-deps
1630
update-deps:

cmd/baton-cloudflare-zero-trust/config.go

Lines changed: 0 additions & 46 deletions
This file was deleted.

cmd/baton-cloudflare-zero-trust/config_test.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package main
33
import (
44
"testing"
55

6-
"github.com/conductorone/baton-sdk/pkg/field"
6+
"github.com/conductorone/baton-cloudflare-zero-trust/pkg/config"
77
"github.com/conductorone/baton-sdk/pkg/test"
88
"github.com/conductorone/baton-sdk/pkg/ustrings"
99
)
@@ -44,10 +44,7 @@ func TestConfigs(t *testing.T) {
4444

4545
test.ExerciseTestCasesFromExpressions(
4646
t,
47-
field.NewConfiguration(
48-
configurationFields,
49-
field.WithConstraints(fieldRelationships...),
50-
),
47+
config.Config,
5148
nil,
5249
ustrings.ParseFlags,
5350
testCases,

0 commit comments

Comments
 (0)