diff --git a/README.md b/README.md index 423e3d0..ee20d69 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,6 @@ the [`local-config.yaml`][config] can be used to set the variables. | `REPOSITORY_TYPES` | | Comma separated list of supported repository types. | | `REPOSITORY_KEY_SEPARATOR` | `.` | Single character used to separate repository name from repository type. repository name and repository type must not contain separator. | | | | | -| `ALLOWED_FILE_CATEGORIES` | | List of allowed keys for the filecategory field in repositories. Parsed as a json array, example value: `["key1","key2"]`. All keys not in this list are rejected on writes, and silently dropped when reading. | | | | | | `REDIS_URL` | | Url to an optional Redis instance to use as a shared cache. Will use in-memory cache if left blank | | `REDIS_PASSWORD` | | Password for the Redis instance. Can be read from Vault via `VAULT_SECRETS_CONFIG` | diff --git a/api/generated_model_repository_create_dto.go b/api/generated_model_repository_create_dto.go index 82e2cc7..3aad4e0 100644 --- a/api/generated_model_repository_create_dto.go +++ b/api/generated_model_repository_create_dto.go @@ -22,8 +22,6 @@ type RepositoryCreateDto struct { // this repository contains unit tests (currently ignored except for helm charts) Unittest *bool `yaml:"unittest,omitempty" json:"unittest,omitempty"` Configuration *RepositoryConfigurationDto `yaml:"configuration,omitempty" json:"configuration,omitempty"` - // Assign a category to a list of files, e.g. to mark them for caching purposes. The key is the category name, and the value is a list of paths. Files are considered to have that category if their path is in the list. - Filecategory map[string][]string `yaml:"filecategory,omitempty" json:"filecategory,omitempty"` // The jira issue to use for committing a change, or the last jira issue used. JiraIssue string `yaml:"-" json:"jiraIssue"` // A map of arbitrary string labels attached to this repository. diff --git a/api/generated_model_repository_dto.go b/api/generated_model_repository_dto.go index 478e8ed..b816ed7 100644 --- a/api/generated_model_repository_dto.go +++ b/api/generated_model_repository_dto.go @@ -23,8 +23,6 @@ type RepositoryDto struct { // this repository contains unit tests (currently ignored except for helm charts) Unittest *bool `yaml:"unittest,omitempty" json:"unittest,omitempty"` Configuration *RepositoryConfigurationDto `yaml:"configuration,omitempty" json:"configuration,omitempty"` - // Assign a category to a list of files, e.g. to mark them for caching purposes. The key is the category name, and the value is a list of paths. Files are considered to have that category if their path is in the list. - Filecategory map[string][]string `yaml:"filecategory,omitempty" json:"filecategory,omitempty"` // ISO-8601 UTC date time at which this information was originally committed. When sending an update, include the original timestamp you got so we can detect concurrent updates. TimeStamp string `yaml:"-" json:"timeStamp"` // The git commit hash this information was originally committed under. When sending an update, include the original commitHash you got so we can detect concurrent updates. diff --git a/api/generated_model_repository_patch_dto.go b/api/generated_model_repository_patch_dto.go index e0de48c..87c64f5 100644 --- a/api/generated_model_repository_patch_dto.go +++ b/api/generated_model_repository_patch_dto.go @@ -22,8 +22,6 @@ type RepositoryPatchDto struct { // this repository contains unit tests (currently ignored except for helm charts) Unittest *bool `yaml:"unittest,omitempty" json:"unittest,omitempty"` Configuration *RepositoryConfigurationPatchDto `yaml:"configuration,omitempty" json:"configuration,omitempty"` - // Assign a category to a list of files, e.g. to mark them for caching purposes. The key is the category name, and the value is a list of paths. Files are considered to have that category if their path is in the list. - Filecategory map[string][]string `yaml:"filecategory,omitempty" json:"filecategory,omitempty"` // ISO-8601 UTC date time at which this information was originally committed. When sending an update, include the original timestamp you got so we can detect concurrent updates. TimeStamp string `yaml:"-" json:"timeStamp"` // The git commit hash this information was originally committed under. When sending an update, include the original commitHash you got so we can detect concurrent updates. diff --git a/api/openapi-v3-spec.yaml b/api/openapi-v3-spec.yaml index d053dc9..f0a1260 100644 --- a/api/openapi-v3-spec.yaml +++ b/api/openapi-v3-spec.yaml @@ -1820,8 +1820,6 @@ components: default: false configuration: $ref: '#/components/schemas/RepositoryConfigurationDto' - filecategory: - $ref: '#/components/schemas/RepositoryFileCategoriesDto' timeStamp: description: 'ISO-8601 UTC date time at which this information was originally committed. When sending an update, include the original timestamp you got so we can detect concurrent updates.' type: string @@ -1875,8 +1873,6 @@ components: default: false configuration: $ref: '#/components/schemas/RepositoryConfigurationDto' - filecategory: - $ref: '#/components/schemas/RepositoryFileCategoriesDto' jiraIssue: description: 'The jira issue to use for committing a change, or the last jira issue used.' type: string @@ -1918,8 +1914,6 @@ components: default: false configuration: $ref: '#/components/schemas/RepositoryConfigurationPatchDto' - filecategory: - $ref: '#/components/schemas/RepositoryFileCategoriesDto' timeStamp: description: 'ISO-8601 UTC date time at which this information was originally committed. When sending an update, include the original timestamp you got so we can detect concurrent updates.' type: string @@ -2235,17 +2229,6 @@ components: properties: text: type: string - RepositoryFileCategoriesDto: - description: 'Assign a category to a list of files, e.g. to mark them for caching purposes. The key is the category name, and the value is a list of paths. Files are considered to have that category if their path is in the list.' - type: object - examples: - - cache-template: - - templates/template1.yaml - - another/path/template2.json - additionalProperties: - type: array - items: - type: string ConditionReferenceDto: description: Configuration of conditional build references. type: object diff --git a/internal/acorn/config/customconfigint.go b/internal/acorn/config/customconfigint.go index 18544c2..7bee1fd 100644 --- a/internal/acorn/config/customconfigint.go +++ b/internal/acorn/config/customconfigint.go @@ -75,8 +75,6 @@ type CustomConfiguration interface { NotificationConsumerConfigs() map[string]NotificationConsumerConfig - AllowedFileCategories() []string - VCSConfigs() map[string]VCSConfig WebhooksProcessAsync() bool UserPrefix() string @@ -138,7 +136,6 @@ const ( KeyRepositoryKeySeparator = "REPOSITORY_KEY_SEPARATOR" KeyRepositoryTypes = "REPOSITORY_TYPES" KeyNotificationConsumerConfigs = "NOTIFICATION_CONSUMER_CONFIGS" - KeyAllowedFileCategories = "ALLOWED_FILE_CATEGORIES" KeyRedisUrl = "REDIS_URL" KeyRedisPassword = "REDIS_PASSWORD" KeyPullRequestBuildUrl = "PULL_REQUEST_BUILD_URL" diff --git a/internal/repository/config/accessors.go b/internal/repository/config/accessors.go index d121971..f4db57e 100644 --- a/internal/repository/config/accessors.go +++ b/internal/repository/config/accessors.go @@ -156,10 +156,6 @@ func (c *CustomConfigImpl) NotificationConsumerConfigs() map[string]config.Notif return c.VNotificationConsumerConfigs } -func (c *CustomConfigImpl) AllowedFileCategories() []string { - return c.VAllowedFileCategories -} - func (c *CustomConfigImpl) Kafka() *kafka.Config { return c.VKafkaConfig } diff --git a/internal/repository/config/config.go b/internal/repository/config/config.go index eb249ee..61b17d6 100644 --- a/internal/repository/config/config.go +++ b/internal/repository/config/config.go @@ -264,17 +264,6 @@ var CustomConfigItems = []auconfigapi.ConfigItem{ return err }, }, - { - Key: config.KeyAllowedFileCategories, - EnvName: config.KeyAllowedFileCategories, - Default: "", - Description: "allowed filecategory keys", - Validate: func(key string) error { - value := auconfigenv.Get(key) - _, err := parseAllowedFileCategories(value) - return err - }, - }, { Key: config.KeyRedisUrl, EnvName: config.KeyRedisUrl, diff --git a/internal/repository/config/plumbing.go b/internal/repository/config/plumbing.go index 084dd9e..441e8b6 100644 --- a/internal/repository/config/plumbing.go +++ b/internal/repository/config/plumbing.go @@ -54,7 +54,6 @@ type CustomConfigImpl struct { VRepositoryTypes string VRepositoryKeySeparator string VNotificationConsumerConfigs map[string]config.NotificationConsumerConfig - VAllowedFileCategories []string VRedisUrl string VRedisPassword string VPullRequestBuildUrl string @@ -120,7 +119,6 @@ func (c *CustomConfigImpl) Obtain(getter func(key string) string) { c.VRepositoryTypes = getter(config.KeyRepositoryTypes) c.VRepositoryKeySeparator = getter(config.KeyRepositoryKeySeparator) c.VNotificationConsumerConfigs, _ = parseNotificationConsumerConfigs(getter(config.KeyNotificationConsumerConfigs)) - c.VAllowedFileCategories, _ = parseAllowedFileCategories(getter(config.KeyAllowedFileCategories)) c.VRedisUrl = getter(config.KeyRedisUrl) c.VRedisPassword = getter(config.KeyRedisPassword) c.VPullRequestBuildUrl = getter(config.KeyPullRequestBuildUrl) @@ -232,19 +230,6 @@ func parseNotificationConsumerConfigs(rawJson string) (map[string]config.Notific return result, nil } -func parseAllowedFileCategories(rawJson string) ([]string, error) { - result := make([]string, 0) - if rawJson == "" { - return result, nil - } - - if err := json.Unmarshal([]byte(rawJson), &result); err != nil { - return nil, err - } - - return result, nil -} - type rawVCSConfig struct { Platform string `json:"platform"` APIBaseURL string `json:"apiBaseURL"` diff --git a/internal/repository/config/validation_test.go b/internal/repository/config/validation_test.go index db40841..cb8f529 100644 --- a/internal/repository/config/validation_test.go +++ b/internal/repository/config/validation_test.go @@ -79,7 +79,7 @@ func TestValidate_LotsOfErrors(t *testing.T) { _, err := tstSetupCutAndLogRecorder(t, "invalid-config-values.yaml") require.NotNil(t, err) - require.Contains(t, err.Error(), "some configuration values failed to validate or parse. There were 26 error(s). See details above") + require.Contains(t, err.Error(), "some configuration values failed to validate or parse. There were 25 error(s). See details above") actualLog := goauzerolog.RecordedLogForTesting.String() diff --git a/internal/service/repositories/repositories.go b/internal/service/repositories/repositories.go index 2de3024..a947a92 100644 --- a/internal/service/repositories/repositories.go +++ b/internal/service/repositories/repositories.go @@ -168,21 +168,6 @@ func (s *Impl) GetRepository(ctx context.Context, repoKey string) (openapi.Repos repositoryDto.Configuration = &repoConfig } - if err == nil && repositoryDto.Filecategory != nil { - // filter by allowed keys - allowedKeys := s.CustomConfiguration.AllowedFileCategories() - for key, _ := range repositoryDto.Filecategory { - if !sliceContains(allowedKeys, key) { - delete(repositoryDto.Filecategory, key) - } - } - - if len(repositoryDto.Filecategory) == 0 { - // drop empty map completely - repositoryDto.Filecategory = nil - } - } - return repositoryDto, err } @@ -275,7 +260,6 @@ func (s *Impl) mapRepoCreateDtoToRepoDto(repositoryCreateDto openapi.RepositoryC Url: repositoryCreateDto.Url, Mainline: repositoryCreateDto.Mainline, Configuration: repositoryCreateDto.Configuration, - Filecategory: repositoryCreateDto.Filecategory, Generator: repositoryCreateDto.Generator, Unittest: repositoryCreateDto.Unittest, Labels: repositoryCreateDto.Labels, @@ -292,9 +276,6 @@ func (s *Impl) validateRepositoryCreateDto(ctx context.Context, key string, dto if dto.JiraIssue == "" { messages = append(messages, "field jiraIssue is mandatory") } - if dto.Filecategory != nil { - messages = s.validateFilecategory(messages, dto.Filecategory) - } if len(messages) > 0 { details := strings.Join(messages, ", ") @@ -361,9 +342,6 @@ func (s *Impl) validateExistingRepositoryDto(ctx context.Context, key string, dt if dto.JiraIssue == "" { messages = append(messages, "field jiraIssue is mandatory for updates") } - if dto.Filecategory != nil { - messages = s.validateFilecategory(messages, dto.Filecategory) - } if len(messages) > 0 { details := strings.Join(messages, ", ") @@ -428,9 +406,6 @@ func (s *Impl) validateRepositoryPatchDto(ctx context.Context, key string, patch messages = validateOwner(messages, dto.Owner) messages = validateUrl(messages, dto.Url) messages = validateMainline(messages, dto.Mainline) - if dto.Filecategory != nil { - messages = s.validateFilecategory(messages, dto.Filecategory) - } if patchDto.CommitHash == "" { messages = append(messages, "field commitHash is mandatory for patching") @@ -458,7 +433,6 @@ func patchRepository(current openapi.RepositoryDto, patch openapi.RepositoryPatc Generator: patchStringPtr(patch.Generator, current.Generator), Unittest: patchPtr[bool](patch.Unittest, current.Unittest), Configuration: patchConfiguration(patch.Configuration, current.Configuration), - Filecategory: patchFilecategory(patch.Filecategory, current.Filecategory), Labels: patchLabels(patch.Labels, current.Labels), TimeStamp: patch.TimeStamp, CommitHash: patch.CommitHash, @@ -498,10 +472,6 @@ func patchApprovers(patch map[string][]string, original map[string][]string) map return patchMapStringListString(patch, original) } -func patchFilecategory(patch map[string][]string, original map[string][]string) map[string][]string { - return patchMapStringListString(patch, original) -} - func patchMapStringListString(patch map[string][]string, original map[string][]string) map[string][]string { if patch != nil { if len(patch) == 0 { @@ -700,18 +670,6 @@ func validateMainline(messages []string, mainline string) []string { return messages } -func (s *Impl) validateFilecategory(messages []string, filecategories map[string][]string) []string { - allowedCategories := s.CustomConfiguration.AllowedFileCategories() - - for category, _ := range filecategories { - if !sliceContains(allowedCategories, category) { - messages = append(messages, fmt.Sprintf("filecategory keys must be one of %s", strings.Join(allowedCategories, ","))) - } - } - - return messages -} - func (s *Impl) expandRefProtectionsExemptionLists(ctx context.Context, protections *openapi.RefProtections) *openapi.RefProtections { if protections == nil { return protections diff --git a/internal/service/repositories/repositories_test.go b/internal/service/repositories/repositories_test.go index 3bf877b..f25bea4 100644 --- a/internal/service/repositories/repositories_test.go +++ b/internal/service/repositories/repositories_test.go @@ -32,7 +32,6 @@ func createRepositoryDto() openapi.RepositoryDto { Generator: ptr("generator"), Unittest: ptr(true), Configuration: createRepositoryConfigurationDto(), - Filecategory: map[string][]string{"a": {"path/a.yaml"}}, Labels: map[string]string{"label": "originalValue"}, TimeStamp: "ts", CommitHash: "hash", @@ -155,10 +154,9 @@ func TestPatchRepository_ReplaceAll(t *testing.T) { Approvers: map[string][]string{"group": {"newapprover1"}}, Archived: ptr(true), }, - Filecategory: map[string][]string{"b": {"b.yaml", "b.json"}}, - Labels: map[string]string{"label": "patchedValue"}, - TimeStamp: "newts", - CommitHash: "newhash", + Labels: map[string]string{"label": "patchedValue"}, + TimeStamp: "newts", + CommitHash: "newhash", }, openapi.RepositoryDto{ Owner: "newowner", Url: "newurl", @@ -191,10 +189,9 @@ func TestPatchRepository_ReplaceAll(t *testing.T) { Approvers: map[string][]string{"group": {"newapprover1"}}, Archived: ptr(true), }, - Filecategory: map[string][]string{"b": {"b.yaml", "b.json"}}, - Labels: map[string]string{"label": "patchedValue"}, - TimeStamp: "newts", - CommitHash: "newhash", + Labels: map[string]string{"label": "patchedValue"}, + TimeStamp: "newts", + CommitHash: "newhash", }) } @@ -214,10 +211,9 @@ func TestPatchRepository_ClearFields(t *testing.T) { }, Approvers: map[string][]string{}, }, - Filecategory: map[string][]string{}, - Labels: map[string]string{}, - TimeStamp: "", - CommitHash: "", + Labels: map[string]string{}, + TimeStamp: "", + CommitHash: "", }, openapi.RepositoryDto{ Owner: "", Url: "", @@ -236,10 +232,9 @@ func TestPatchRepository_ClearFields(t *testing.T) { Approvers: nil, Archived: ptr(false), }, - Filecategory: nil, - Labels: nil, - TimeStamp: "", - CommitHash: "", + Labels: nil, + TimeStamp: "", + CommitHash: "", }) } diff --git a/local-config.template.yaml b/local-config.template.yaml index 8686730..9396f90 100644 --- a/local-config.template.yaml +++ b/local-config.template.yaml @@ -67,8 +67,6 @@ ALERT_TARGET_REGEX: '(^https://domain[.]com/)|(@domain[.]com$)' OWNER_ALIAS_FILTER_REGEX: '.*' -ALLOWED_FILE_CATEGORIES: '["template"]' - # The NOTIFICATION_CONSUMER_CONFIGS env below is an example: #NOTIFICATION_CONSUMER_CONFIGS: >- diff --git a/test/acceptance/util_dtos_test.go b/test/acceptance/util_dtos_test.go index 04ca5f7..4c68967 100644 --- a/test/acceptance/util_dtos_test.go +++ b/test/acceptance/util_dtos_test.go @@ -229,9 +229,6 @@ func tstUpdatedServicePayload(name string) openapi.NotificationPayload { // repository func tstRepository() openapi.RepositoryDto { - fc := map[string][]string{ - "cached-template": {"cached-templates/tpl1.yaml", "more/cached/templates/tpl2.yaml"}, - } return openapi.RepositoryDto{ Owner: "some-owner", Url: "ssh://git@bitbucket.some-organisation.com:7999/helm/karma-wrapper.git", @@ -259,10 +256,9 @@ func tstRepository() openapi.RepositoryDto { }, Approvers: map[string][]string{"testing": {"some-user"}}, }, - Filecategory: fc, - TimeStamp: "2022-11-06T18:14:10Z", - CommitHash: "6c8ac2c35791edf9979623c717a243fc53400000", - JiraIssue: "ISSUE-2345", + TimeStamp: "2022-11-06T18:14:10Z", + CommitHash: "6c8ac2c35791edf9979623c717a243fc53400000", + JiraIssue: "ISSUE-2345", } } @@ -353,10 +349,6 @@ configuration: requireConditions: snyk-key: refMatcher: master -filecategory: - cached-template: - - cached-templates/tpl1.yaml - - more/cached/templates/tpl2.yaml ` } diff --git a/test/mock/metadatamock/metadata.go b/test/mock/metadatamock/metadata.go index 6333aa6..1f4c0e2 100644 --- a/test/mock/metadatamock/metadata.go +++ b/test/mock/metadatamock/metadata.go @@ -179,9 +179,6 @@ configuration: const deployment2 = `mainline: main url: ssh://git@bitbucket.some-organisation.com:7999/PROJECT/whatever-deployment.git generator: third-party-software -filecategory: - forbidden-key: - - some/interesting/file.txt ` const implementation = `mainline: master diff --git a/test/resources/acceptance-expected/repository-create-cache.json b/test/resources/acceptance-expected/repository-create-cache.json index b363475..34da291 100644 --- a/test/resources/acceptance-expected/repository-create-cache.json +++ b/test/resources/acceptance-expected/repository-create-cache.json @@ -37,12 +37,6 @@ ] } }, - "filecategory": { - "cached-template": [ - "cached-templates/tpl1.yaml", - "more/cached/templates/tpl2.yaml" - ] - }, "jiraIssue": "ISSUE-2345", "mainline": "master", "owner": "some-owner", diff --git a/test/resources/acceptance-expected/repository-create.json b/test/resources/acceptance-expected/repository-create.json index ebc3b47..b53f8da 100644 --- a/test/resources/acceptance-expected/repository-create.json +++ b/test/resources/acceptance-expected/repository-create.json @@ -32,12 +32,6 @@ ] } }, - "filecategory": { - "cached-template": [ - "cached-templates/tpl1.yaml", - "more/cached/templates/tpl2.yaml" - ] - }, "jiraIssue": "ISSUE-2345", "mainline": "master", "owner": "some-owner", diff --git a/test/resources/acceptance-expected/repository-update-cache.json b/test/resources/acceptance-expected/repository-update-cache.json index b363475..34da291 100644 --- a/test/resources/acceptance-expected/repository-update-cache.json +++ b/test/resources/acceptance-expected/repository-update-cache.json @@ -37,12 +37,6 @@ ] } }, - "filecategory": { - "cached-template": [ - "cached-templates/tpl1.yaml", - "more/cached/templates/tpl2.yaml" - ] - }, "jiraIssue": "ISSUE-2345", "mainline": "master", "owner": "some-owner", diff --git a/test/resources/acceptance-expected/repository-update-newowner-cache.json b/test/resources/acceptance-expected/repository-update-newowner-cache.json index ac19cd6..be39799 100644 --- a/test/resources/acceptance-expected/repository-update-newowner-cache.json +++ b/test/resources/acceptance-expected/repository-update-newowner-cache.json @@ -37,12 +37,6 @@ ] } }, - "filecategory": { - "cached-template": [ - "cached-templates/tpl1.yaml", - "more/cached/templates/tpl2.yaml" - ] - }, "jiraIssue": "ISSUE-2345", "mainline": "master", "owner": "deleteme", diff --git a/test/resources/acceptance-expected/repository-update-newowner.json b/test/resources/acceptance-expected/repository-update-newowner.json index a6b15ad..ccfb772 100644 --- a/test/resources/acceptance-expected/repository-update-newowner.json +++ b/test/resources/acceptance-expected/repository-update-newowner.json @@ -28,12 +28,6 @@ ] } }, - "filecategory": { - "cached-template": [ - "cached-templates/tpl1.yaml", - "more/cached/templates/tpl2.yaml" - ] - }, "jiraIssue": "ISSUE-2345", "mainline": "master", "owner": "deleteme", diff --git a/test/resources/acceptance-expected/repository-update.json b/test/resources/acceptance-expected/repository-update.json index f6c925e..c147fc5 100644 --- a/test/resources/acceptance-expected/repository-update.json +++ b/test/resources/acceptance-expected/repository-update.json @@ -32,12 +32,6 @@ ] } }, - "filecategory": { - "cached-template": [ - "cached-templates/tpl1.yaml", - "more/cached/templates/tpl2.yaml" - ] - }, "jiraIssue": "ISSUE-2345", "mainline": "master", "owner": "some-owner", diff --git a/test/resources/invalid-config-values.yaml b/test/resources/invalid-config-values.yaml index 4718c57..1d4856b 100644 --- a/test/resources/invalid-config-values.yaml +++ b/test/resources/invalid-config-values.yaml @@ -53,5 +53,3 @@ NOTIFICATION_CONSUMER_CONFIGS: >- "url": "https://valid.url.com/for/a/webhook" } } - -ALLOWED_FILE_CATEGORIES: '["a","b"' diff --git a/test/resources/valid-config-unique.yaml b/test/resources/valid-config-unique.yaml index acd2b19..039ddf6 100644 --- a/test/resources/valid-config-unique.yaml +++ b/test/resources/valid-config-unique.yaml @@ -43,5 +43,3 @@ REPOSITORY_KEY_SEPARATOR: ';' REPOSITORY_TYPES: 'some-type,some-other-type' NOTIFICATION_CONSUMER_CONFIGS: "{}" - -ALLOWED_FILE_CATEGORIES: '' diff --git a/test/resources/valid-config.yaml b/test/resources/valid-config.yaml index 05b21ca..ef2f333 100644 --- a/test/resources/valid-config.yaml +++ b/test/resources/valid-config.yaml @@ -65,5 +65,3 @@ NOTIFICATION_CONSUMER_CONFIGS: >- "url": "https://some.url.com/for/the/webhook" } } - -ALLOWED_FILE_CATEGORIES: '["cached-template"]'