From 98c7ed53cd2eb76a3d7bbeaa43ea1567c091e223 Mon Sep 17 00:00:00 2001 From: Raffael Date: Thu, 7 Nov 2024 08:59:50 +0100 Subject: [PATCH] RELTEC-12275: add new config property actionsAccess --- ...nerated_model_repository_configuration_dto.go | 2 ++ ...d_model_repository_configuration_patch_dto.go | 2 ++ api/openapi-v3-spec.yaml | 16 ++++++++++++++++ internal/service/repositories/repositories.go | 1 + .../service/repositories/repositories_test.go | 5 +++++ 5 files changed, 26 insertions(+) diff --git a/api/generated_model_repository_configuration_dto.go b/api/generated_model_repository_configuration_dto.go index f45a17b..d55f28c 100644 --- a/api/generated_model_repository_configuration_dto.go +++ b/api/generated_model_repository_configuration_dto.go @@ -45,4 +45,6 @@ type RepositoryConfigurationDto struct { RequireIssue *bool `yaml:"requireIssue,omitempty" json:"requireIssue,omitempty"` // Configuration of conditional builds as map of structs (key name e.g. some-key) of target references. RequireConditions map[string]ConditionReferenceDto `yaml:"requireConditions,omitempty" json:"requireConditions,omitempty"` + // Control how the repository is used by GitHub Actions workflows in other repositories + ActionsAccess *string `yaml:"actionsAccess,omitempty" json:"actionsAccess,omitempty"` } diff --git a/api/generated_model_repository_configuration_patch_dto.go b/api/generated_model_repository_configuration_patch_dto.go index 52002af..bfaa08d 100644 --- a/api/generated_model_repository_configuration_patch_dto.go +++ b/api/generated_model_repository_configuration_patch_dto.go @@ -39,4 +39,6 @@ type RepositoryConfigurationPatchDto struct { Archived *bool `yaml:"archived,omitempty" json:"archived,omitempty"` // Repository will not be configured, also not archived. Unmanaged *bool `yaml:"unmanaged,omitempty" json:"unmanaged,omitempty"` + // Control how the repository is used by GitHub Actions workflows in other repositories + ActionsAccess *string `yaml:"actionsAccess,omitempty" json:"actionsAccess,omitempty"` } diff --git a/api/openapi-v3-spec.yaml b/api/openapi-v3-spec.yaml index 5ca6616..42ad013 100644 --- a/api/openapi-v3-spec.yaml +++ b/api/openapi-v3-spec.yaml @@ -2089,6 +2089,14 @@ components: refMatcher: main additionalProperties: $ref: '#/components/schemas/ConditionReferenceDto' + actionsAccess: + description: Control how the repository is used by GitHub Actions workflows in other repositories + type: string + enum: + - NONE + - ORGANIZATION + - ENTERPRISE + example: NOT_ACCESSIBLE RepositoryConfigurationPatchDto: description: Attributes to configure the repository. If a configuration exists there are also some configured defaults for the repository. type: object @@ -2159,6 +2167,14 @@ components: unmanaged: description: 'Repository will not be configured, also not archived.' type: boolean + actionsAccess: + description: Control how the repository is used by GitHub Actions workflows in other repositories + type: string + enum: + - NONE + - ORGANIZATION + - ENTERPRISE + example: NOT_ACCESSIBLE MergeStrategy: type: object properties: diff --git a/internal/service/repositories/repositories.go b/internal/service/repositories/repositories.go index 0def6da..7a6f3da 100644 --- a/internal/service/repositories/repositories.go +++ b/internal/service/repositories/repositories.go @@ -463,6 +463,7 @@ func patchConfiguration(patch *openapi.RepositoryConfigurationPatchDto, original Approvers: patchApprovers(patch.Approvers, original.Approvers), Watchers: patchStringSlice(patch.Watchers, original.Watchers), Archived: patchPtr[bool](patch.Archived, original.Archived), + ActionsAccess: patchStringPtr(patch.ActionsAccess, original.ActionsAccess), // fields not allowed for patching carry over from original RequireIssue: original.RequireIssue, RequireConditions: original.RequireConditions, diff --git a/internal/service/repositories/repositories_test.go b/internal/service/repositories/repositories_test.go index c93ac82..3bf877b 100644 --- a/internal/service/repositories/repositories_test.go +++ b/internal/service/repositories/repositories_test.go @@ -68,6 +68,7 @@ func createRepositoryConfigurationPatchDtoFromConfigurationDto(input *openapi.Re return &openapi.RepositoryConfigurationPatchDto{ AccessKeys: input.AccessKeys, CommitMessageType: input.CommitMessageType, + ActionsAccess: input.ActionsAccess, RequireSuccessfulBuilds: input.RequireSuccessfulBuilds, Webhooks: input.Webhooks, Approvers: input.Approvers, @@ -139,6 +140,7 @@ func TestPatchRepository_ReplaceAll(t *testing.T) { BranchNameRegex: ptr("(testing_[^_-]+_[^-]+$)"), CommitMessageRegex: ptr("(([A-Z][A-Z_0-9]+-[0-9]+))(.|\\n)*"), CommitMessageType: ptr("DEFAULT"), + ActionsAccess: ptr("ENTERPRISE"), RequireSuccessfulBuilds: i(2), Webhooks: &openapi.RepositoryConfigurationWebhooksDto{ Additional: []openapi.RepositoryConfigurationWebhookDto{ @@ -173,6 +175,7 @@ func TestPatchRepository_ReplaceAll(t *testing.T) { BranchNameRegex: ptr("(testing_[^_-]+_[^-]+$)"), CommitMessageRegex: ptr("(([A-Z][A-Z_0-9]+-[0-9]+))(.|\\n)*"), CommitMessageType: ptr("DEFAULT"), + ActionsAccess: ptr("ENTERPRISE"), RequireIssue: ptr(false), RequireSuccessfulBuilds: i(2), Webhooks: &openapi.RepositoryConfigurationWebhooksDto{ @@ -205,6 +208,7 @@ func TestPatchRepository_ClearFields(t *testing.T) { Configuration: &openapi.RepositoryConfigurationPatchDto{ AccessKeys: []openapi.RepositoryConfigurationAccessKeyDto{}, CommitMessageType: ptr(""), + ActionsAccess: ptr(""), Webhooks: &openapi.RepositoryConfigurationWebhooksDto{ Additional: []openapi.RepositoryConfigurationWebhookDto{}, }, @@ -223,6 +227,7 @@ func TestPatchRepository_ClearFields(t *testing.T) { Configuration: &openapi.RepositoryConfigurationDto{ AccessKeys: nil, CommitMessageType: nil, + ActionsAccess: nil, RequireIssue: ptr(false), RequireSuccessfulBuilds: i(1), Webhooks: &openapi.RepositoryConfigurationWebhooksDto{