Skip to content

Commit 8bac1bd

Browse files
authored
Add AccountManagerV2 for type assertions in connectors. (#590)
1 parent 48199c2 commit 8bac1bd

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

pkg/connectorbuilder/accounts.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ type AccountManager interface {
3333
AccountManagerLimited
3434
}
3535

36+
type AccountManagerV2 interface {
37+
ResourceSyncerV2
38+
AccountManagerLimited
39+
}
40+
3641
type AccountManagerLimited interface {
3742
CreateAccount(ctx context.Context,
3843
accountInfo *v2.AccountInfo,

pkg/connectorbuilder/connectorbuilder_v2_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ func TestConnectorBuilderV2_FullCapabilities(t *testing.T) {
2121
resourceSyncers: []ResourceSyncerV2{
2222
newTestResourceSyncerV2WithProvisioner("resource-1"),
2323
newTestResourceSyncerV2WithManager("resource-2"),
24+
newTestResourceSyncerV2WithAccountProvisioner("user-1"),
2425
},
2526
hasActionManager: true,
2627
hasEventProvider: true,
@@ -155,6 +156,12 @@ func (t *testConnectorBuilderV2Full) ListEvents(
155156
}, &pagination.StreamState{}, annotations.Annotations{}, nil
156157
}
157158

159+
func newTestResourceSyncerV2WithAccountProvisioner(resourceType string) ResourceSyncerV2 {
160+
return &testResourceSyncerV2WithAccountProvisioner{
161+
testResourceSyncerV2Simple: testResourceSyncerV2Simple{resourceType: resourceType},
162+
}
163+
}
164+
158165
func newTestResourceSyncerV2WithProvisioner(resourceType string) ResourceSyncerV2 {
159166
return &testResourceSyncerV2WithProvisioner{
160167
testResourceSyncerV2Simple: testResourceSyncerV2Simple{resourceType: resourceType},
@@ -224,6 +231,24 @@ func (t *testResourceSyncerV2Simple) Grants(
224231
}, nil, nil
225232
}
226233

234+
var _ AccountManagerV2 = &testResourceSyncerV2WithAccountProvisioner{}
235+
236+
type testResourceSyncerV2WithAccountProvisioner struct {
237+
testResourceSyncerV2Simple
238+
}
239+
240+
func (t *testResourceSyncerV2WithAccountProvisioner) CreateAccount(
241+
ctx context.Context,
242+
accountInfo *v2.AccountInfo,
243+
credentialOptions *v2.LocalCredentialOptions,
244+
) (CreateAccountResponse, []*v2.PlaintextData, annotations.Annotations, error) {
245+
return nil, nil, annotations.Annotations{}, nil
246+
}
247+
248+
func (t *testResourceSyncerV2WithAccountProvisioner) CreateAccountCapabilityDetails(ctx context.Context) (*v2.CredentialDetailsAccountProvisioning, annotations.Annotations, error) {
249+
return nil, annotations.Annotations{}, nil
250+
}
251+
227252
type testResourceSyncerV2WithProvisioner struct {
228253
testResourceSyncerV2Simple
229254
}

0 commit comments

Comments
 (0)