diff --git a/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/feign/data/ServiceRequest.kt b/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/feign/data/ServiceRequest.kt index 57ef946..4e161d4 100644 --- a/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/feign/data/ServiceRequest.kt +++ b/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/feign/data/ServiceRequest.kt @@ -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 ) } } diff --git a/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/graphql/GitlabGraphqlProvider.kt b/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/graphql/GitlabGraphqlProvider.kt index 1ae81ef..d4ecfe2 100644 --- a/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/graphql/GitlabGraphqlProvider.kt +++ b/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/adapter/graphql/GitlabGraphqlProvider.kt @@ -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 { diff --git a/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/domain/Repository.kt b/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/domain/Repository.kt index cd86bad..9107a11 100644 --- a/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/domain/Repository.kt +++ b/src/main/kotlin/net/leanix/vsm/gitlab/broker/connector/domain/Repository.kt @@ -9,5 +9,6 @@ data class Repository( val visibility: String?, val languages: List?, val tags: List?, - val defaultBranch: String + val defaultBranch: String, + val groupName: String ) diff --git a/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookClient.kt b/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookClient.kt index 315a066..1b286bd 100644 --- a/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookClient.kt +++ b/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookClient.kt @@ -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 { diff --git a/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookFeignClientConfiguration.kt b/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookFeignClientConfiguration.kt index 723c655..338380a 100644 --- a/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookFeignClientConfiguration.kt +++ b/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookFeignClientConfiguration.kt @@ -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 { diff --git a/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookProvider.kt b/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookProvider.kt index 17ef21c..01a0a6d 100644 --- a/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookProvider.kt +++ b/src/main/kotlin/net/leanix/vsm/gitlab/broker/webhook/adapter/feign/GitlabWebhookProvider.kt @@ -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 { diff --git a/src/main/resources/application.yaml b/src/main/resources/application.yaml index 9a8589d..90446b3 100644 --- a/src/main/resources/application.yaml +++ b/src/main/resources/application.yaml @@ -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: diff --git a/src/main/resources/queries/AllGroupsQuery.graphql b/src/main/resources/queries/AllGroupsQuery.graphql index 818da36..8683536 100644 --- a/src/main/resources/queries/AllGroupsQuery.graphql +++ b/src/main/resources/queries/AllGroupsQuery.graphql @@ -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 @@ -25,6 +25,9 @@ query AllGroupsQuery($group: ID!, $pageCount: Int!, $cursor: String) { diskPath rootRef } + group { + fullPath + } } } } diff --git a/src/test/resources/mappings/get-groups.json b/src/test/resources/mappings/get-groups.json index 08d0ec1..0fd816d 100644 --- a/src/test/resources/mappings/get-groups.json +++ b/src/test/resources/mappings/get-groups.json @@ -52,6 +52,9 @@ "codeOwnersPath": null, "diskPath": null, "rootRef": "main" + }, + "group": { + "fullPath": "gitlab-org" } }, { @@ -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", @@ -80,6 +86,9 @@ "codeOwnersPath": null, "diskPath": null, "rootRef": "main" + }, + "group": { + "fullPath": "gitlab-org" } }, { @@ -121,6 +130,9 @@ "codeOwnersPath": "/gitlab-org/terraform-provider-gitlab/-/blob/main/.gitlab/CODEOWNERS", "diskPath": null, "rootRef": "main" + }, + "group": { + "fullPath": "gitlab-org" } }, { @@ -158,6 +170,9 @@ "codeOwnersPath": null, "diskPath": null, "rootRef": "main" + }, + "group": { + "fullPath": "gitlab-org" } }, { @@ -179,6 +194,9 @@ "codeOwnersPath": null, "diskPath": null, "rootRef": "main" + }, + "group": { + "fullPath": "gitlab-org" } } ]