Skip to content

Commit 6d6c5db

Browse files
authored
Use new configuration schema (#7)
* Update vendor and dependencies * Use new configuration schema * Remove unknown directive toolchain from go.mod * Set go to version 1.21 in go.mod
1 parent bf16c7c commit 6d6c5db

File tree

1,998 files changed

+3388829
-1940291
lines changed

Some content is hidden

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

1,998 files changed

+3388829
-1940291
lines changed

cmd/baton-sql-server/config.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/conductorone/baton-sdk/pkg/cli"
7+
"github.com/conductorone/baton-sdk/pkg/field"
8+
"github.com/spf13/viper"
89
)
910

10-
// config defines the external configuration required for the connector to run.
11-
type config struct {
12-
cli.BaseConfig `mapstructure:",squash"` // Puts the base config options in the same place as the connector options
13-
14-
Dsn string `mapstructure:"dsn"`
15-
}
11+
var (
12+
dns = field.StringField("dns",
13+
field.WithDescription("The connection string for connecting to SQL Server"),
14+
field.WithRequired(true))
15+
)
1616

1717
// validateConfig is run after the configuration is loaded, and should return an error if it isn't valid.
18-
func validateConfig(ctx context.Context, cfg *config) error {
19-
if cfg.Dsn == "" {
18+
func validateConfig(_ context.Context, v *viper.Viper) error {
19+
if v.GetString(dns.FieldName) == "" {
2020
return fmt.Errorf("--dsn is required")
2121
}
2222

cmd/baton-sql-server/main.go

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

8-
"github.com/conductorone/baton-sdk/pkg/cli"
8+
config "github.com/conductorone/baton-sdk/pkg/config"
99
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
10+
"github.com/conductorone/baton-sdk/pkg/field"
1011
"github.com/conductorone/baton-sdk/pkg/types"
1112
"github.com/conductorone/baton-sql-server/pkg/connector"
1213
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
14+
"github.com/spf13/viper"
1315
"go.uber.org/zap"
1416
)
1517

@@ -18,15 +20,12 @@ var version = "dev"
1820
func main() {
1921
ctx := context.Background()
2022

21-
cfg := &config{}
22-
cmd, err := cli.NewCmd(ctx, "baton-sql-server", cfg, validateConfig, getConnector)
23+
_, cmd, err := config.DefineConfiguration(ctx, "baton-sql-server", getConnector, []field.SchemaField{dns}, nil)
2324
if err != nil {
2425
fmt.Fprintln(os.Stderr, err.Error())
2526
os.Exit(1)
2627
}
27-
2828
cmd.Version = version
29-
cmd.PersistentFlags().String("dsn", "", "The connection string for connecting to SQL Server ($BATON_DSN)")
3029

3130
err = cmd.Execute()
3231
if err != nil {
@@ -35,10 +34,14 @@ func main() {
3534
}
3635
}
3736

38-
func getConnector(ctx context.Context, cfg *config) (types.ConnectorServer, error) {
37+
func getConnector(ctx context.Context, v *viper.Viper) (types.ConnectorServer, error) {
3938
l := ctxzap.Extract(ctx)
4039

41-
cb, err := connector.New(ctx, cfg.Dsn)
40+
if err := validateConfig(ctx, v); err != nil {
41+
return nil, err
42+
}
43+
44+
cb, err := connector.New(ctx, v.GetString(dns.FieldName))
4245
if err != nil {
4346
l.Error("error creating connector", zap.Error(err))
4447
return nil, err

go.mod

Lines changed: 70 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,101 @@
11
module github.com/conductorone/baton-sql-server
22

3-
go 1.20
3+
go 1.21
44

55
require (
6-
github.com/conductorone/baton-sdk v0.1.0
6+
github.com/conductorone/baton-sdk v0.2.1
77
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
88
github.com/jmoiron/sqlx v1.3.5
99
github.com/microsoft/go-mssqldb v1.3.0
10-
github.com/stretchr/testify v1.8.4
11-
go.uber.org/zap v1.24.0
10+
github.com/spf13/viper v1.18.2
11+
github.com/stretchr/testify v1.9.0
12+
go.uber.org/zap v1.27.0
1213
)
1314

1415
require (
15-
github.com/aws/aws-sdk-go-v2 v1.18.1 // indirect
16-
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.4.10 // indirect
17-
github.com/aws/aws-sdk-go-v2/config v1.18.27 // indirect
18-
github.com/aws/aws-sdk-go-v2/credentials v1.13.26 // indirect
19-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.13.4 // indirect
20-
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.11.71 // indirect
21-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.1.34 // indirect
22-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.4.28 // indirect
23-
github.com/aws/aws-sdk-go-v2/internal/ini v1.3.35 // indirect
24-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.0.26 // indirect
25-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.9.11 // indirect
26-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.1.29 // indirect
27-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.9.28 // indirect
28-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.14.3 // indirect
29-
github.com/aws/aws-sdk-go-v2/service/s3 v1.36.0 // indirect
30-
github.com/aws/aws-sdk-go-v2/service/sso v1.12.12 // indirect
31-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.14.12 // indirect
32-
github.com/aws/aws-sdk-go-v2/service/sts v1.19.2 // indirect
33-
github.com/aws/smithy-go v1.13.5 // indirect
16+
filippo.io/age v1.1.1 // indirect
17+
filippo.io/edwards25519 v1.1.0 // indirect
18+
github.com/aws/aws-sdk-go-v2 v1.26.1 // indirect
19+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
20+
github.com/aws/aws-sdk-go-v2/config v1.27.11 // indirect
21+
github.com/aws/aws-sdk-go-v2/credentials v1.17.11 // indirect
22+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect
23+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15 // indirect
24+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 // indirect
25+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 // indirect
26+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
27+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.5 // indirect
28+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
29+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.7 // indirect
30+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 // indirect
31+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.5 // indirect
32+
github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1 // indirect
33+
github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 // indirect
34+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect
35+
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect
36+
github.com/aws/smithy-go v1.20.2 // indirect
3437
github.com/benbjohnson/clock v1.3.5 // indirect
35-
github.com/davecgh/go-spew v1.1.1 // indirect
36-
github.com/doug-martin/goqu/v9 v9.18.0 // indirect
38+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
39+
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
40+
github.com/doug-martin/goqu/v9 v9.19.0 // indirect
3741
github.com/dustin/go-humanize v1.0.1 // indirect
38-
github.com/envoyproxy/protoc-gen-validate v1.0.2 // indirect
39-
github.com/fsnotify/fsnotify v1.6.0 // indirect
40-
github.com/glebarez/go-sqlite v1.21.2 // indirect
41-
github.com/go-jose/go-jose/v3 v3.0.0 // indirect
42-
github.com/go-ole/go-ole v1.2.6 // indirect
42+
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
43+
github.com/fsnotify/fsnotify v1.7.0 // indirect
44+
github.com/glebarez/go-sqlite v1.22.0 // indirect
45+
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
46+
github.com/go-ole/go-ole v1.3.0 // indirect
4347
github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 // indirect
4448
github.com/golang-sql/sqlexp v0.1.0 // indirect
45-
github.com/golang/protobuf v1.5.3 // indirect
46-
github.com/google/uuid v1.3.0 // indirect
49+
github.com/golang/protobuf v1.5.4 // indirect
50+
github.com/google/uuid v1.6.0 // indirect
4751
github.com/hashicorp/hcl v1.0.0 // indirect
4852
github.com/inconshreveable/mousetrap v1.1.0 // indirect
4953
github.com/jmespath/go-jmespath v0.4.0 // indirect
50-
github.com/klauspost/compress v1.16.7 // indirect
51-
github.com/lufia/plan9stats v0.0.0-20230326075908-cb1d2100619a // indirect
54+
github.com/klauspost/compress v1.17.8 // indirect
55+
github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 // indirect
5256
github.com/magiconair/properties v1.8.7 // indirect
53-
github.com/mattn/go-isatty v0.0.19 // indirect
57+
github.com/mattn/go-isatty v0.0.20 // indirect
5458
github.com/mitchellh/mapstructure v1.5.0 // indirect
55-
github.com/pelletier/go-toml/v2 v2.0.8 // indirect
56-
github.com/pmezard/go-difflib v1.0.0 // indirect
57-
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
59+
github.com/ncruces/go-strftime v0.1.9 // indirect
60+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
61+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
62+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
5863
github.com/pquerna/xjwt v0.2.0 // indirect
5964
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
65+
github.com/sagikazarmark/locafero v0.4.0 // indirect
66+
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
6067
github.com/segmentio/ksuid v1.0.4 // indirect
61-
github.com/shirou/gopsutil/v3 v3.23.6 // indirect
68+
github.com/shirou/gopsutil/v3 v3.24.4 // indirect
6269
github.com/shoenig/go-m1cpu v0.1.6 // indirect
63-
github.com/spf13/afero v1.9.5 // indirect
64-
github.com/spf13/cast v1.5.1 // indirect
65-
github.com/spf13/cobra v1.7.0 // indirect
66-
github.com/spf13/jwalterweatherman v1.1.0 // indirect
70+
github.com/sourcegraph/conc v0.3.0 // indirect
71+
github.com/spf13/afero v1.11.0 // indirect
72+
github.com/spf13/cast v1.6.0 // indirect
73+
github.com/spf13/cobra v1.8.0 // indirect
6774
github.com/spf13/pflag v1.0.5 // indirect
68-
github.com/spf13/viper v1.16.0 // indirect
69-
github.com/subosito/gotenv v1.4.2 // indirect
70-
github.com/tklauser/go-sysconf v0.3.11 // indirect
71-
github.com/tklauser/numcpus v0.6.1 // indirect
72-
github.com/yusufpapurcu/wmi v1.2.3 // indirect
73-
go.uber.org/atomic v1.11.0 // indirect
75+
github.com/subosito/gotenv v1.6.0 // indirect
76+
github.com/tklauser/go-sysconf v0.3.14 // indirect
77+
github.com/tklauser/numcpus v0.8.0 // indirect
78+
github.com/yusufpapurcu/wmi v1.2.4 // indirect
79+
go.opentelemetry.io/otel v1.27.0 // indirect
80+
go.opentelemetry.io/otel/metric v1.27.0 // indirect
7481
go.uber.org/multierr v1.11.0 // indirect
75-
go.uber.org/ratelimit v0.3.0 // indirect
76-
golang.org/x/crypto v0.11.0 // indirect
77-
golang.org/x/net v0.12.0 // indirect
78-
golang.org/x/oauth2 v0.10.0 // indirect
79-
golang.org/x/sys v0.10.0 // indirect
80-
golang.org/x/term v0.10.0 // indirect
81-
golang.org/x/text v0.11.0 // indirect
82-
google.golang.org/appengine v1.6.7 // indirect
83-
google.golang.org/genproto/googleapis/rpc v0.0.0-20230710151506-e685fd7b542b // indirect
84-
google.golang.org/grpc v1.56.2 // indirect
85-
google.golang.org/protobuf v1.31.0 // indirect
82+
go.uber.org/ratelimit v0.3.1 // indirect
83+
golang.org/x/crypto v0.24.0 // indirect
84+
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
85+
golang.org/x/net v0.26.0 // indirect
86+
golang.org/x/oauth2 v0.20.0 // indirect
87+
golang.org/x/sync v0.7.0 // indirect
88+
golang.org/x/sys v0.21.0 // indirect
89+
golang.org/x/text v0.16.0 // indirect
90+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae // indirect
91+
google.golang.org/grpc v1.63.2 // indirect
92+
google.golang.org/protobuf v1.34.1 // indirect
8693
gopkg.in/ini.v1 v1.67.0 // indirect
8794
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
8895
gopkg.in/yaml.v2 v2.4.0 // indirect
8996
gopkg.in/yaml.v3 v3.0.1 // indirect
90-
modernc.org/libc v1.24.1 // indirect
97+
modernc.org/libc v1.50.5 // indirect
9198
modernc.org/mathutil v1.6.0 // indirect
92-
modernc.org/memory v1.6.0 // indirect
93-
modernc.org/sqlite v1.23.1 // indirect
99+
modernc.org/memory v1.8.0 // indirect
100+
modernc.org/sqlite v1.29.9 // indirect
94101
)

0 commit comments

Comments
 (0)