Migrate to DefineConfigurationV2 / RunConnector (prerequisite for CE-1195) - #49
Conversation
Prerequisite plumbing only — no guard logic, no behaviour change. This connector was on the V1 entrypoint, so *cli.ConnectorOpts never reached connector.New. That is what blocks reading the sync resource-type filter (CE-1195). - cmd: DefineConfiguration + getConnector + cmd.Execute() -> config.RunConnector, with WithProvisioningEnabled and WithDefaultCapabilitiesConnectorBuilderV2 so `capabilities` needs no credentials. - pkg/config: `Config` -> `Configuration`; regenerated conf.gen.go. - connector.New: takes (*config.Miro, *cli.ConnectorOpts) and returns (connectorbuilder.ConnectorBuilderV2, []connectorbuilder.Opt, error) instead of three positional strings. Accepted but unread — wiring it up is the follow-up. - ResourceSyncers returns []connectorbuilder.ResourceSyncerV2; the user, team and role builders move to the V2 sync signatures. Two renames were forced by the V2 signatures naming SDK packages that local identifiers shadowed: - teams.go took a parameter literally named `pagination`, which shadowed the pagination package; it is now pToken. - roles_test.go had a local named `resource` shadowing the SDK resource package; it is now res. Test reads of *SyncOpResults go through a nil check. roleBuilder.Grants returns `nil, nil, nil` for the empty case, so dereferencing the results unconditionally panicked — TestRoleBuilder_Grants_EmptyResult caught it. Verified with an empty environment: `env -i ./connector capabilities` and `config` regenerate byte-identical. golangci-lint reports 0 issues, same as main. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
| version, | ||
| cfg.Configuration, | ||
| connector.New, | ||
| connectorrunner.WithProvisioningEnabled(), |
There was a problem hiding this comment.
🟡 Suggestion: connectorrunner.WithProvisioningEnabled() is new — main passed no runner options, so runnerConfig.provisioningEnabled was only ever set from the --provisioning/BATON_PROVISIONING input. Hardcoding it means grant/revoke/account-create are now always registered on the wrapper in daemon mode, which is a real behaviour change despite the PR description saying "no behaviour change". Confidence: high on the diff, medium on impact (likely the intended fix for a provisioning-capable connector) — worth calling out in the PR body rather than changing.
| // New returns a new instance of the connector. | ||
| func New(ctx context.Context, accessToken string, scimAccessToken string, baseURL string) (*Connector, error) { | ||
| // New returns a new instance of the connector. | ||
| // | ||
| // The *cli.ConnectorOpts parameter is part of the V2 entrypoint contract; it | ||
| // carries runtime options such as the sync resource-type filter. It is accepted | ||
| // but not yet read here. |
There was a problem hiding this comment.
🟡 Suggestion: the doc comment // New returns a new instance of the connector. is duplicated on consecutive lines. Drop the first one.
| // New returns a new instance of the connector. | |
| func New(ctx context.Context, accessToken string, scimAccessToken string, baseURL string) (*Connector, error) { | |
| // New returns a new instance of the connector. | |
| // | |
| // The *cli.ConnectorOpts parameter is part of the V2 entrypoint contract; it | |
| // carries runtime options such as the sync resource-type filter. It is accepted | |
| // but not yet read here. | |
| // New returns a new instance of the connector. | |
| // | |
| // The *cli.ConnectorOpts parameter is part of the V2 entrypoint contract; it | |
| // carries runtime options such as the sync resource-type filter. It is accepted | |
| // but not yet read here. |
| import ( | ||
| "context" | ||
| "github.com/conductorone/baton-sdk/pkg/types/resource" | ||
| "testing" | ||
|
|
||
| v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2" | ||
| "github.com/conductorone/baton-sdk/pkg/pagination" | ||
| ) |
There was a problem hiding this comment.
🟡 Suggestion: the new resource import landed in the stdlib group. It's still gofmt-sorted so lint passes, but it breaks the stdlib/third-party grouping used everywhere else in this package.
| import ( | |
| "context" | |
| "github.com/conductorone/baton-sdk/pkg/types/resource" | |
| "testing" | |
| v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2" | |
| "github.com/conductorone/baton-sdk/pkg/pagination" | |
| ) | |
| import ( | |
| "context" | |
| "testing" | |
| v2 "github.com/conductorone/baton-sdk/pb/c1/connector/v2" | |
| "github.com/conductorone/baton-sdk/pkg/types/resource" | |
| ) |
Connector PR Review: Migrate to DefineConfigurationV2 / RunConnector (prerequisite for CE-1195)Blocking Issues: 0 | Suggestions: 2 | Threads Resolved: 0 Review SummaryThe new commit removes the hardcoded Security IssuesNone found. Correctness IssuesNone found. Suggestions
Prompt for AI agents |
Review feedback. The V1 DefineConfiguration call passed no connectorrunner options at all, so adding WithProvisioningEnabled() here would have flipped provisioning on unconditionally (it sets cfg.provisioningEnabled = true) rather than leaving it under whatever gates it before. That is a behaviour change, and this PR is meant to be pure entrypoint plumbing. Implementing Grant/Revoke/CreateAccount is not the same thing as the runner being told to enable provisioning, which is the mistake behind the original change. WithDefaultCapabilitiesConnectorBuilderV2 stays: that is what lets `capabilities` run without credentials. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Prerequisite for CE-1195. Plumbing only — no guard logic in this PR.
baton-mirowas on the V1 entrypoint, so*cli.ConnectorOptsnever reachedconnector.New— which is what blocks reading the sync resource-type filter.What changed
cmd/:DefineConfiguration+getConnector+cmd.Execute()→config.RunConnector, withWithProvisioningEnabled()andWithDefaultCapabilitiesConnectorBuilderV2(&connector.Connector{}).pkg/config:Config→Configuration, regeneratedconf.gen.go.connector.New: takes(*config.Miro, *cli.ConnectorOpts), returns(ConnectorBuilderV2, []connectorbuilder.Opt, error)instead of three positional strings.ResourceSyncers→[]connectorbuilder.ResourceSyncerV2; user, team and role builders move to the V2 sync signatures.optsis accepted but deliberately unread. Nofield.Validate— the SDK validates viaRunConnector.Two forced renames
The V2 signatures name SDK packages that local identifiers were shadowing. Harmless under V1, compile errors under V2:
teams.gotook a parameter literally namedpagination— shadowing thepaginationpackage. NowpToken.roles_test.gohad a local namedresource— shadowing the SDKresourcepackage. Nowres.A real panic the tests caught
roleBuilder.Grantsreturnsnil, nil, nilfor the empty case, so readingsyncResults.NextPageTokenunconditionally panicked —TestRoleBuilder_Grants_EmptyResultfailed with a nil dereference. Test reads of*SyncOpResultsnow go through a nil check. Worth knowing since a nil results value is legitimate under V2.Verification
env -i ./connector capabilitiesandconfigregenerate byte-identical.go build,go vet,go test ./...pass.golangci-lintreports 0 issues, matchingmain.🤖 Generated with Claude Code