Skip to content

Commit 83e43ef

Browse files
committed
add team ids filter config option for ticket schemas
1 parent 20ccf3d commit 83e43ef

File tree

5 files changed

+20
-8
lines changed

5 files changed

+20
-8
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, lc.SkipProjects)
39+
cb, err := connector.New(ctx, lc.ApiKey, lc.SkipProjects, lc.TicketSchemaTeamIdsFilter)
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: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,22 @@ var (
1717
field.WithDisplayName("Skip projects"),
1818
field.WithDescription("Skip syncing projects."),
1919
)
20+
teamIDsTicketSchemaFilterField = field.StringSliceField(
21+
"ticket-schema-team-ids-filter",
22+
field.WithDisplayName("Teams"),
23+
field.WithDescription("Comma-separated list of team IDs to use for tickets schemas."),
24+
)
2025
)
2126

2227
var externalTicketField = field.TicketingField.ExportAs(field.ExportTargetGUI)
28+
var configRelations = []field.SchemaFieldRelationship{
29+
field.FieldsDependentOn([]field.SchemaField{teamIDsTicketSchemaFilterField}, []field.SchemaField{field.TicketingField}),
30+
}
2331

2432
//go:generate go run ./gen
2533
var Config = field.NewConfiguration(
26-
[]field.SchemaField{apiKey, externalTicketField, skipProjects},
34+
[]field.SchemaField{apiKey, externalTicketField, skipProjects, teamIDsTicketSchemaFilterField},
35+
field.WithConstraints(configRelations...),
2736
field.WithConnectorDisplayName("Linear"),
2837
field.WithHelpUrl("/docs/baton/linear"),
2938
field.WithIconUrl("/static/app-icons/linear.svg"),

pkg/connector/connector.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ var (
4141
)
4242

4343
type Linear struct {
44-
client *linear.Client
45-
skipProjects bool
44+
client *linear.Client
45+
skipProjects bool
46+
ticketSchemaTeamIDs []string
4647
}
4748

4849
func (ln *Linear) ResourceSyncers(ctx context.Context) []connectorbuilder.ResourceSyncer {
@@ -79,14 +80,15 @@ func (ln *Linear) Validate(ctx context.Context) (annotations.Annotations, error)
7980
}
8081

8182
// New returns the Linear connector.
82-
func New(ctx context.Context, apiKey string, skipProjects bool) (*Linear, error) {
83+
func New(ctx context.Context, apiKey string, skipProjects bool, ticketSchemaTeamIDs []string) (*Linear, error) {
8384
client, err := linear.NewClient(ctx, apiKey)
8485
if err != nil {
8586
return nil, err
8687
}
8788

8889
return &Linear{
89-
client: client,
90-
skipProjects: skipProjects,
90+
client: client,
91+
skipProjects: skipProjects,
92+
ticketSchemaTeamIDs: ticketSchemaTeamIDs,
9193
}, nil
9294
}

pkg/connector/tickets.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (ln *Linear) ListTicketSchemas(ctx context.Context, p *pagination.Token) ([
154154
}
155155
l := ctxzap.Extract(ctx)
156156

157-
teams, nextToken, _, rlData, err := ln.client.ListTeamWorkflowStates(ctx, linear.GetTeamsVars{After: bag.PageToken(), First: resourcePageSize})
157+
teams, nextToken, _, rlData, err := ln.client.ListTeamWorkflowStates(ctx, linear.GetTeamsVars{TeamIDs: ln.ticketSchemaTeamIDs, After: bag.PageToken(), First: resourcePageSize})
158158
annotations.WithRateLimiting(rlData)
159159
if err != nil {
160160
l.Debug("teams failed", zap.Error(err), zap.Any("rlData", rlData))

0 commit comments

Comments
 (0)