Skip to content

Commit bca90ac

Browse files
committed
Upgrade baton-sdk to v0.7.4 and Go to 1.25.2
1 parent a2755cc commit bca90ac

File tree

2,783 files changed

+4935525
-2027708
lines changed

Some content is hidden

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

2,783 files changed

+4935525
-2027708
lines changed

.github/workflows/ci.yaml

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
11
name: ci
2-
on: pull_request
2+
on:
3+
pull_request:
4+
types: [opened, reopened, synchronize]
5+
push:
6+
branches:
7+
- main
38
jobs:
49
go-lint:
510
runs-on: ubuntu-latest
611
steps:
12+
- name: Checkout code
13+
uses: actions/checkout@v4
714
- name: Install Go
8-
uses: actions/setup-go@v4
15+
uses: actions/setup-go@v5
916
with:
10-
go-version: 1.22.x
11-
- name: Checkout code
12-
uses: actions/checkout@v3
17+
go-version-file: 'go.mod'
1318
- name: Run linters
14-
uses: golangci/golangci-lint-action@v3
19+
uses: golangci/golangci-lint-action@v8
1520
with:
16-
version: latest
1721
args: --timeout=3m
1822
go-test:
1923
strategy:
2024
matrix:
21-
go-version: [1.22.x]
2225
platform: [ubuntu-latest]
2326
runs-on: ${{ matrix.platform }}
2427
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
2530
- name: Install Go
26-
if: success()
27-
uses: actions/setup-go@v4
31+
uses: actions/setup-go@v5
2832
with:
29-
go-version: ${{ matrix.go-version }}
30-
- name: Checkout code
31-
uses: actions/checkout@v3
33+
go-version-file: 'go.mod'
3234
- name: go tests
3335
run: go test -v -covermode=count -json ./... > test.json
3436
- name: annotate go tests
3537
if: always()
36-
uses: guyarb/golang-test-annotations@v0.5.1
38+
uses: guyarb/golang-test-annotations@v0.6.0
3739
with:
38-
test-results: test.json
40+
test-results: test.json

.golangci.yml

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

Makefile

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,31 @@
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-segment.exe
78
else
89
OUTPUT_PATH = ${BUILD_DIR}/baton-segment
910
endif
1011

12+
# Set the build tag conditionally based on BATON_LAMBDA_SUPPORT
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-segment
20+
build: $(GENERATED_CONF)
21+
go build ${BUILD_TAGS} -o ${OUTPUT_PATH} ./cmd/baton-segment
22+
23+
$(GENERATED_CONF): pkg/config/config.go go.mod
24+
@echo "Generating $(GENERATED_CONF)..."
25+
go generate ./pkg/config
26+
27+
.PHONY: generate
28+
generate: $(GENERATED_CONF)
1429

1530
.PHONY: update-deps
1631
update-deps:

cmd/baton-segment/config.go

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

cmd/baton-segment/main.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@ import (
55
"fmt"
66
"os"
77

8-
"github.com/conductorone/baton-sdk/pkg/cli"
8+
"github.com/conductorone/baton-sdk/pkg/config"
99
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
10+
"github.com/conductorone/baton-sdk/pkg/connectorrunner"
1011
"github.com/conductorone/baton-sdk/pkg/types"
1112
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
13+
"github.com/spf13/viper"
1214
"go.uber.org/zap"
1315

16+
segmentconfig "github.com/conductorone/baton-segment/pkg/config"
1417
"github.com/conductorone/baton-segment/pkg/connector"
1518
)
1619

@@ -19,15 +22,19 @@ var version = "dev"
1922
func main() {
2023
ctx := context.Background()
2124

22-
cfg := &config{}
23-
cmd, err := cli.NewCmd(ctx, "baton-segment", cfg, validateConfig, getConnector)
25+
_, cmd, err := config.DefineConfiguration(
26+
ctx,
27+
"baton-segment",
28+
getConnector,
29+
segmentconfig.ConfigurationSchema,
30+
connectorrunner.WithDefaultCapabilitiesConnectorBuilder(&connector.Segment{}),
31+
)
2432
if err != nil {
2533
fmt.Fprintln(os.Stderr, err.Error())
2634
os.Exit(1)
2735
}
2836

2937
cmd.Version = version
30-
cmdFlags(cmd)
3138

3239
err = cmd.Execute()
3340
if err != nil {
@@ -36,10 +43,10 @@ func main() {
3643
}
3744
}
3845

39-
func getConnector(ctx context.Context, cfg *config) (types.ConnectorServer, error) {
46+
func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, error) {
4047
l := ctxzap.Extract(ctx)
4148

42-
cb, err := connector.New(ctx, cfg.Token)
49+
cb, err := connector.New(ctx, v.GetString(segmentconfig.TokenField.FieldName))
4350
if err != nil {
4451
l.Error("error creating connector", zap.Error(err))
4552
return nil, err

0 commit comments

Comments
 (0)