Skip to content

Commit f5e6bdb

Browse files
authored
Merge pull request #18 from ConductorOne/ggreer/fix-pagestate
Upgrade baton-sdk. Reduce the size of pagestates.
2 parents b40314e + f8e3885 commit f5e6bdb

File tree

713 files changed

+3146468
-1905665
lines changed

Some content is hidden

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

713 files changed

+3146468
-1905665
lines changed

cmd/baton-retool/config.go

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,36 @@
11
package main
22

33
import (
4-
"context"
5-
"fmt"
6-
7-
"github.com/conductorone/baton-sdk/pkg/cli"
4+
"github.com/conductorone/baton-sdk/pkg/field"
85
)
96

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
7+
var (
8+
ConnectionString = field.StringField(
9+
"connection-string",
10+
field.WithRequired(true),
11+
field.WithDescription("The connection string for connecting to retool database"),
12+
)
13+
SkipPages = field.BoolField(
14+
"skip-pages",
15+
field.WithDescription("Skip syncing pages"),
16+
)
17+
SkipResources = field.BoolField(
18+
"skip-resources",
19+
field.WithDescription("Skip syncing resources"),
20+
)
21+
SkipDisabledUsers = field.BoolField(
22+
"skip-disabled-users",
23+
field.WithDescription("Skip syncing disabled users"),
24+
)
25+
)
1326

14-
ConnectionString string `mapstructure:"connection-string"`
15-
SkipPages bool `mapstructure:"skip-pages"`
16-
SkipResources bool `mapstructure:"skip-resources"`
17-
SkipDisabledUsers bool `mapstructure:"skip-disabled-users"`
27+
var configurationFields = []field.SchemaField{
28+
ConnectionString,
29+
SkipPages,
30+
SkipResources,
31+
SkipDisabledUsers,
1832
}
1933

20-
// validateConfig is run after the configuration is loaded, and should return an error if it isn't valid.
21-
func validateConfig(ctx context.Context, cfg *config) error {
22-
if cfg.ConnectionString == "" {
23-
return fmt.Errorf("--connection-string is required")
24-
}
34+
var configRelations = []field.SchemaFieldRelationship{}
2535

26-
return nil
27-
}
36+
var configuration = field.NewConfiguration(configurationFields, configRelations...)

cmd/baton-retool/main.go

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

8-
"github.com/conductorone/baton-sdk/pkg/cli"
8+
configschema "github.com/conductorone/baton-sdk/pkg/config"
99
"github.com/conductorone/baton-sdk/pkg/connectorbuilder"
1010
"github.com/conductorone/baton-sdk/pkg/types"
1111
"github.com/grpc-ecosystem/go-grpc-middleware/logging/zap/ctxzap"
12+
"github.com/spf13/viper"
1213
"go.uber.org/zap"
1314

1415
"github.com/conductorone/baton-retool/pkg/connector"
@@ -19,36 +20,30 @@ var version = "dev"
1920
func main() {
2021
ctx := context.Background()
2122

22-
cfg := &config{}
23-
cmd, err := cli.NewCmd(ctx, "baton-retool", cfg, validateConfig, getConnector)
23+
_, cmd, err := configschema.DefineConfiguration(ctx, "baton-retool", getConnector, configuration)
2424
if err != nil {
2525
fmt.Fprintln(os.Stderr, err.Error())
2626
os.Exit(1)
2727
}
2828

2929
cmd.Version = version
3030

31-
cmd.PersistentFlags().String(
32-
"connection-string",
33-
"user=retool password=retool host=localhost port=5432 dbname=hammerhead_production",
34-
"The connection string for connecting to retool database ($BATON_CONNECTION_STRING)",
35-
)
36-
37-
cmd.PersistentFlags().Bool("skip-pages", false, "Skip syncing pages")
38-
cmd.PersistentFlags().Bool("skip-resources", false, "Skip syncing resources")
39-
cmd.PersistentFlags().Bool("skip-disabled-users", false, "Skip syncing disabled users")
40-
4131
err = cmd.Execute()
4232
if err != nil {
4333
fmt.Fprintln(os.Stderr, err.Error())
4434
os.Exit(1)
4535
}
4636
}
4737

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

