Skip to content

Commit 954f4a2

Browse files
[BB-1049] Remove required validation for account provisioning group in GitLab Cloud (#39)
* Remove required validation for account provisioning group in GitLab Cloud
1 parent 2a85e14 commit 954f4a2

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pkg/connector/connector.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,7 @@ func (d *Connector) Metadata(ctx context.Context) (*v2.ConnectorMetadata, error)
8686
// Validate is called to ensure that the connector is properly configured. It should exercise any API credentials
8787
// to be sure that they are valid.
8888
func (d *Connector) Validate(ctx context.Context) (annotations.Annotations, error) {
89-
if !d.Client.IsOnPremise && d.Client.AccountCreationGroup == "" {
90-
return nil, fmt.Errorf("a group is required when using GitLab Cloud Version")
91-
}
92-
93-
_, _, err := d.Client.ListGroups(ctx, "")
94-
if err != nil {
95-
return nil, fmt.Errorf("error listing groups: %w", err)
96-
}
97-
98-
if d.Client.AccountCreationGroup != "" {
89+
if !d.Client.IsOnPremise && d.Client.AccountCreationGroup != "" {
9990
groupName := d.Client.AccountCreationGroup
10091
groups, _, err := d.Client.Groups.ListGroups(&gitlabSDK.ListGroupsOptions{
10192
Search: &groupName,
@@ -109,6 +100,11 @@ func (d *Connector) Validate(ctx context.Context) (annotations.Annotations, erro
109100
if len(groups) == 0 {
110101
return nil, fmt.Errorf("account creation group not found")
111102
}
103+
} else {
104+
_, _, err := d.Client.ListGroups(ctx, "")
105+
if err != nil {
106+
return nil, fmt.Errorf("error listing groups: %w", err)
107+
}
112108
}
113109

114110
return nil, nil

0 commit comments

Comments
 (0)