Skip to content

Commit

Permalink
Merge pull request #301 from Interhyp/updated_api
Browse files Browse the repository at this point in the history
RELTEC-11865: updated api, added new fields: "branchNameRegex" and "c…
  • Loading branch information
mplushnikov committed Jun 19, 2024
2 parents 3040679 + 60de08e commit b88d6c0
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 36 deletions.
4 changes: 4 additions & 0 deletions api/generated_model_repository_configuration_dto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions api/generated_model_repository_configuration_webhooks_dto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions api/openapi-v3-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,8 @@
"url": "ssh://git@bitbucket.some-organisation.com:7999/UNICORNS/unicorn-finder-service-deployment.git",
"mainline": "main",
"configuration": {
"branchNameRegex": "(testing_[^_-]+_[^-]+$|development.*|production.*|versioncheck.*|renovate.*)",
"commitMessageRegex": "(([A-Z][A-Z_0-9]+-[0-9]+)|(Ticket#[0-9]{16})[^0-9]|((SCTASK|INC|RITM|CHG)[0-9]{7}))(.|\\n)*",
"commitMessageType": "DEFAULT",
"requireIssue": true,
"requireSuccessfulBuilds": 1,
Expand All @@ -2883,7 +2885,6 @@
}
],
"webhooks": {
"pipelineTrigger": true,
"predefined": [
"jenkinsPipeline"
],
Expand Down Expand Up @@ -2958,6 +2959,14 @@
}
}
},
"branchNameRegex": {
"type": "string",
"description": "Use an explicit branch name regex."
},
"commitMessageRegex": {
"type": "string",
"description": "Use an explicit commit message regex."
},
"commitMessageType": {
"type": "string",
"description": "Adds a corresponding commit message regex.",
Expand Down Expand Up @@ -3125,10 +3134,6 @@
"type": "object",
"description": "Webhooks configured to the repository.",
"properties": {
"pipelineTrigger": {
"type": "boolean",
"description": "Default pipeline trigger webhook."
},
"predefined": {
"type": "array",
"description": "List of predefined webhooks",
Expand Down
5 changes: 3 additions & 2 deletions internal/service/repositories/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ func patchConfiguration(patch *openapi.RepositoryConfigurationDto, original *ope
}
return &openapi.RepositoryConfigurationDto{
AccessKeys: patchAccessKeys(patch.AccessKeys, original.AccessKeys),
BranchNameRegex: patchStringPtr(patch.BranchNameRegex, original.BranchNameRegex),
CommitMessageRegex: patchStringPtr(patch.CommitMessageRegex, original.CommitMessageRegex),
CommitMessageType: patchStringPtr(patch.CommitMessageType, original.CommitMessageType),
RequireIssue: patchPtr[bool](patch.RequireIssue, original.RequireIssue),
RequireSuccessfulBuilds: patchPtr[int32](patch.RequireSuccessfulBuilds, original.RequireSuccessfulBuilds),
Expand Down Expand Up @@ -516,8 +518,7 @@ func patchWebhooks(patch *openapi.RepositoryConfigurationWebhooksDto, original *
original = &openapi.RepositoryConfigurationWebhooksDto{}
}
return &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: patchPtr[bool](patch.PipelineTrigger, original.PipelineTrigger),
Additional: patchAdditionalWebhooks(patch.Additional, original.Additional),
Additional: patchAdditionalWebhooks(patch.Additional, original.Additional),
}
} else {
return original
Expand Down
10 changes: 5 additions & 5 deletions internal/service/repositories/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func createRepositoryDto() openapi.RepositoryDto {
RequireIssue: ptr(false),
RequireSuccessfulBuilds: i(1),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "webhookname",
Expand Down Expand Up @@ -115,11 +114,12 @@ func TestPatchRepository_ReplaceAll(t *testing.T) {
Permission: ptr("REPO_READ"),
},
},
BranchNameRegex: ptr("(testing_[^_-]+_[^-]+$)"),
CommitMessageRegex: ptr("(([A-Z][A-Z_0-9]+-[0-9]+))(.|\\n)*"),
CommitMessageType: ptr("DEFAULT"),
RequireIssue: ptr(true),
RequireSuccessfulBuilds: i(2),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "newwebhookname",
Expand Down Expand Up @@ -151,11 +151,12 @@ func TestPatchRepository_ReplaceAll(t *testing.T) {
Permission: ptr("REPO_READ"),
},
},
BranchNameRegex: ptr("(testing_[^_-]+_[^-]+$)"),
CommitMessageRegex: ptr("(([A-Z][A-Z_0-9]+-[0-9]+))(.|\\n)*"),
CommitMessageType: ptr("DEFAULT"),
RequireIssue: ptr(true),
RequireSuccessfulBuilds: i(2),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "newwebhookname",
Expand Down Expand Up @@ -210,8 +211,7 @@ func TestPatchRepository_ClearFields(t *testing.T) {
RequireIssue: ptr(false),
RequireSuccessfulBuilds: i(1),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: nil,
Additional: nil,
},
Approvers: nil,
DefaultReviewers: nil,
Expand Down
2 changes: 0 additions & 2 deletions test/acceptance/util_dtos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func tstRepository() openapi.RepositoryDto {
RequireSuccessfulBuilds: pi(1),
RequireConditions: &map[string]openapi.ConditionReferenceDto{"snyk-key": {RefMatcher: "master"}},
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: pb(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "webhookname",
Expand Down Expand Up @@ -305,7 +304,6 @@ configuration:
snyk-key:
refMatcher: master
webhooks:
pipelineTrigger: false
additional:
- name: webhookname
url: webhookurl
Expand Down
2 changes: 0 additions & 2 deletions test/mock/metadatamock/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ configuration:
permission: REPO_READ
- data: 'ssh-key abcdefgh.....'
permission: REPO_WRITE
webhooks:
pipelineTrigger: true
commitMessageType: DEFAULT
mergeConfig:
defaultStrategy:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@
}
]
},
"requireIssue": true,
"webhooks": {
"pipelineTrigger": true
}
"requireIssue": true
},
"generator": "third-party-software",
"jiraIssue": "ISSUE-0000",
Expand Down
5 changes: 1 addition & 4 deletions test/resources/acceptance-expected/repositories.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,7 @@
}
]
},
"requireIssue": true,
"webhooks": {
"pipelineTrigger": true
}
"requireIssue": true
},
"generator": "third-party-software",
"jiraIssue": "ISSUE-0000",
Expand Down
3 changes: 1 addition & 2 deletions test/resources/acceptance-expected/repository-create.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"name": "webhookname",
"url": "webhookurl"
}
],
"pipelineTrigger": false
]
}
},
"filecategory": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"name": "webhookname",
"url": "webhookurl"
}
],
"pipelineTrigger": false
]
}
},
"filecategory": {
Expand Down
3 changes: 1 addition & 2 deletions test/resources/acceptance-expected/repository-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
"name": "webhookname",
"url": "webhookurl"
}
],
"pipelineTrigger": false
]
}
},
"filecategory": {
Expand Down
5 changes: 1 addition & 4 deletions test/resources/acceptance-expected/repository.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@
}
]
},
"requireIssue": true,
"webhooks": {
"pipelineTrigger": true
}
"requireIssue": true
},
"generator": "third-party-software",
"jiraIssue": "ISSUE-0000",
Expand Down

0 comments on commit b88d6c0

Please sign in to comment.