Skip to content

Commit 44eb5ea

Browse files
[BB-1202] Refactoring connector without GitLab SDK (#49)
* list only owned groups and projects to avoid 403 error on listing users * Refactoring connector without GitLab SDK * Refactoring connector without GitLab SDK * Apply cursor bot review suggestions * Apply cursor bot review suggestions * fix: close response body to avoid lint error * Apply suggestions from Luisina and Agustín - Improved Validate and getGroupID functions for account provisioning flag, to handle duplicate group names - Added validation: disallow grants to subgroups with minimal access * Refactor: Improve group search and validation logic * refactor: Simplify subgroup validation check * Fix cloud pagination for members and invites * Apply cursor bot review suggestions --------- Co-authored-by: Luisina Santos <luisina.santos@conductorone.com>
1 parent efd8059 commit 44eb5ea

File tree

202 files changed

+1211
-49167
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

202 files changed

+1211
-49167
lines changed

.github/workflows/capabilities_and_config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ jobs:
3030
- name: Run and save capabilities output
3131
env:
3232
BATON_ACCESS_TOKEN: "${{ secrets.BATON_ACCESS_TOKEN }}"
33-
run: ./connector capabilities > baton_capabilities.json
33+
run: ./connector capabilities --access-token=access_token --base-url=base_url --account-creation-group=group > baton_capabilities.json
3434

3535
- name: Commit changes
3636
uses: EndBug/add-and-commit@v9

.golangci.yml

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
version: "2"
2+
23
linters:
3-
default: none
44
enable:
55
- asasalint
66
- asciicheck
77
- bidichk
8+
- bodyclose
89
- durationcheck
9-
- errcheck
1010
- errorlint
1111
- exhaustive
1212
- forbidigo
1313
- gochecknoinits
1414
- goconst
1515
- gocritic
1616
- godot
17+
- gomoddirectives
1718
- goprintffuncname
1819
- gosec
19-
- govet
20-
- ineffassign
2120
- nakedret
2221
- nilerr
2322
- noctx
@@ -26,13 +25,11 @@ linters:
2625
- nosprintfhostport
2726
- predeclared
2827
- revive
29-
- staticcheck
3028
- tparallel
3129
- unconvert
32-
- unused
3330
- usestdlibvars
34-
- usetesting
3531
- whitespace
32+
3633
settings:
3734
exhaustive:
3835
default-signifies-exhaustive: true
@@ -44,13 +41,15 @@ linters:
4441
rules: ${base-path}/tools/rules.go
4542
underef:
4643
skipRecvDeref: false
44+
gomoddirectives:
45+
replace-allow-list:
46+
- gitlab.com/gitlab-org/api/client-go
47+
replace-local: true
4748
govet:
4849
disable:
4950
- fieldalignment
5051
- shadow
5152
enable-all: true
52-
nakedret:
53-
max-func-lines: 0
5453
nolintlint:
5554
require-explanation: true
5655
require-specific: true
@@ -87,26 +86,11 @@ linters:
8786
- HTTP
8887
- API
8988
- []
90-
exclusions:
91-
generated: lax
92-
presets:
93-
- comments
94-
- common-false-positives
95-
- legacy
96-
- std-error-handling
97-
rules:
98-
- linters:
99-
- godot
100-
source: (TODO)
101-
paths:
102-
- third_party$
103-
- builtin$
104-
- examples$
89+
10590
issues:
10691
max-same-issues: 50
92+
10793
formatters:
108-
enable:
109-
- goimports
11094
exclusions:
11195
generated: lax
11296
paths:

baton_capabilities.json

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,55 @@
11
{
2-
"@type": "type.googleapis.com/c1.connector.v2.ConnectorCapabilities",
3-
"resourceTypeCapabilities": [
2+
"@type": "type.googleapis.com/c1.connector.v2.ConnectorCapabilities",
3+
"resourceTypeCapabilities": [
44
{
5-
"resourceType": {
6-
"id": "group",
7-
"displayName": "Group",
8-
"traits": [
5+
"resourceType": {
6+
"id": "group",
7+
"displayName": "Group",
8+
"traits": [
99
"TRAIT_GROUP"
1010
]
1111
},
12-
"capabilities": [
12+
"capabilities": [
1313
"CAPABILITY_SYNC",
1414
"CAPABILITY_PROVISION"
1515
]
1616
},
1717
{
18-
"resourceType": {
19-
"id": "project",
20-
"displayName": "Project"
18+
"resourceType": {
19+
"id": "project",
20+
"displayName": "Project"
2121
},
22-
"capabilities": [
22+
"capabilities": [
2323
"CAPABILITY_SYNC",
2424
"CAPABILITY_PROVISION"
2525
]
2626
},
2727
{
28-
"resourceType": {
29-
"id": "user",
30-
"displayName": "User",
31-
"traits": [
28+
"resourceType": {
29+
"id": "user",
30+
"displayName": "User",
31+
"traits": [
3232
"TRAIT_USER"
3333
]
3434
},
35-
"capabilities": [
35+
"capabilities": [
3636
"CAPABILITY_SYNC",
3737
"CAPABILITY_ACCOUNT_PROVISIONING"
3838
]
3939
}
4040
],
41-
"connectorCapabilities": [
41+
"connectorCapabilities": [
4242
"CAPABILITY_PROVISION",
4343
"CAPABILITY_SYNC",
4444
"CAPABILITY_ACCOUNT_PROVISIONING"
4545
],
46-
"credentialDetails": {
47-
"capabilityAccountProvisioning": {
48-
"supportedCredentialOptions": [
46+
"credentialDetails": {
47+
"capabilityAccountProvisioning": {
48+
"supportedCredentialOptions": [
4949
"CAPABILITY_DETAIL_CREDENTIAL_OPTION_NO_PASSWORD",
5050
"CAPABILITY_DETAIL_CREDENTIAL_OPTION_RANDOM_PASSWORD"
5151
],
52-
"preferredCredentialOption": "CAPABILITY_DETAIL_CREDENTIAL_OPTION_NO_PASSWORD"
52+
"preferredCredentialOption": "CAPABILITY_DETAIL_CREDENTIAL_OPTION_NO_PASSWORD"
5353
}
5454
}
5555
}

docs/doc-info.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ While developing the connector, please fill out this form. This information is n
4141

4242
1. What credentials or information are needed to set up the connector? (For example, API key, client ID and secret, domain, etc.)
4343
- DC version (on-premise/self-hosted): Requires an API key and a base url. Args: --access-token and --base-url
44-
- Cloud version: Requires an API key and a group already created in gitlab for account creation and synchronization. Args --access-token and --account-creation-group
44+
- Cloud version: Requires an API key for synchronization. To enable account provisioning or deprovisioning, you must also provide the name of an existing GitLab group — only users within this group can be added or removed.
45+
Use the --access-token and --account-creation-group arguments
4546

4647

4748
2. For each item in the list above:

go.mod

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ require (
88
github.com/conductorone/baton-sdk v0.3.18
99
github.com/ennyjfrick/ruleguard-logfatal v0.0.2
1010
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0
11-
github.com/peterhellberg/link v1.2.0
1211
github.com/quasilyte/go-ruleguard/dsl v0.3.22
13-
gitlab.com/gitlab-org/api/client-go v0.118.0
1412
go.uber.org/zap v1.27.0
15-
google.golang.org/grpc v1.71.0
13+
google.golang.org/protobuf v1.36.5
1614
)
1715

1816
require (
@@ -57,11 +55,8 @@ require (
5755
github.com/go-logr/stdr v1.2.2 // indirect
5856
github.com/go-ole/go-ole v1.3.0 // indirect
5957
github.com/golang/protobuf v1.5.4 // indirect
60-
github.com/google/go-querystring v1.1.0 // indirect
6158
github.com/google/uuid v1.6.0 // indirect
6259
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 // indirect
63-
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
64-
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
6560
github.com/hashicorp/hcl v1.0.0 // indirect
6661
github.com/inconshreveable/mousetrap v1.1.0 // indirect
6762
github.com/jellydator/ttlcache/v3 v3.3.0 // indirect
@@ -116,10 +111,9 @@ require (
116111
golang.org/x/sync v0.12.0 // indirect
117112
golang.org/x/sys v0.31.0 // indirect
118113
golang.org/x/text v0.23.0 // indirect
119-
golang.org/x/time v0.9.0 // indirect
120114
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
121115
google.golang.org/genproto/googleapis/rpc v0.0.0-20250303144028-a0af3efb3deb // indirect
122-
google.golang.org/protobuf v1.36.5 // indirect
116+
google.golang.org/grpc v1.71.0 // indirect
123117
gopkg.in/ini.v1 v1.67.0 // indirect
124118
gopkg.in/yaml.v2 v2.4.0 // indirect
125119
gopkg.in/yaml.v3 v3.0.1 // indirect

go.sum

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,6 @@ github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1m
8888
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
8989
github.com/envoyproxy/protoc-gen-validate v1.2.1 h1:DEo3O99U8j4hBFwbJfrz9VtgcDfUKS7KJ7spH3d86P8=
9090
github.com/envoyproxy/protoc-gen-validate v1.2.1/go.mod h1:d/C80l/jxXLdfEIhX1W2TmLfsJ31lvEjwamM4DxlWXU=
91-
github.com/fatih/color v1.16.0 h1:zmkK9Ngbjj+K0yRhTVONQh1p/HknKYSlNT+vZCzyokM=
92-
github.com/fatih/color v1.16.0/go.mod h1:fL2Sau1YI5c0pdGEVCbKQbLXB6edEj1ZgiY4NijnWvE=
9391
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
9492
github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0=
9593
github.com/fsnotify/fsnotify v1.8.0 h1:dAwr6QBTBZIkG8roQaJjGof0pp0EeF+tNV7YBP3F/8M=
@@ -127,12 +125,9 @@ github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaW
127125
github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
128126
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
129127
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
130-
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
131128
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
132129
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
133130
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
134-
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
135-
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
136131
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
137132
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
138133
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -141,12 +136,6 @@ github.com/grpc-ecosystem/go-grpc-middleware v1.4.0 h1:UH//fgunKIs4JdUbpDl1VZCDa
141136
github.com/grpc-ecosystem/go-grpc-middleware v1.4.0/go.mod h1:g5qyo/la0ALbONm6Vbp88Yd8NsDy6rZz+RcrMPxvld8=
142137
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1 h1:e9Rjr40Z98/clHv5Yg79Is0NtosR5LXRvdr7o/6NwbA=
143138
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.1/go.mod h1:tIxuGz/9mpox++sgp9fJjHO0+q1X9/UOWd798aAm22M=
144-
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
145-
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
146-
github.com/hashicorp/go-hclog v1.6.3 h1:Qr2kF+eVWjTiYmU7Y31tYlP1h0q/X3Nl3tPGdaB11/k=
147-
github.com/hashicorp/go-hclog v1.6.3/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M=
148-
github.com/hashicorp/go-retryablehttp v0.7.7 h1:C8hUCYzor8PIfXHa4UrZkU4VvK8o9ISHxT2Q8+VepXU=
149-
github.com/hashicorp/go-retryablehttp v0.7.7/go.mod h1:pkQpWZeYWskR+D1tR2O5OcBFOxfA7DoAO6xtkuQnHTk=
150139
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
151140
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
152141
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
@@ -171,8 +160,6 @@ github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683 h1:7UMa6KCCMjZEMD
171160
github.com/lufia/plan9stats v0.0.0-20240909124753-873cd0166683/go.mod h1:ilwx/Dta8jXAgpFYFvSWEMwxmbWXyiUHkd5FwyKhb5k=
172161
github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM=
173162
github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
174-
github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
175-
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
176163
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
177164
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
178165
github.com/mattn/go-sqlite3 v1.14.7/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
@@ -187,8 +174,6 @@ github.com/ncruces/go-strftime v0.1.9/go.mod h1:Fwc5htZGVVkseilnfgOVb9mKy6w1naJm
187174
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
188175
github.com/pelletier/go-toml/v2 v2.2.3 h1:YmeHyLY8mFWbdkNWwpr+qIL2bEqT0o95WSdkNHvL12M=
189176
github.com/pelletier/go-toml/v2 v2.2.3/go.mod h1:MfCQTFTvCcUyyvvwm1+G6H/jORL20Xlb6rzQu9GuUkc=
190-
github.com/peterhellberg/link v1.2.0 h1:UA5pg3Gp/E0F2WdX7GERiNrPQrM1K6CVJUUWfHa4t6c=
191-
github.com/peterhellberg/link v1.2.0/go.mod h1:gYfAh+oJgQu2SrZHg5hROVRQe1ICoK0/HHJTcE0edxc=
192177
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
193178
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
194179
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
@@ -262,8 +247,6 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de
262247
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
263248
github.com/yusufpapurcu/wmi v1.2.4 h1:zFUKzehAFReQwLys1b/iSMl+JQGSCSjtVqQn9bBrPo0=
264249
github.com/yusufpapurcu/wmi v1.2.4/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0=
265-
gitlab.com/jirwin/client-go v0.123.1-0.20250228021302-c3f0af7d3169 h1:Mbwmm8QoDnefnd0B+L6Y87AeP5OQSg3aBOSDPG4clnA=
266-
gitlab.com/jirwin/client-go v0.123.1-0.20250228021302-c3f0af7d3169/go.mod h1:Jh0qjLILEdbO6z/OY94RD+3NDQRUKiuFSFYozN6cpKM=
267250
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
268251
go.opentelemetry.io/auto/sdk v1.1.0/go.mod h1:3wSPjt5PWp2RhlCcmmOial7AvC4DQqZb7a7wCow3W8A=
269252
go.opentelemetry.io/contrib/bridges/otelzap v0.10.0 h1:ojdSRDvjrnm30beHOmwsSvLpoRF40MlwNCA+Oo93kXU=
@@ -366,8 +349,6 @@ golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
366349
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
367350
golang.org/x/text v0.23.0 h1:D71I7dUrlY+VX0gQShAThNGHFxZ13dGLBHQLVl1mJlY=
368351
golang.org/x/text v0.23.0/go.mod h1:/BLNzu4aZCJ1+kcD0DNRotWKage4q2rGVAg4o22unh4=
369-
golang.org/x/time v0.9.0 h1:EsRrnYcQiGH+5FfbgvV4AP7qEZstoyrHB0DzarOQ4ZY=
370-
golang.org/x/time v0.9.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
371352
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
372353
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
373354
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=

0 commit comments

Comments
 (0)