Skip to content

Commit

Permalink
CID-1751: Add group path to generate organization
Browse files Browse the repository at this point in the history
  • Loading branch information
henriqamaral committed Aug 29, 2023
1 parent 24fd095 commit a67a77c
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class ServiceRequest(
languages = repository.languages,
labels = repository.tags?.map { Tag(it, it) },
contributors = emptyList(),
organizationName = assignment.connectorConfiguration.orgName
organizationName = repository.groupName
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class GitlabGraphqlProvider(private val gitLabOnPremProperties: GitLabOnPremProp
languages = LanguageParser.parse(project.languages),
tags = project.topics,
defaultBranch = project.repository?.rootRef ?: "empty-branch",
groupName = project.group!!.fullPath
)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ data class Repository(
val visibility: String?,
val languages: List<Language>?,
val tags: List<String>?,
val defaultBranch: String
val defaultBranch: String,
val groupName: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestParam

@FeignClient(
name = "gitlabWebhookClient",
url = "\${leanix.gitlab.base-url}",
url = "\${leanix.vsm.connector.gitlab-url}",
configuration = [GitlabWebhookFeignClientConfiguration::class]
)
interface GitlabWebhookClient {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import org.springframework.context.annotation.Configuration
@Configuration
class GitlabWebhookFeignClientConfiguration(

@Value("\${leanix.gitlab.access-token}") private val gitlabAccessToken: String
@Value("\${leanix.vsm.connector.gitlab-token}") private val gitlabAccessToken: String
) {
@Bean
fun requestInterceptor(): RequestInterceptor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const val LEANIX_WEBHOOK_PATH = "/leanix-vsm/webhook"
class GitlabWebhookProvider(
private val webhookClient: GitlabWebhookClient,
@Value("\${leanix.gitlab.webhook-url}") private val gitlabWebhookUrl: String,
@Value("\${leanix.gitlab.leanix-id}") private val leanixId: String,
@Value("\${leanix.vsm.connector.api-user-token}") private val leanixId: String,
@Value("\${leanix.gitlab.enable-ssl-verification}") private val enableSSLVerification: Boolean,
) : WebhookProvider {

Expand Down
3 changes: 0 additions & 3 deletions src/main/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ leanix:
auth:
access-token-uri: ${leanix.base-url}/mtm/v1
gitlab:
base-url: ${GITLAB_URL}
access-token: ${GITLAB_TOKEN}
webhook-url: ${GITLAB_WEBHOOK_URL}
leanix-id: ${LEANIX_ID}
enable-ssl-verification: ${ENABLE_SSL_VERIFICATION:false}

server:
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/queries/AllGroupsQuery.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ query AllGroupsQuery($group: ID!, $pageCount: Int!, $cursor: String) {
group(fullPath: $group) {
id
name
projects(first: $pageCount, after: $cursor) {
projects(first: $pageCount, after: $cursor, includeSubgroups: true) {
pageInfo {
hasNextPage
endCursor
Expand All @@ -25,6 +25,9 @@ query AllGroupsQuery($group: ID!, $pageCount: Int!, $cursor: String) {
diskPath
rootRef
}
group {
fullPath
}
}
}
}
Expand Down
20 changes: 19 additions & 1 deletion src/test/resources/mappings/get-groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@
"codeOwnersPath": null,
"diskPath": null,
"rootRef": "main"
},
"group": {
"fullPath": "gitlab-org"
}
},
{
Expand All @@ -64,7 +67,10 @@
"description": null,
"lastActivityAt": "2023-08-22T19:08:53Z",
"languages": [],
"repository": null
"repository": null,
"group": {
"fullPath": "gitlab-org"
}
},
{
"name": "public-image-archive",
Expand All @@ -80,6 +86,9 @@
"codeOwnersPath": null,
"diskPath": null,
"rootRef": "main"
},
"group": {
"fullPath": "gitlab-org"
}
},
{
Expand Down Expand Up @@ -121,6 +130,9 @@
"codeOwnersPath": "/gitlab-org/terraform-provider-gitlab/-/blob/main/.gitlab/CODEOWNERS",
"diskPath": null,
"rootRef": "main"
},
"group": {
"fullPath": "gitlab-org"
}
},
{
Expand Down Expand Up @@ -158,6 +170,9 @@
"codeOwnersPath": null,
"diskPath": null,
"rootRef": "main"
},
"group": {
"fullPath": "gitlab-org"
}
},
{
Expand All @@ -179,6 +194,9 @@
"codeOwnersPath": null,
"diskPath": null,
"rootRef": "main"
},
"group": {
"fullPath": "gitlab-org"
}
}
]
Expand Down

0 comments on commit a67a77c

Please sign in to comment.