51-
cb, err := connector.New(ctx, cfg.ConnectionString, cfg.SkipPages, cfg.SkipResources, cfg.SkipDisabledUsers)
41+
connString := v.GetString(ConnectionString.FieldName)
42+
skipPages := v.GetBool(SkipPages.FieldName)
43+
skipResources := v.GetBool(SkipResources.FieldName)
44+
skipDisabledUsers := v.GetBool(SkipDisabledUsers.FieldName)
45+
46+
cb, err := connector.New(ctx, connString, skipPages, skipResources, skipDisabledUsers)
5247
if err != nil {
5348
l.Error("error creating connector builder", zap.Error(err))
5449
return nil, err

go.mod

Lines changed: 51 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
11
module github.com/conductorone/baton-retool
22

3-
go 1.20
3+
go 1.21
4+
5+
toolchain go1.22.5
46

57
require (
6-
github.com/conductorone/baton-sdk v0.1.22
8+
github.com/conductorone/baton-sdk v0.2.10
79
github.com/georgysavva/scany v1.2.1
810
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
911
github.com/jackc/pgx/v4 v4.18.1
10-
go.uber.org/zap v1.26.0
11-
golang.org/x/text v0.14.0
12+
github.com/spf13/viper v1.18.2
13+
go.uber.org/zap v1.27.0
14+
golang.org/x/text v0.16.0
1215
)
1316

1417
require (
1518
filippo.io/age v1.1.1 // indirect
1619
filippo.io/edwards25519 v1.1.0 // indirect
17-
github.com/aws/aws-sdk-go-v2 v1.24.1 // indirect
18-
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.5.4 // indirect
19-
github.com/aws/aws-sdk-go-v2/config v1.26.6 // indirect
20-
github.com/aws/aws-sdk-go-v2/credentials v1.16.16 // indirect
21-
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.14.11 // indirect
22-
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.15.15 // indirect
23-
github.com/aws/aws-sdk-go-v2/internal/configsources v1.2.10 // indirect
24-
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.5.10 // indirect
25-
github.com/aws/aws-sdk-go-v2/internal/ini v1.7.3 // indirect
26-
github.com/aws/aws-sdk-go-v2/internal/v4a v1.2.10 // indirect
27-
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.10.4 // indirect
28-
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.2.10 // indirect
29-
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.10.10 // indirect
30-
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.16.10 // indirect
31-
github.com/aws/aws-sdk-go-v2/service/s3 v1.48.1 // indirect
32-
github.com/aws/aws-sdk-go-v2/service/sso v1.18.7 // indirect
33-
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.21.7 // indirect
34-
github.com/aws/aws-sdk-go-v2/service/sts v1.26.7 // indirect
35-
github.com/aws/smithy-go v1.19.0 // indirect
20+
github.com/aws/aws-sdk-go-v2 v1.26.1 // indirect
21+
github.com/aws/aws-sdk-go-v2/aws/protocol/eventstream v1.6.2 // indirect
22+
github.com/aws/aws-sdk-go-v2/config v1.27.11 // indirect
23+
github.com/aws/aws-sdk-go-v2/credentials v1.17.11 // indirect
24+
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.1 // indirect
25+
github.com/aws/aws-sdk-go-v2/feature/s3/manager v1.16.15 // indirect
26+
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.5 // indirect
27+
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.5 // indirect
28+
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.0 // indirect
29+
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.5 // indirect
30+
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.2 // indirect
31+
github.com/aws/aws-sdk-go-v2/service/internal/checksum v1.3.7 // indirect
32+
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.7 // indirect
33+
github.com/aws/aws-sdk-go-v2/service/internal/s3shared v1.17.5 // indirect
34+
github.com/aws/aws-sdk-go-v2/service/s3 v1.53.1 // indirect
35+
github.com/aws/aws-sdk-go-v2/service/sso v1.20.5 // indirect
36+
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.23.4 // indirect
37+
github.com/aws/aws-sdk-go-v2/service/sts v1.28.6 // indirect
38+
github.com/aws/smithy-go v1.20.2 // indirect
3639
github.com/benbjohnson/clock v1.3.5 // indirect
40+
github.com/deckarep/golang-set/v2 v2.6.0 // indirect
3741
github.com/doug-martin/goqu/v9 v9.19.0 // indirect
3842
github.com/dustin/go-humanize v1.0.1 // indirect
3943
github.com/envoyproxy/protoc-gen-validate v1.0.4 // indirect
4044
github.com/fsnotify/fsnotify v1.7.0 // indirect
4145
github.com/glebarez/go-sqlite v1.22.0 // indirect
42-
github.com/go-jose/go-jose/v3 v3.0.1 // indirect
46+
github.com/go-jose/go-jose/v3 v3.0.3 // indirect
4347
github.com/go-ole/go-ole v1.3.0 // indirect
44-
github.com/golang/protobuf v1.5.3 // indirect
48+
github.com/golang/protobuf v1.5.4 // indirect
4549
github.com/google/uuid v1.6.0 // indirect
4650
github.com/hashicorp/hcl v1.0.0 // indirect
4751
github.com/inconshreveable/mousetrap v1.1.0 // indirect
@@ -54,49 +58,49 @@ require (
5458
github.com/jackc/pgtype v1.14.2 // indirect
5559
github.com/jackc/puddle v1.3.0 // indirect
5660
github.com/jmespath/go-jmespath v0.4.0 // indirect
57-
github.com/klauspost/compress v1.17.6 // indirect
58-
github.com/lufia/plan9stats v0.0.0-20231016141302-07b5767bb0ed // indirect
61+
github.com/klauspost/compress v1.17.8 // indirect
62+
github.com/lufia/plan9stats v0.0.0-20240408141607-282e7b5d6b74 // indirect
5963
github.com/magiconair/properties v1.8.7 // indirect
6064
github.com/mattn/go-isatty v0.0.20 // indirect
6165
github.com/mitchellh/mapstructure v1.5.0 // indirect
6266
github.com/ncruces/go-strftime v0.1.9 // indirect
63-
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
64-
github.com/power-devops/perfstat v0.0.0-20221212215047-62379fc7944b // indirect
67+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
68+
github.com/power-devops/perfstat v0.0.0-20240221224432-82ca36839d55 // indirect
6569
github.com/pquerna/xjwt v0.2.0 // indirect
6670
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
6771
github.com/sagikazarmark/locafero v0.4.0 // indirect
6872
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
6973
github.com/segmentio/ksuid v1.0.4 // indirect
70-
github.com/shirou/gopsutil/v3 v3.24.1 // indirect
74+
github.com/shirou/gopsutil/v3 v3.24.4 // indirect
7175
github.com/shoenig/go-m1cpu v0.1.6 // indirect
7276
github.com/sourcegraph/conc v0.3.0 // indirect
7377
github.com/spf13/afero v1.11.0 // indirect
7478
github.com/spf13/cast v1.6.0 // indirect
7579
github.com/spf13/cobra v1.8.0 // indirect
7680
github.com/spf13/pflag v1.0.5 // indirect
77-
github.com/spf13/viper v1.18.2 // indirect
7881
github.com/subosito/gotenv v1.6.0 // indirect
79-
github.com/tklauser/go-sysconf v0.3.13 // indirect
80-
github.com/tklauser/numcpus v0.7.0 // indirect
82+
github.com/tklauser/go-sysconf v0.3.14 // indirect
83+
github.com/tklauser/numcpus v0.8.0 // indirect
8184
github.com/yusufpapurcu/wmi v1.2.4 // indirect
85+
go.opentelemetry.io/otel v1.27.0 // indirect
86+
go.opentelemetry.io/otel/metric v1.27.0 // indirect
8287
go.uber.org/multierr v1.11.0 // indirect
83-
go.uber.org/ratelimit v0.3.0 // indirect
84-
golang.org/x/crypto v0.19.0 // indirect
85-
golang.org/x/exp v0.0.0-20240205201215-2c58cdc269a3 // indirect
86-
golang.org/x/net v0.21.0 // indirect
87-
golang.org/x/oauth2 v0.17.0 // indirect
88-
golang.org/x/sync v0.6.0 // indirect
89-
golang.org/x/sys v0.17.0 // indirect
90-
google.golang.org/appengine v1.6.8 // indirect
91-
google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014 // indirect
92-
google.golang.org/grpc v1.61.0 // indirect
93-
google.golang.org/protobuf v1.32.0 // indirect
88+
go.uber.org/ratelimit v0.3.1 // indirect
89+
golang.org/x/crypto v0.24.0 // indirect
90+
golang.org/x/exp v0.0.0-20240506185415-9bf2ced13842 // indirect
91+
golang.org/x/net v0.26.0 // indirect
92+
golang.org/x/oauth2 v0.20.0 // indirect
93+
golang.org/x/sync v0.7.0 // indirect
94+
golang.org/x/sys v0.21.0 // indirect
95+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240506185236-b8a5c65736ae // indirect
96+
google.golang.org/grpc v1.63.2 // indirect
97+
google.golang.org/protobuf v1.34.1 // indirect
9498
gopkg.in/ini.v1 v1.67.0 // indirect
9599
gopkg.in/square/go-jose.v2 v2.6.0 // indirect
96100
gopkg.in/yaml.v2 v2.4.0 // indirect
97101
gopkg.in/yaml.v3 v3.0.1 // indirect
98-
modernc.org/libc v1.41.0 // indirect
102+
modernc.org/libc v1.50.5 // indirect
99103
modernc.org/mathutil v1.6.0 // indirect
100-
modernc.org/memory v1.7.2 // indirect
101-
modernc.org/sqlite v1.28.0 // indirect
104+
modernc.org/memory v1.8.0 // indirect
105+
modernc.org/sqlite v1.29.9 // indirect
102106
)

0 commit comments

Comments
 (0)