Skip to content

Commit 9c345e2

Browse files
authored
Merge pull request #38 from ConductorOne/lauren/skip-projects-option
Add skip projects option
2 parents 5b82a66 + fceafcf commit 9c345e2

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

cmd/baton-linear/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func main() {
3636

3737
func getConnector(ctx context.Context, lc *cfg.Linear) (types.ConnectorServer, error) {
3838
l := ctxzap.Extract(ctx)
39-
cb, err := connector.New(ctx, lc.ApiKey)
39+
cb, err := connector.New(ctx, lc.ApiKey, lc.SkipProjects)
4040
if err != nil {
4141
l.Error("error creating connector", zap.Error(err))
4242
return nil, err

pkg/config/conf.gen.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/config/config.go

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,26 @@ import (
44
"github.com/conductorone/baton-sdk/pkg/field"
55
)
66

7-
var apiKey = field.StringField(
8-
"api-key",
9-
field.WithDisplayName("API key"),
10-
field.WithRequired(true),
11-
field.WithDescription("The Linear Personal API key used to connect to the Linear API"),
12-
field.WithIsSecret(true),
7+
var (
8+
apiKey = field.StringField(
9+
"api-key",
10+
field.WithDisplayName("API key"),
11+
field.WithRequired(true),
12+
field.WithDescription("The Linear Personal API key used to connect to the Linear API"),
13+
field.WithIsSecret(true),
14+
)
15+
skipProjects = field.BoolField(
16+
"skip-projects",
17+
field.WithDisplayName("Skip projects"),
18+
field.WithDescription("Skip syncing projects."),
19+
)
1320
)
1421

1522
var externalTicketField = field.TicketingField.ExportAs(field.ExportTargetGUI)
1623

1724
//go:generate go run ./gen
1825
var Config = field.NewConfiguration(
19-
[]field.SchemaField{apiKey, externalTicketField},
26+
[]field.SchemaField{apiKey, externalTicketField, skipProjects},
2027
field.WithConnectorDisplayName("Linear"),
2128
field.WithHelpUrl("/docs/baton/linear"),
2229
field.WithIconUrl("/static/app-icons/linear.svg"),

pkg/connector/connector.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,23 @@ var (
4141
)
4242

4343
type Linear struct {
44-
client *linear.Client
44+
client *linear.Client
45+
skipProjects bool
4546
}
4647

4748
func (ln *Linear) ResourceSyncers(ctx context.Context) []connectorbuilder.ResourceSyncer {
48-
return []connectorbuilder.ResourceSyncer{
49+
resourceSyncers := []connectorbuilder.ResourceSyncer{
4950
userBuilder(ln.client),
5051
teamBuilder(ln.client),
51-
projectBuilder(ln.client),
5252
orgBuilder(ln.client),
5353
roleBuilder(ln.client),
5454
}
55+
56+
if !ln.skipProjects {
57+
resourceSyncers = append(resourceSyncers, projectBuilder(ln.client))
58+
}
59+
60+
return resourceSyncers
5561
}
5662

5763
// Metadata returns metadata about the connector.
@@ -73,13 +79,14 @@ func (ln *Linear) Validate(ctx context.Context) (annotations.Annotations, error)
7379
}
7480

7581
// New returns the Linear connector.
76-
func New(ctx context.Context, apiKey string) (*Linear, error) {
82+
func New(ctx context.Context, apiKey string, skipProjects bool) (*Linear, error) {
7783
client, err := linear.NewClient(ctx, apiKey)
7884
if err != nil {
7985
return nil, err
8086
}
8187

8288
return &Linear{
83-
client: client,
89+
client: client,
90+
skipProjects: skipProjects,
8491
}, nil
8592
}

0 commit comments

Comments
 (0)