From da6debe5ec5cc40759c4c6fe22a7c242fd2068c6 Mon Sep 17 00:00:00 2001 From: Blake Patterson Date: Tue, 29 Oct 2024 09:48:51 -0400 Subject: [PATCH] chore(rn): add resource name to additional entities (#291) * chore(refactor): update servicename to serviceccrn throughout repo * chore(refactor): update component to use ccrn throughout repo * chore(refactor): update supportgroup to use ccrn throughout repo * chore(refactor): added ccrn field to component version * chore(refactor): revert changes to component version with ccrn This reverts commit 0b4b38615bf0ec07255ec7e3370d0149c3ba55e1. * Update tests.yaml (#323) * Update codeql.yaml (#325) * chore: add sleeps to suppress potential racing conditions which make tests fail. (#327) * chore: increase license location threshold (#329) * fix: Resolve the double port expose for Prometheus metrics (#333) * chore(doc):uploaded images for Prod. design doc. (#311) Co-authored-by: David Rochow * chore: create setup job in codeql.yaml (#335) * chore: remove generated code (#324) * chore: remove generated code * Automatic application of license header * chore: remove bot license header * Automatic application of license header --------- Co-authored-by: License Bot * chore: update build_query in codeql.yaml (#336) * chore(deps): bump github.com/brianvoe/gofakeit/v7 from 7.0.4 to 7.1.1 (#330) Bumps [github.com/brianvoe/gofakeit/v7](https://github.com/brianvoe/gofakeit) from 7.0.4 to 7.1.1. - [Release notes](https://github.com/brianvoe/gofakeit/releases) - [Commits](https://github.com/brianvoe/gofakeit/compare/v7.0.4...v7.1.1) --- updated-dependencies: - dependency-name: github.com/brianvoe/gofakeit/v7 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Michael Reimsbach * fix(test): added additonal readiness checks for DB (#334) Co-authored-by: Michael Reimsbach * merge * chore(refactor): update supportgroup to use ccrn throughout repo * chore(refactor): added ccrn field to component version * chore(refactor): revert changes to component version with ccrn This reverts commit 0b4b38615bf0ec07255ec7e3370d0149c3ba55e1. * fix wrong function name --------- Signed-off-by: dependabot[bot] Co-authored-by: Michael Reimsbach Co-authored-by: copyonwrite <73547592+copyonwrite@users.noreply.github.com> Co-authored-by: Dimitrios Tassopoulos <137508942+dimtas@users.noreply.github.com> Co-authored-by: Lola <163291542+lolaapenna@users.noreply.github.com> Co-authored-by: David Rochow Co-authored-by: License Bot Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- internal/api/graphql/gqlgen.yml | 14 +- .../graphql/graph/baseResolver/activity.go | 2 +- .../api/graphql/graph/baseResolver/common.go | 16 +- .../graphql/graph/baseResolver/component.go | 14 +- .../graph/baseResolver/component_version.go | 3 +- .../api/graphql/graph/baseResolver/issue.go | 4 +- .../graphql/graph/baseResolver/issue_match.go | 6 +- .../graph/baseResolver/issue_repository.go | 2 +- .../api/graphql/graph/baseResolver/service.go | 18 +- .../graph/baseResolver/support_group.go | 18 +- internal/api/graphql/graph/model/models.go | 14 +- .../activity/addService.graphql | 2 +- .../activity/directRelations.graphql | 2 +- .../queryCollection/activity/full.graphql | 6 +- .../activity/removeService.graphql | 2 +- .../queryCollection/component/create.graphql | 2 +- .../component/directRelations.graphql | 2 +- .../queryCollection/component/minimal.graphql | 2 +- .../queryCollection/component/update.graphql | 2 +- ...ntName.graphqls => componentCcrn.graphqls} | 2 +- .../componentInstance/directRelations.graphql | 2 +- ...viceName.graphqls => serviceCcrn.graphqls} | 2 +- ...ame.graphqls => supportGroupCcrn.graphqls} | 2 +- .../componentVersion/directRelations.graphql | 2 +- .../graph/queryCollection/issue/full.graphql | 6 +- .../issueRepository/directRelations.graphql | 2 +- .../service/addIssueRepository.graphql | 2 +- .../queryCollection/service/addOwner.graphql | 2 +- .../queryCollection/service/create.graphql | 2 +- .../service/directRelations.graphql | 4 +- .../queryCollection/service/minimal.graphql | 2 +- .../service/removeIssueRepository.graphql | 2 +- .../service/removeOwner.graphql | 2 +- .../queryCollection/service/update.graphql | 2 +- .../service/withMetadata.graphql | 2 +- ...viceNames.graphql => serviceCcrns.graphql} | 2 +- ...ames.graphql => supportGroupCcrns.graphql} | 2 +- .../supportGroup/addService.graphql | 4 +- .../supportGroup/create.graphql | 2 +- .../supportGroup/directRelations.graphql | 4 +- .../supportGroup/minimal.graphql | 2 +- .../supportGroup/removeService.graphql | 4 +- .../supportGroup/update.graphql | 2 +- .../user/directRelations.graphql | 4 +- .../graph/resolver/component_filter.go | 7 +- .../resolver/component_instance_filter.go | 14 +- .../resolver/issue_match_filter_value.go | 16 +- .../graphql/graph/resolver/service_filter.go | 14 +- .../graphql/graph/schema/activity.graphqls | 2 +- .../graphql/graph/schema/component.graphqls | 6 +- .../graph/schema/component_filter.graphqls | 2 +- .../graph/schema/component_instance.graphqls | 2 +- .../schema/component_instance_filter.graphqls | 4 +- .../graph/schema/component_version.graphqls | 2 +- .../graphql/graph/schema/issue_match.graphqls | 4 +- .../schema/issue_match_filter_value.graphqls | 4 +- .../graph/schema/issue_repository.graphqls | 2 +- .../api/graphql/graph/schema/service.graphqls | 8 +- .../graph/schema/service_filter.graphqls | 4 +- .../graph/schema/support_group.graphqls | 6 +- internal/app/component/component_handler.go | 16 +- .../app/component/component_handler_events.go | 10 +- .../component/component_handler_interface.go | 2 +- .../app/component/component_handler_test.go | 12 +- internal/app/issue/issue_handler_test.go | 4 +- .../issue_match/issue_match_handler_test.go | 2 +- .../issue_repository_handler_test.go | 2 +- .../issue_variant_handler_test.go | 2 +- internal/app/service/service_handler.go | 16 +- .../app/service/service_handler_events.go | 10 +- .../app/service/service_handler_interface.go | 2 +- internal/app/service/service_handler_test.go | 28 +-- .../support_group/support_group_handler.go | 18 +- .../support_group_handler_events.go | 10 +- .../support_group_handler_interface.go | 2 +- .../support_group_handler_test.go | 28 +-- internal/database/interface.go | 8 +- internal/database/mariadb/activity.go | 10 +- internal/database/mariadb/activity_test.go | 4 +- internal/database/mariadb/component.go | 28 +-- internal/database/mariadb/component_test.go | 46 ++-- .../database/mariadb/component_version.go | 11 +- .../mariadb/component_version_test.go | 6 +- internal/database/mariadb/entity.go | 22 +- internal/database/mariadb/init/schema.sql | 18 +- internal/database/mariadb/issue.go | 12 +- internal/database/mariadb/issue_match.go | 20 +- internal/database/mariadb/issue_match_test.go | 2 +- internal/database/mariadb/issue_repository.go | 12 +- .../database/mariadb/issue_repository_test.go | 4 +- internal/database/mariadb/issue_test.go | 14 +- internal/database/mariadb/service.go | 44 ++-- internal/database/mariadb/service_test.go | 68 +++--- internal/database/mariadb/support_group.go | 32 +-- .../database/mariadb/support_group_test.go | 58 ++--- internal/database/mariadb/test/fixture.go | 24 +- internal/e2e/activity_query_test.go | 2 +- internal/e2e/component_filter_query_test.go | 20 +- .../e2e/component_instance_filter_test.go | 40 ++-- internal/e2e/component_instance_query_test.go | 2 +- internal/e2e/component_query_test.go | 10 +- internal/e2e/component_version_query_test.go | 2 +- internal/e2e/issue_repository_query_test.go | 2 +- internal/e2e/service_filter_query_test.go | 38 +-- internal/e2e/service_query_test.go | 12 +- internal/e2e/support_group_query_test.go | 14 +- internal/e2e/user_query_test.go | 4 +- internal/entity/activity.go | 2 +- internal/entity/component.go | 4 +- internal/entity/component_version.go | 2 +- internal/entity/issue.go | 2 +- internal/entity/issue_match.go | 6 +- internal/entity/issue_repository.go | 4 +- internal/entity/service.go | 6 +- internal/entity/support_group.go | 4 +- internal/entity/test/component.go | 2 +- internal/entity/test/service.go | 2 +- internal/entity/test/support_group.go | 2 +- internal/mocks/mock_Database.go | 220 +++++++++--------- internal/mocks/mock_Heureka.go | 160 ++++++------- scanner/k8s-assets/client/generated.go | 82 +++---- .../query/addServiceToSupportGroup.graphql | 2 +- .../client/query/component_create.graphql | 2 +- .../client/query/component_query.graphql | 2 +- .../client/query/service_create.graphql | 2 +- .../client/query/support_group_create.graphql | 2 +- scanner/k8s-assets/main.go | 7 +- scanner/k8s-assets/processor/processor.go | 24 +- scanner/k8s-assets/scanner/config.go | 2 +- scanner/k8s-assets/scanner/scanner.go | 10 +- scanner/keppel/client/generated.go | 34 +-- .../client/query/createComponent.graphql | 2 +- .../query/listComponentsAndVersions.graphql | 2 +- scanner/keppel/go.mod | 6 + scanner/keppel/go.sum | 14 ++ scanner/keppel/main.go | 6 +- scanner/keppel/processor/processor.go | 2 +- 137 files changed, 846 insertions(+), 816 deletions(-) rename internal/api/graphql/graph/queryCollection/componentFilter/{componentName.graphqls => componentCcrn.graphqls} (86%) rename internal/api/graphql/graph/queryCollection/componentInstanceFilter/{serviceName.graphqls => serviceCcrn.graphqls} (87%) rename internal/api/graphql/graph/queryCollection/componentInstanceFilter/{supportGroupName.graphqls => supportGroupCcrn.graphqls} (85%) rename internal/api/graphql/graph/queryCollection/serviceFilter/{serviceNames.graphql => serviceCcrns.graphql} (86%) rename internal/api/graphql/graph/queryCollection/serviceFilter/{supportGroupNames.graphql => supportGroupCcrns.graphql} (85%) diff --git a/internal/api/graphql/gqlgen.yml b/internal/api/graphql/gqlgen.yml index d7316191..dd2ca753 100644 --- a/internal/api/graphql/gqlgen.yml +++ b/internal/api/graphql/gqlgen.yml @@ -203,29 +203,29 @@ models: resolver: true affectedService: resolver: true - componentName: + componentCcrn: resolver: true - supportGroupName: + supportGroupCcrn: resolver: true ServiceFilterValue: fields: - serviceName: + serviceCcrn: resolver: true uniqueUserId: resolver: true userName: resolver: true - supportGroupName: + supportGroupCcrn: resolver: true ComponentInstanceFilterValue: fields: - serviceName: + serviceCcrn: resolver: true - supportGroupName: + supportGroupCcrn: resolver: true ccrn: resolver: true ComponentFilterValue: fields: - componentName: + componentCcrn: resolver: true diff --git a/internal/api/graphql/graph/baseResolver/activity.go b/internal/api/graphql/graph/baseResolver/activity.go index c078e632..ce2a17ad 100644 --- a/internal/api/graphql/graph/baseResolver/activity.go +++ b/internal/api/graphql/graph/baseResolver/activity.go @@ -90,7 +90,7 @@ func ActivityBaseResolver(app app.Heureka, ctx context.Context, filter *model.Ac f := &entity.ActivityFilter{ Paginated: entity.Paginated{First: first, After: afterId}, - ServiceName: filter.ServiceName, + ServiceCCRN: filter.ServiceCcrn, ServiceId: sId, IssueId: issueId, } diff --git a/internal/api/graphql/graph/baseResolver/common.go b/internal/api/graphql/graph/baseResolver/common.go index d57396ea..dcb162b5 100644 --- a/internal/api/graphql/graph/baseResolver/common.go +++ b/internal/api/graphql/graph/baseResolver/common.go @@ -14,11 +14,11 @@ import ( ) var ( - FilterDisplayServiceName string = "Service Name" - FilterDisplaySupportGroupName string = "Support Group Name" + FilterDisplayServiceCcrn string = "Service CCRN" + FilterDisplaySupportGroupCcrn string = "Support Group CCRN" FilterDisplayUserName string = "User Name" FilterDisplayUniqueUserId string = "Unique User ID" - FilterDisplayComponentName string = "Component Name" + FilterDisplayComponentCcrn string = "Component CCRN" FilterDisplayIssueType string = "Issue Type" FilterDisplayIssueMatchStatus string = "Issue Match Status" FilterDisplayIssueMatchID string = "Issue Match ID" @@ -26,21 +26,21 @@ var ( FilterDisplayIssueSeverity string = "Severity" FilterDisplayCcrn string = "CCRN" - ServiceFilterServiceName string = "serviceName" + ServiceFilterServiceCcrn string = "serviceCcrn" ServiceFilterUniqueUserId string = "uniqueUserId" ServiceFilterType string = "type" ServiceFilterUserName string = "userName" - ServiceFilterSupportGroupName string = "supportGroupName" + ServiceFilterSupportGroupCcrn string = "supportGroupCcrn" IssueMatchFilterPrimaryName string = "primaryName" - IssueMatchFilterComponentName string = "componentName" + IssueMatchFilterComponentCcrn string = "componentCcrn" IssueMatchFilterIssueType string = "issueType" IssueMatchFilterStatus string = "status" IssueMatchFilterSeverity string = "severity" IssueMatchFilterAffectedService string = "affectedService" - IssueMatchFilterSupportGroupName string = "supportGroupName" + IssueMatchFilterSupportGroupCcrn string = "supportGroupCcrn" - ComponentFilterComponentName string = "componentName" + ComponentFilterComponentCcrn string = "componentCcrn" ) type ResolverError struct { diff --git a/internal/api/graphql/graph/baseResolver/component.go b/internal/api/graphql/graph/baseResolver/component.go index 8d0d5204..91cedbc1 100644 --- a/internal/api/graphql/graph/baseResolver/component.go +++ b/internal/api/graphql/graph/baseResolver/component.go @@ -71,7 +71,7 @@ func ComponentBaseResolver(app app.Heureka, ctx context.Context, filter *model.C f := &entity.ComponentFilter{ Paginated: entity.Paginated{First: first, After: afterId}, - Name: filter.ComponentName, + CCRN: filter.ComponentCcrn, } opt := GetListOptions(requestedFields) @@ -107,11 +107,11 @@ func ComponentBaseResolver(app app.Heureka, ctx context.Context, filter *model.C } -func ComponentNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.ComponentFilter) (*model.FilterItem, error) { +func ComponentCcrnBaseResolver(app app.Heureka, ctx context.Context, filter *model.ComponentFilter) (*model.FilterItem, error) { requestedFields := GetPreloads(ctx) logrus.WithFields(logrus.Fields{ "requestedFields": requestedFields, - }).Debug("Called ComponentNameBaseResolver") + }).Debug("Called ComponentCcrnBaseResolver") if filter == nil { filter = &model.ComponentFilter{} @@ -119,15 +119,15 @@ func ComponentNameBaseResolver(app app.Heureka, ctx context.Context, filter *mod f := &entity.ComponentFilter{ Paginated: entity.Paginated{}, - Name: filter.ComponentName, + CCRN: filter.ComponentCcrn, } opt := GetListOptions(requestedFields) - names, err := app.ListComponentNames(f, opt) + names, err := app.ListComponentCcrns(f, opt) if err != nil { - return nil, NewResolverError("ComponentNameBaseReolver", err.Error()) + return nil, NewResolverError("ComponentCcrnBaseReolver", err.Error()) } var pointerNames []*string @@ -137,7 +137,7 @@ func ComponentNameBaseResolver(app app.Heureka, ctx context.Context, filter *mod } filterItem := model.FilterItem{ - DisplayName: &FilterDisplayComponentName, + DisplayName: &FilterDisplayComponentCcrn, Values: pointerNames, } diff --git a/internal/api/graphql/graph/baseResolver/component_version.go b/internal/api/graphql/graph/baseResolver/component_version.go index c6e19e5a..040ad90e 100644 --- a/internal/api/graphql/graph/baseResolver/component_version.go +++ b/internal/api/graphql/graph/baseResolver/component_version.go @@ -5,6 +5,7 @@ package baseResolver import ( "context" + "github.com/cloudoperators/heureka/internal/api/graphql/graph/model" "github.com/cloudoperators/heureka/internal/app" "github.com/cloudoperators/heureka/internal/entity" @@ -97,7 +98,7 @@ func ComponentVersionBaseResolver(app app.Heureka, ctx context.Context, filter * Paginated: entity.Paginated{First: first, After: afterId}, IssueId: issueId, ComponentId: componentId, - ComponentName: filter.ComponentName, + ComponentCCRN: filter.ComponentCcrn, Version: filter.Version, } diff --git a/internal/api/graphql/graph/baseResolver/issue.go b/internal/api/graphql/graph/baseResolver/issue.go index 9cc8b6df..065db6df 100644 --- a/internal/api/graphql/graph/baseResolver/issue.go +++ b/internal/api/graphql/graph/baseResolver/issue.go @@ -99,7 +99,7 @@ func IssueBaseResolver(app app.Heureka, ctx context.Context, filter *model.Issue f := &entity.IssueFilter{ Paginated: entity.Paginated{First: first, After: afterId}, - ServiceName: filter.AffectedService, + ServiceCCRN: filter.AffectedService, ActivityId: activityId, ComponentVersionId: cvId, PrimaryName: filter.PrimaryName, @@ -170,7 +170,7 @@ func IssueNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.I f := &entity.IssueFilter{ Paginated: entity.Paginated{}, - ServiceName: filter.AffectedService, + ServiceCCRN: filter.AffectedService, PrimaryName: filter.PrimaryName, Type: lo.Map(filter.IssueType, func(item *model.IssueTypes, _ int) *string { return pointer.String(item.String()) }), Search: filter.Search, diff --git a/internal/api/graphql/graph/baseResolver/issue_match.go b/internal/api/graphql/graph/baseResolver/issue_match.go index 2d59b5f9..5ae2aa9f 100644 --- a/internal/api/graphql/graph/baseResolver/issue_match.go +++ b/internal/api/graphql/graph/baseResolver/issue_match.go @@ -105,15 +105,15 @@ func IssueMatchBaseResolver(app app.Heureka, ctx context.Context, filter *model. f := &entity.IssueMatchFilter{ Id: issue_match_ids, Paginated: entity.Paginated{First: first, After: afterId}, - AffectedServiceName: filter.AffectedService, + AffectedServiceCCRN: filter.AffectedService, Status: lo.Map(filter.Status, func(item *model.IssueMatchStatusValues, _ int) *string { return pointer.String(item.String()) }), SeverityValue: lo.Map(filter.Severity, func(item *model.SeverityValues, _ int) *string { return pointer.String(item.String()) }), - SupportGroupName: filter.SupportGroupName, + SupportGroupCCRN: filter.SupportGroupCcrn, IssueId: issueId, EvidenceId: eId, ComponentInstanceId: ciId, Search: filter.Search, - ComponentName: filter.ComponentName, + ComponentCCRN: filter.ComponentCcrn, PrimaryName: filter.PrimaryName, IssueType: lo.Map(filter.IssueType, func(item *model.IssueTypes, _ int) *string { return pointer.String(item.String()) }), } diff --git a/internal/api/graphql/graph/baseResolver/issue_repository.go b/internal/api/graphql/graph/baseResolver/issue_repository.go index 3d346f1c..8f571b0d 100644 --- a/internal/api/graphql/graph/baseResolver/issue_repository.go +++ b/internal/api/graphql/graph/baseResolver/issue_repository.go @@ -89,7 +89,7 @@ func IssueRepositoryBaseResolver(app app.Heureka, ctx context.Context, filter *m Paginated: entity.Paginated{First: first, After: afterId}, ServiceId: serviceId, Name: filter.Name, - ServiceName: filter.ServiceName, + ServiceCCRN: filter.ServiceCcrn, } opt := GetListOptions(requestedFields) diff --git a/internal/api/graphql/graph/baseResolver/service.go b/internal/api/graphql/graph/baseResolver/service.go index 8c9ea076..a9d1ab90 100644 --- a/internal/api/graphql/graph/baseResolver/service.go +++ b/internal/api/graphql/graph/baseResolver/service.go @@ -96,8 +96,8 @@ func ServiceBaseResolver(app app.Heureka, ctx context.Context, filter *model.Ser f := &entity.ServiceFilter{ Paginated: entity.Paginated{First: first, After: afterId}, - SupportGroupName: filter.SupportGroupName, - Name: filter.ServiceName, + SupportGroupCCRN: filter.SupportGroupCcrn, + CCRN: filter.ServiceCcrn, OwnerName: filter.UserName, OwnerId: ownerId, ActivityId: activityId, @@ -144,11 +144,11 @@ func ServiceBaseResolver(app app.Heureka, ctx context.Context, filter *model.Ser return &connection, nil } -func ServiceNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.ServiceFilter) (*model.FilterItem, error) { +func ServiceCcrnBaseResolver(app app.Heureka, ctx context.Context, filter *model.ServiceFilter) (*model.FilterItem, error) { requestedFields := GetPreloads(ctx) logrus.WithFields(logrus.Fields{ "requestedFields": requestedFields, - }).Debug("Called ServiceNameBaseResolver") + }).Debug("Called ServiceCcrnBaseResolver") if filter == nil { filter = &model.ServiceFilter{} @@ -156,17 +156,17 @@ func ServiceNameBaseResolver(app app.Heureka, ctx context.Context, filter *model f := &entity.ServiceFilter{ Paginated: entity.Paginated{}, - SupportGroupName: filter.SupportGroupName, - Name: filter.ServiceName, + SupportGroupCCRN: filter.SupportGroupCcrn, + CCRN: filter.ServiceCcrn, OwnerName: filter.UserName, } opt := GetListOptions(requestedFields) - names, err := app.ListServiceNames(f, opt) + names, err := app.ListServiceCcrns(f, opt) if err != nil { - return nil, NewResolverError("ServiceNameBaseResolver", err.Error()) + return nil, NewResolverError("ServiceCcrnBaseResolver", err.Error()) } var pointerNames []*string @@ -176,7 +176,7 @@ func ServiceNameBaseResolver(app app.Heureka, ctx context.Context, filter *model } filterItem := model.FilterItem{ - DisplayName: &FilterDisplayServiceName, + DisplayName: &FilterDisplayServiceCcrn, Values: pointerNames, } diff --git a/internal/api/graphql/graph/baseResolver/support_group.go b/internal/api/graphql/graph/baseResolver/support_group.go index 649271e6..8a174e67 100644 --- a/internal/api/graphql/graph/baseResolver/support_group.go +++ b/internal/api/graphql/graph/baseResolver/support_group.go @@ -52,7 +52,7 @@ func SupportGroupBaseResolver(app app.Heureka, ctx context.Context, filter *mode Paginated: entity.Paginated{First: first, After: afterId}, ServiceId: serviceId, UserId: userId, - Name: filter.SupportGroupName, + CCRN: filter.SupportGroupCcrn, } opt := GetListOptions(requestedFields) @@ -87,11 +87,11 @@ func SupportGroupBaseResolver(app app.Heureka, ctx context.Context, filter *mode return &connection, nil } -func SupportGroupNameBaseResolver(app app.Heureka, ctx context.Context, filter *model.SupportGroupFilter) (*model.FilterItem, error) { +func SupportGroupCcrnBaseResolver(app app.Heureka, ctx context.Context, filter *model.SupportGroupFilter) (*model.FilterItem, error) { requestedFields := GetPreloads(ctx) logrus.WithFields(logrus.Fields{ "requestedFields": requestedFields, - }).Debug("Called SupportGroupNameBaseResolver") + }).Debug("Called SupportGroupCcrnBaseResolver") var err error if filter == nil { @@ -103,23 +103,23 @@ func SupportGroupNameBaseResolver(app app.Heureka, ctx context.Context, filter * userIds, err = util.ConvertStrToIntSlice(filter.UserIds) if err != nil { - logrus.WithField("Filter", filter).Error("SupportGroupNameBaseResolver: Error while parsing 'UserIds'") - return nil, NewResolverError("SupportGroupNameBaseResolver", "Bad Request - unable to parse 'UserIds'") + logrus.WithField("Filter", filter).Error("SupportGroupCcrnBaseResolver: Error while parsing 'UserIds'") + return nil, NewResolverError("SupportGroupCcrnBaseResolver", "Bad Request - unable to parse 'UserIds'") } } f := &entity.SupportGroupFilter{ Paginated: entity.Paginated{}, UserId: userIds, - Name: filter.SupportGroupName, + CCRN: filter.SupportGroupCcrn, } opt := GetListOptions(requestedFields) - names, err := app.ListSupportGroupNames(f, opt) + names, err := app.ListSupportGroupCcrns(f, opt) if err != nil { - return nil, NewResolverError("SupportGroupNameBaseResolver", err.Error()) + return nil, NewResolverError("SupportGroupCcrnBaseResolver", err.Error()) } var pointerNames []*string @@ -129,7 +129,7 @@ func SupportGroupNameBaseResolver(app app.Heureka, ctx context.Context, filter * } filterItem := model.FilterItem{ - DisplayName: &FilterDisplaySupportGroupName, + DisplayName: &FilterDisplaySupportGroupCcrn, Values: pointerNames, } diff --git a/internal/api/graphql/graph/model/models.go b/internal/api/graphql/graph/model/models.go index bdac542a..4fe2052a 100644 --- a/internal/api/graphql/graph/model/models.go +++ b/internal/api/graphql/graph/model/models.go @@ -355,7 +355,7 @@ func NewUserEntity(user *UserInput) entity.User { func NewService(s *entity.Service) Service { return Service{ ID: fmt.Sprintf("%d", s.Id), - Name: &s.Name, + Ccrn: &s.CCRN, } } @@ -371,7 +371,7 @@ func NewServiceWithAggregations(service *entity.ServiceResult) Service { return Service{ ID: fmt.Sprintf("%d", service.Id), - Name: &service.Name, + Ccrn: &service.CCRN, Metadata: &metadata, } } @@ -379,7 +379,7 @@ func NewServiceWithAggregations(service *entity.ServiceResult) Service { func NewServiceEntity(service *ServiceInput) entity.Service { return entity.Service{ BaseService: entity.BaseService{ - Name: lo.FromPtr(service.Name), + CCRN: lo.FromPtr(service.Ccrn), }, } } @@ -387,13 +387,13 @@ func NewServiceEntity(service *ServiceInput) entity.Service { func NewSupportGroup(supportGroup *entity.SupportGroup) SupportGroup { return SupportGroup{ ID: fmt.Sprintf("%d", supportGroup.Id), - Name: &supportGroup.Name, + Ccrn: &supportGroup.CCRN, } } func NewSupportGroupEntity(supportGroup *SupportGroupInput) entity.SupportGroup { return entity.SupportGroup{ - Name: lo.FromPtr(supportGroup.Name), + CCRN: lo.FromPtr(supportGroup.Ccrn), } } @@ -452,7 +452,7 @@ func NewComponent(component *entity.Component) Component { componentType, _ := ComponentTypeValue(component.Type) return Component{ ID: fmt.Sprintf("%d", component.Id), - Name: &component.Name, + Ccrn: &component.CCRN, Type: &componentType, } } @@ -463,7 +463,7 @@ func NewComponentEntity(component *ComponentInput) entity.Component { componentType = component.Type.String() } return entity.Component{ - Name: lo.FromPtr(component.Name), + CCRN: lo.FromPtr(component.Ccrn), Type: componentType, } } diff --git a/internal/api/graphql/graph/queryCollection/activity/addService.graphql b/internal/api/graphql/graph/queryCollection/activity/addService.graphql index 09036fac..14935970 100644 --- a/internal/api/graphql/graph/queryCollection/activity/addService.graphql +++ b/internal/api/graphql/graph/queryCollection/activity/addService.graphql @@ -11,7 +11,7 @@ mutation ($activityId: ID!, $serviceId: ID!) { edges { node { id - name + ccrn } } } diff --git a/internal/api/graphql/graph/queryCollection/activity/directRelations.graphql b/internal/api/graphql/graph/queryCollection/activity/directRelations.graphql index 30bc155f..e40d7d3e 100644 --- a/internal/api/graphql/graph/queryCollection/activity/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/activity/directRelations.graphql @@ -17,7 +17,7 @@ query ($filter: ActivityFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/activity/full.graphql b/internal/api/graphql/graph/queryCollection/activity/full.graphql index 15bfff0d..09fbfe1f 100644 --- a/internal/api/graphql/graph/queryCollection/activity/full.graphql +++ b/internal/api/graphql/graph/queryCollection/activity/full.graphql @@ -17,7 +17,7 @@ query ($filter: ActivityFilter, $first: Int, $after: String) { edges { node { id - name + ccrn owners { totalCount edges { @@ -39,7 +39,7 @@ query ($filter: ActivityFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } @@ -177,7 +177,7 @@ query ($filter: ActivityFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/activity/removeService.graphql b/internal/api/graphql/graph/queryCollection/activity/removeService.graphql index c0fb433f..ceec6e29 100644 --- a/internal/api/graphql/graph/queryCollection/activity/removeService.graphql +++ b/internal/api/graphql/graph/queryCollection/activity/removeService.graphql @@ -11,7 +11,7 @@ mutation ($activityId: ID!, $serviceId: ID!) { edges { node { id - name + ccrn } } } diff --git a/internal/api/graphql/graph/queryCollection/component/create.graphql b/internal/api/graphql/graph/queryCollection/component/create.graphql index fb5e78c8..284dd32c 100644 --- a/internal/api/graphql/graph/queryCollection/component/create.graphql +++ b/internal/api/graphql/graph/queryCollection/component/create.graphql @@ -6,7 +6,7 @@ mutation ($input: ComponentInput!) { input: $input ) { id - name + ccrn type } } \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/component/directRelations.graphql b/internal/api/graphql/graph/queryCollection/component/directRelations.graphql index 752d6d08..8d3b77e1 100644 --- a/internal/api/graphql/graph/queryCollection/component/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/component/directRelations.graphql @@ -12,7 +12,7 @@ query ($filter: ComponentFilter, $first: Int, $after: String) { edges { node { id - name + ccrn type componentVersions { totalCount diff --git a/internal/api/graphql/graph/queryCollection/component/minimal.graphql b/internal/api/graphql/graph/queryCollection/component/minimal.graphql index f032a666..72005309 100644 --- a/internal/api/graphql/graph/queryCollection/component/minimal.graphql +++ b/internal/api/graphql/graph/queryCollection/component/minimal.graphql @@ -11,7 +11,7 @@ query ($filter: ComponentFilter, $first: Int, $after: String) { edges { node { id - name + ccrn type } cursor diff --git a/internal/api/graphql/graph/queryCollection/component/update.graphql b/internal/api/graphql/graph/queryCollection/component/update.graphql index 5f4fe1a6..89760928 100644 --- a/internal/api/graphql/graph/queryCollection/component/update.graphql +++ b/internal/api/graphql/graph/queryCollection/component/update.graphql @@ -8,6 +8,6 @@ mutation ($id: ID!, $input: ComponentInput!) { ) { __typename id - name + ccrn } } \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/componentFilter/componentName.graphqls b/internal/api/graphql/graph/queryCollection/componentFilter/componentCcrn.graphqls similarity index 86% rename from internal/api/graphql/graph/queryCollection/componentFilter/componentName.graphqls rename to internal/api/graphql/graph/queryCollection/componentFilter/componentCcrn.graphqls index 0ea1b53d..ae668c8e 100644 --- a/internal/api/graphql/graph/queryCollection/componentFilter/componentName.graphqls +++ b/internal/api/graphql/graph/queryCollection/componentFilter/componentCcrn.graphqls @@ -3,7 +3,7 @@ query($filter: ComponentFilter){ ComponentFilterValues{ - componentName(filter: $filter){ + componentCcrn(filter: $filter){ filterName values } diff --git a/internal/api/graphql/graph/queryCollection/componentInstance/directRelations.graphql b/internal/api/graphql/graph/queryCollection/componentInstance/directRelations.graphql index e7d97d74..1ef71306 100644 --- a/internal/api/graphql/graph/queryCollection/componentInstance/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/componentInstance/directRelations.graphql @@ -23,7 +23,7 @@ query ($filter: ComponentInstanceFilter, $first: Int, $after: String) { serviceId service { id - name + ccrn } createdAt updatedAt diff --git a/internal/api/graphql/graph/queryCollection/componentInstanceFilter/serviceName.graphqls b/internal/api/graphql/graph/queryCollection/componentInstanceFilter/serviceCcrn.graphqls similarity index 87% rename from internal/api/graphql/graph/queryCollection/componentInstanceFilter/serviceName.graphqls rename to internal/api/graphql/graph/queryCollection/componentInstanceFilter/serviceCcrn.graphqls index b87682f0..379a03a3 100644 --- a/internal/api/graphql/graph/queryCollection/componentInstanceFilter/serviceName.graphqls +++ b/internal/api/graphql/graph/queryCollection/componentInstanceFilter/serviceCcrn.graphqls @@ -3,7 +3,7 @@ query($filter: ServiceFilter){ ComponentInstanceFilterValues{ - serviceName(filter: $filter){ + serviceCcrn(filter: $filter){ filterName values } diff --git a/internal/api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupName.graphqls b/internal/api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupCcrn.graphqls similarity index 85% rename from internal/api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupName.graphqls rename to internal/api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupCcrn.graphqls index 1431489a..7cc8149f 100644 --- a/internal/api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupName.graphqls +++ b/internal/api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupCcrn.graphqls @@ -3,7 +3,7 @@ query($filter: SupportGroupFilter){ ComponentInstanceFilterValues{ - supportGroupName(filter: $filter){ + supportGroupCcrn(filter: $filter){ filterName values } diff --git a/internal/api/graphql/graph/queryCollection/componentVersion/directRelations.graphql b/internal/api/graphql/graph/queryCollection/componentVersion/directRelations.graphql index 9caeb6b1..654cf814 100644 --- a/internal/api/graphql/graph/queryCollection/componentVersion/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/componentVersion/directRelations.graphql @@ -16,7 +16,7 @@ query ($filter: ComponentVersionFilter, $first: Int, $after: String) { componentId component { id - name + ccrn type } issues { diff --git a/internal/api/graphql/graph/queryCollection/issue/full.graphql b/internal/api/graphql/graph/queryCollection/issue/full.graphql index 0fbfcda0..e826a032 100644 --- a/internal/api/graphql/graph/queryCollection/issue/full.graphql +++ b/internal/api/graphql/graph/queryCollection/issue/full.graphql @@ -95,13 +95,13 @@ query ($filter: IssueFilter, $first: Int, $after: String) { version component { id - name + ccrn type } } service { id - name + ccrn owners { totalCount edges { @@ -123,7 +123,7 @@ query ($filter: IssueFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql b/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql index 259d50d3..db574c98 100644 --- a/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/issueRepository/directRelations.graphql @@ -40,7 +40,7 @@ query ($filter: IssueRepositoryFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor priority diff --git a/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql b/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql index 86d82b10..2ee588c1 100644 --- a/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql +++ b/internal/api/graphql/graph/queryCollection/service/addIssueRepository.graphql @@ -8,7 +8,7 @@ mutation ($serviceId: ID!, $issueRepositoryId: ID!, $priority: Int!) { priority: $priority ) { id - name + ccrn issueRepositories { edges { node { diff --git a/internal/api/graphql/graph/queryCollection/service/addOwner.graphql b/internal/api/graphql/graph/queryCollection/service/addOwner.graphql index 91cc9485..53de2489 100644 --- a/internal/api/graphql/graph/queryCollection/service/addOwner.graphql +++ b/internal/api/graphql/graph/queryCollection/service/addOwner.graphql @@ -7,7 +7,7 @@ mutation ($serviceId: ID!, $userId: ID!) { userId: $userId ) { id - name + ccrn owners { edges { node { diff --git a/internal/api/graphql/graph/queryCollection/service/create.graphql b/internal/api/graphql/graph/queryCollection/service/create.graphql index 26c1de2c..48513564 100644 --- a/internal/api/graphql/graph/queryCollection/service/create.graphql +++ b/internal/api/graphql/graph/queryCollection/service/create.graphql @@ -6,6 +6,6 @@ mutation ($input: ServiceInput!) { input: $input ) { id - name + ccrn } } \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/service/directRelations.graphql b/internal/api/graphql/graph/queryCollection/service/directRelations.graphql index 16e131dc..3b1f6b75 100644 --- a/internal/api/graphql/graph/queryCollection/service/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/service/directRelations.graphql @@ -12,7 +12,7 @@ query ($filter: ServiceFilter, $first: Int, $after: String) { edges { node { id - name + ccrn owners { totalCount edges { @@ -34,7 +34,7 @@ query ($filter: ServiceFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/service/minimal.graphql b/internal/api/graphql/graph/queryCollection/service/minimal.graphql index 206015f5..393c1287 100644 --- a/internal/api/graphql/graph/queryCollection/service/minimal.graphql +++ b/internal/api/graphql/graph/queryCollection/service/minimal.graphql @@ -11,7 +11,7 @@ query ($filter: ServiceFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql b/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql index a9da692c..437ec5d3 100644 --- a/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql +++ b/internal/api/graphql/graph/queryCollection/service/removeIssueRepository.graphql @@ -7,7 +7,7 @@ mutation ($serviceId: ID!, $issueRepositoryId: ID!) { issueRepositoryId: $issueRepositoryId ) { id - name + ccrn issueRepositories { edges { node { diff --git a/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql b/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql index 484950ca..33444759 100644 --- a/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql +++ b/internal/api/graphql/graph/queryCollection/service/removeOwner.graphql @@ -7,7 +7,7 @@ mutation ($serviceId: ID!, $userId: ID!) { userId: $userId ) { id - name + ccrn owners{ edges { node { diff --git a/internal/api/graphql/graph/queryCollection/service/update.graphql b/internal/api/graphql/graph/queryCollection/service/update.graphql index 24b398f5..4317a5fb 100644 --- a/internal/api/graphql/graph/queryCollection/service/update.graphql +++ b/internal/api/graphql/graph/queryCollection/service/update.graphql @@ -8,6 +8,6 @@ mutation ($id: ID!, $input: ServiceInput!) { ) { __typename id - name + ccrn } } \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/service/withMetadata.graphql b/internal/api/graphql/graph/queryCollection/service/withMetadata.graphql index 8b0c471a..ae54a716 100644 --- a/internal/api/graphql/graph/queryCollection/service/withMetadata.graphql +++ b/internal/api/graphql/graph/queryCollection/service/withMetadata.graphql @@ -11,7 +11,7 @@ query ($filter: ServiceFilter, $first: Int, $after: String) { edges { node { id - name + ccrn componentInstances { edges { node { diff --git a/internal/api/graphql/graph/queryCollection/serviceFilter/serviceNames.graphql b/internal/api/graphql/graph/queryCollection/serviceFilter/serviceCcrns.graphql similarity index 86% rename from internal/api/graphql/graph/queryCollection/serviceFilter/serviceNames.graphql rename to internal/api/graphql/graph/queryCollection/serviceFilter/serviceCcrns.graphql index 01c8f5dc..a68ed926 100644 --- a/internal/api/graphql/graph/queryCollection/serviceFilter/serviceNames.graphql +++ b/internal/api/graphql/graph/queryCollection/serviceFilter/serviceCcrns.graphql @@ -3,7 +3,7 @@ query($filter: ServiceFilter){ ServiceFilterValues{ - serviceName(filter: $filter){ + serviceCcrn(filter: $filter){ filterName values } diff --git a/internal/api/graphql/graph/queryCollection/serviceFilter/supportGroupNames.graphql b/internal/api/graphql/graph/queryCollection/serviceFilter/supportGroupCcrns.graphql similarity index 85% rename from internal/api/graphql/graph/queryCollection/serviceFilter/supportGroupNames.graphql rename to internal/api/graphql/graph/queryCollection/serviceFilter/supportGroupCcrns.graphql index 4f4d8de8..02b4eaea 100644 --- a/internal/api/graphql/graph/queryCollection/serviceFilter/supportGroupNames.graphql +++ b/internal/api/graphql/graph/queryCollection/serviceFilter/supportGroupCcrns.graphql @@ -3,7 +3,7 @@ query($filter: SupportGroupFilter){ ServiceFilterValues{ - supportGroupName(filter: $filter){ + supportGroupCcrn(filter: $filter){ filterName values } diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql index a305a241..794cb1d4 100644 --- a/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql +++ b/internal/api/graphql/graph/queryCollection/supportGroup/addService.graphql @@ -7,12 +7,12 @@ mutation ($supportGroupId: ID!, $serviceId: ID!) { serviceId: $serviceId ) { id - name + ccrn services { edges { node { id - name + ccrn } } } diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/create.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/create.graphql index 0e21fc52..ab290847 100644 --- a/internal/api/graphql/graph/queryCollection/supportGroup/create.graphql +++ b/internal/api/graphql/graph/queryCollection/supportGroup/create.graphql @@ -6,6 +6,6 @@ mutation ($input: SupportGroupInput!) { input: $input ) { id - name + ccrn } } \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/directRelations.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/directRelations.graphql index b18731ad..f3a864bc 100644 --- a/internal/api/graphql/graph/queryCollection/supportGroup/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/supportGroup/directRelations.graphql @@ -12,7 +12,7 @@ query ($filter: SupportGroupFilter, $first: Int, $after: String) { edges { node { id - name + ccrn users { totalCount edges { @@ -34,7 +34,7 @@ query ($filter: SupportGroupFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/minimal.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/minimal.graphql index 69007eb9..e5336159 100644 --- a/internal/api/graphql/graph/queryCollection/supportGroup/minimal.graphql +++ b/internal/api/graphql/graph/queryCollection/supportGroup/minimal.graphql @@ -11,7 +11,7 @@ query ($filter: SupportGroupFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql index fcdca46a..f140d9a8 100644 --- a/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql +++ b/internal/api/graphql/graph/queryCollection/supportGroup/removeService.graphql @@ -7,12 +7,12 @@ mutation ($supportGroupId: ID!, $serviceId: ID!) { supportGroupId: $supportGroupId ) { id - name + ccrn services { edges { node { id - name + ccrn } } } diff --git a/internal/api/graphql/graph/queryCollection/supportGroup/update.graphql b/internal/api/graphql/graph/queryCollection/supportGroup/update.graphql index c485518d..2f16be81 100644 --- a/internal/api/graphql/graph/queryCollection/supportGroup/update.graphql +++ b/internal/api/graphql/graph/queryCollection/supportGroup/update.graphql @@ -8,6 +8,6 @@ mutation ($id: ID!, $input: SupportGroupInput!) { ) { __typename id - name + ccrn } } \ No newline at end of file diff --git a/internal/api/graphql/graph/queryCollection/user/directRelations.graphql b/internal/api/graphql/graph/queryCollection/user/directRelations.graphql index 745da0ba..60d743a0 100644 --- a/internal/api/graphql/graph/queryCollection/user/directRelations.graphql +++ b/internal/api/graphql/graph/queryCollection/user/directRelations.graphql @@ -20,7 +20,7 @@ query ($filter: UserFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } @@ -34,7 +34,7 @@ query ($filter: UserFilter, $first: Int, $after: String) { edges { node { id - name + ccrn } cursor } diff --git a/internal/api/graphql/graph/resolver/component_filter.go b/internal/api/graphql/graph/resolver/component_filter.go index 94e1c557..873d373e 100644 --- a/internal/api/graphql/graph/resolver/component_filter.go +++ b/internal/api/graphql/graph/resolver/component_filter.go @@ -18,12 +18,13 @@ import ( // SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors // SPDX-License-Identifier: Apache-2.0 -func (r *componentFilterValueResolver) ComponentName(ctx context.Context, obj *model.ComponentFilterValue, filter *model.ComponentFilter) (*model.FilterItem, error) { - item, err := baseResolver.ComponentNameBaseResolver(r.App, ctx, filter) +func (r *componentFilterValueResolver) ComponentCcrn(ctx context.Context, obj *model.ComponentFilterValue, filter *model.ComponentFilter) (*model.FilterItem, error) { + item, err := baseResolver.ComponentCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.ComponentFilterComponentName + item.FilterName = &baseResolver.ComponentFilterComponentCcrn return item, err } diff --git a/internal/api/graphql/graph/resolver/component_instance_filter.go b/internal/api/graphql/graph/resolver/component_instance_filter.go index afacd063..f22894f6 100644 --- a/internal/api/graphql/graph/resolver/component_instance_filter.go +++ b/internal/api/graphql/graph/resolver/component_instance_filter.go @@ -18,21 +18,23 @@ import ( // SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors // SPDX-License-Identifier: Apache-2.0 -func (r *componentInstanceFilterValueResolver) ServiceName(ctx context.Context, obj *model.ComponentInstanceFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { - item, err := baseResolver.ServiceNameBaseResolver(r.App, ctx, filter) +func (r *componentInstanceFilterValueResolver) ServiceCcrn(ctx context.Context, obj *model.ComponentInstanceFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { + item, err := baseResolver.ServiceCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.ServiceFilterServiceName + item.FilterName = &baseResolver.ServiceFilterServiceCcrn return item, err } -func (r *componentInstanceFilterValueResolver) SupportGroupName(ctx context.Context, obj *model.ComponentInstanceFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { - item, err := baseResolver.SupportGroupNameBaseResolver(r.App, ctx, filter) +func (r *componentInstanceFilterValueResolver) SupportGroupCcrn(ctx context.Context, obj *model.ComponentInstanceFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { + item, err := baseResolver.SupportGroupCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.ServiceFilterSupportGroupName + item.FilterName = &baseResolver.ServiceFilterSupportGroupCcrn return item, err } diff --git a/internal/api/graphql/graph/resolver/issue_match_filter_value.go b/internal/api/graphql/graph/resolver/issue_match_filter_value.go index 9d948ebf..e688126d 100644 --- a/internal/api/graphql/graph/resolver/issue_match_filter_value.go +++ b/internal/api/graphql/graph/resolver/issue_match_filter_value.go @@ -28,7 +28,7 @@ func (r *issueMatchFilterValueResolver) PrimaryName(ctx context.Context, obj *mo } func (r *issueMatchFilterValueResolver) AffectedService(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { - item, err := baseResolver.ServiceNameBaseResolver(r.App, ctx, filter) + item, err := baseResolver.ServiceCcrnBaseResolver(r.App, ctx, filter) if err != nil { return nil, err } @@ -36,21 +36,23 @@ func (r *issueMatchFilterValueResolver) AffectedService(ctx context.Context, obj return item, nil } -func (r *issueMatchFilterValueResolver) ComponentName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ComponentFilter) (*model.FilterItem, error) { - item, err := baseResolver.ComponentNameBaseResolver(r.App, ctx, filter) +func (r *issueMatchFilterValueResolver) ComponentCcrn(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.ComponentFilter) (*model.FilterItem, error) { + item, err := baseResolver.ComponentCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.IssueMatchFilterComponentName + item.FilterName = &baseResolver.IssueMatchFilterComponentCcrn return item, nil } -func (r *issueMatchFilterValueResolver) SupportGroupName(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { - item, err := baseResolver.SupportGroupNameBaseResolver(r.App, ctx, filter) +func (r *issueMatchFilterValueResolver) SupportGroupCcrn(ctx context.Context, obj *model.IssueMatchFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { + item, err := baseResolver.SupportGroupCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.IssueMatchFilterSupportGroupName + item.FilterName = &baseResolver.IssueMatchFilterSupportGroupCcrn return item, nil } diff --git a/internal/api/graphql/graph/resolver/service_filter.go b/internal/api/graphql/graph/resolver/service_filter.go index 29f8fa55..1987bc8a 100644 --- a/internal/api/graphql/graph/resolver/service_filter.go +++ b/internal/api/graphql/graph/resolver/service_filter.go @@ -18,12 +18,13 @@ import ( // SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors // SPDX-License-Identifier: Apache-2.0 -func (r *serviceFilterValueResolver) ServiceName(ctx context.Context, obj *model.ServiceFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { - item, err := baseResolver.ServiceNameBaseResolver(r.App, ctx, filter) +func (r *serviceFilterValueResolver) ServiceCcrn(ctx context.Context, obj *model.ServiceFilterValue, filter *model.ServiceFilter) (*model.FilterItem, error) { + item, err := baseResolver.ServiceCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.ServiceFilterServiceName + item.FilterName = &baseResolver.ServiceFilterServiceCcrn return item, err } @@ -45,12 +46,13 @@ func (r *serviceFilterValueResolver) UserName(ctx context.Context, obj *model.Se return item, err } -func (r *serviceFilterValueResolver) SupportGroupName(ctx context.Context, obj *model.ServiceFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { - item, err := baseResolver.SupportGroupNameBaseResolver(r.App, ctx, filter) +func (r *serviceFilterValueResolver) SupportGroupCcrn(ctx context.Context, obj *model.ServiceFilterValue, filter *model.SupportGroupFilter) (*model.FilterItem, error) { + item, err := baseResolver.SupportGroupCcrnBaseResolver(r.App, ctx, filter) + if err != nil { return nil, err } - item.FilterName = &baseResolver.ServiceFilterSupportGroupName + item.FilterName = &baseResolver.ServiceFilterSupportGroupCcrn return item, err } diff --git a/internal/api/graphql/graph/schema/activity.graphqls b/internal/api/graphql/graph/schema/activity.graphqls index b7ccc630..0b4dd782 100644 --- a/internal/api/graphql/graph/schema/activity.graphqls +++ b/internal/api/graphql/graph/schema/activity.graphqls @@ -26,7 +26,7 @@ type ActivityEdge implements Edge { } input ActivityFilter { - serviceName: [String] + serviceCcrn: [String] status: [ActivityStatusValues] } diff --git a/internal/api/graphql/graph/schema/component.graphqls b/internal/api/graphql/graph/schema/component.graphqls index e2805fd1..025601e1 100644 --- a/internal/api/graphql/graph/schema/component.graphqls +++ b/internal/api/graphql/graph/schema/component.graphqls @@ -3,13 +3,13 @@ type Component implements Node { id: ID! - name: String + ccrn: String type: ComponentTypeValues componentVersions(filter: ComponentVersionFilter, first: Int, after: String): ComponentVersionConnection } input ComponentInput { - name: String + ccrn: String type: ComponentTypeValues } @@ -20,7 +20,7 @@ enum ComponentTypeValues { } input ComponentFilter { - componentName: [String] + componentCcrn: [String] } type ComponentConnection implements Connection { diff --git a/internal/api/graphql/graph/schema/component_filter.graphqls b/internal/api/graphql/graph/schema/component_filter.graphqls index 4aaedf3b..be9ea969 100644 --- a/internal/api/graphql/graph/schema/component_filter.graphqls +++ b/internal/api/graphql/graph/schema/component_filter.graphqls @@ -2,5 +2,5 @@ # SPDX-License-Identifier: Apache-2.0 type ComponentFilterValue { - componentName(filter: ComponentFilter): FilterItem + componentCcrn(filter: ComponentFilter): FilterItem } diff --git a/internal/api/graphql/graph/schema/component_instance.graphqls b/internal/api/graphql/graph/schema/component_instance.graphqls index 0e590820..66d25d28 100644 --- a/internal/api/graphql/graph/schema/component_instance.graphqls +++ b/internal/api/graphql/graph/schema/component_instance.graphqls @@ -33,7 +33,7 @@ type ComponentInstanceEdge implements Edge { } input ComponentInstanceFilter { - serviceName: [String], + serviceCcrn: [String], ccrn: [String], supportGroup: [String], search:[String], diff --git a/internal/api/graphql/graph/schema/component_instance_filter.graphqls b/internal/api/graphql/graph/schema/component_instance_filter.graphqls index b774475e..8b290bce 100644 --- a/internal/api/graphql/graph/schema/component_instance_filter.graphqls +++ b/internal/api/graphql/graph/schema/component_instance_filter.graphqls @@ -2,7 +2,7 @@ # SPDX-License-Identifier: Apache-2.0 type ComponentInstanceFilterValue { - serviceName(filter: ServiceFilter): FilterItem - supportGroupName(filter: SupportGroupFilter): FilterItem + serviceCcrn(filter: ServiceFilter): FilterItem + supportGroupCcrn(filter: SupportGroupFilter): FilterItem ccrn(filter: ComponentInstanceFilter): FilterItem } \ No newline at end of file diff --git a/internal/api/graphql/graph/schema/component_version.graphqls b/internal/api/graphql/graph/schema/component_version.graphqls index 0c556654..597292a5 100644 --- a/internal/api/graphql/graph/schema/component_version.graphqls +++ b/internal/api/graphql/graph/schema/component_version.graphqls @@ -28,7 +28,7 @@ type ComponentVersionEdge implements Edge { input ComponentVersionFilter { componentId: [String] - componentName: [String] + componentCcrn: [String] issueId: [String] version: [String] } \ No newline at end of file diff --git a/internal/api/graphql/graph/schema/issue_match.graphqls b/internal/api/graphql/graph/schema/issue_match.graphqls index 479a82f8..5ca68780 100644 --- a/internal/api/graphql/graph/schema/issue_match.graphqls +++ b/internal/api/graphql/graph/schema/issue_match.graphqls @@ -33,12 +33,12 @@ input IssueMatchFilter { id: [String] search: [String] primaryName: [String] - componentName: [String] + componentCcrn: [String] issueType: [IssueTypes] status: [IssueMatchStatusValues] severity: [SeverityValues] affectedService: [String] - supportGroupName: [String] + supportGroupCcrn: [String] } #type CCloudSeverity { diff --git a/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls b/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls index 5387d840..b44a0589 100644 --- a/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls +++ b/internal/api/graphql/graph/schema/issue_match_filter_value.graphqls @@ -7,6 +7,6 @@ type IssueMatchFilterValue { issueType: FilterItem primaryName(filter: IssueFilter): FilterItem affectedService(filter: ServiceFilter): FilterItem - componentName(filter: ComponentFilter): FilterItem - supportGroupName(filter: SupportGroupFilter): FilterItem + componentCcrn(filter: ComponentFilter): FilterItem + supportGroupCcrn(filter: SupportGroupFilter): FilterItem } \ No newline at end of file diff --git a/internal/api/graphql/graph/schema/issue_repository.graphqls b/internal/api/graphql/graph/schema/issue_repository.graphqls index a85967a7..f34eef63 100644 --- a/internal/api/graphql/graph/schema/issue_repository.graphqls +++ b/internal/api/graphql/graph/schema/issue_repository.graphqls @@ -31,7 +31,7 @@ type IssueRepositoryEdge implements Edge { } input IssueRepositoryFilter { - serviceName: [String] + serviceCcrn: [String] serviceId: [String] name: [String] } \ No newline at end of file diff --git a/internal/api/graphql/graph/schema/service.graphqls b/internal/api/graphql/graph/schema/service.graphqls index 7cf7d38f..219596da 100644 --- a/internal/api/graphql/graph/schema/service.graphqls +++ b/internal/api/graphql/graph/schema/service.graphqls @@ -3,7 +3,7 @@ type Service implements Node { id: ID! - name: String + ccrn: String owners(filter: UserFilter, first: Int, after: String): UserConnection supportGroups(filter: SupportGroupFilter, first: Int, after: String): SupportGroupConnection activities(filter: ActivityFilter, first: Int, after: String): ActivityConnection @@ -18,7 +18,7 @@ type ServiceMetadata { } input ServiceInput { - name: String + ccrn: String } type ServiceConnection implements Connection { @@ -34,10 +34,10 @@ type ServiceEdge implements Edge { } input ServiceFilter { - serviceName: [String] + serviceCcrn: [String] uniqueUserId: [String] type: [Int] userName: [String] - supportGroupName: [String] + supportGroupCcrn: [String] search: [String] } diff --git a/internal/api/graphql/graph/schema/service_filter.graphqls b/internal/api/graphql/graph/schema/service_filter.graphqls index 79fbdea5..6cbf8de4 100644 --- a/internal/api/graphql/graph/schema/service_filter.graphqls +++ b/internal/api/graphql/graph/schema/service_filter.graphqls @@ -2,10 +2,10 @@ # SPDX-License-Identifier: Apache-2.0 type ServiceFilterValue { - serviceName(filter: ServiceFilter): FilterItem + serviceCcrn(filter: ServiceFilter): FilterItem uniqueUserId(filter: UserFilter): FilterItem userName(filter: UserFilter): FilterItem - supportGroupName(filter: SupportGroupFilter): FilterItem + supportGroupCcrn(filter: SupportGroupFilter): FilterItem } diff --git a/internal/api/graphql/graph/schema/support_group.graphqls b/internal/api/graphql/graph/schema/support_group.graphqls index 9f1df03d..90060247 100644 --- a/internal/api/graphql/graph/schema/support_group.graphqls +++ b/internal/api/graphql/graph/schema/support_group.graphqls @@ -3,13 +3,13 @@ type SupportGroup implements Node { id: ID! - name: String + ccrn: String users(filter: UserFilter, first: Int, after: String): UserConnection services(filter: ServiceFilter, first: Int, after: String): ServiceConnection } input SupportGroupInput { - name: String + ccrn: String } type SupportGroupConnection implements Connection { @@ -24,6 +24,6 @@ type SupportGroupEdge implements Edge { } input SupportGroupFilter { - supportGroupName: [String], + supportGroupCcrn: [String], userIds: [String], } \ No newline at end of file diff --git a/internal/app/component/component_handler.go b/internal/app/component/component_handler.go index 2da923fd..6afae4e8 100644 --- a/internal/app/component/component_handler.go +++ b/internal/app/component/component_handler.go @@ -106,7 +106,7 @@ func (cs *componentHandler) ListComponents(filter *entity.ComponentFilter, optio func (cs *componentHandler) CreateComponent(component *entity.Component) (*entity.Component, error) { f := &entity.ComponentFilter{ - Name: []*string{&component.Name}, + CCRN: []*string{&component.CCRN}, } l := logrus.WithFields(logrus.Fields{ @@ -123,7 +123,7 @@ func (cs *componentHandler) CreateComponent(component *entity.Component) (*entit } if len(components.Elements) > 0 { - return nil, NewUserHandlerError(fmt.Sprintf("Duplicated entry %s for name.", component.Name)) + return nil, NewUserHandlerError(fmt.Sprintf("Duplicated entry %s for ccrn.", component.CCRN)) } newComponent, err := cs.database.CreateComponent(component) @@ -186,20 +186,20 @@ func (cs *componentHandler) DeleteComponent(id int64) error { return nil } -func (cs *componentHandler) ListComponentNames(filter *entity.ComponentFilter, options *entity.ListOptions) ([]string, error) { +func (cs *componentHandler) ListComponentCcrns(filter *entity.ComponentFilter, options *entity.ListOptions) ([]string, error) { l := logrus.WithFields(logrus.Fields{ - "event": ListComponentNamesEventName, + "event": ListComponentCcrnsEventName, "filter": filter, }) - componentNames, err := cs.database.GetComponentNames(filter) + componentCcrns, err := cs.database.GetComponentCcrns(filter) if err != nil { l.Error(err) - return nil, NewUserHandlerError("Internal error while retrieving componentNames.") + return nil, NewUserHandlerError("Internal error while retrieving componentCcrns.") } - cs.eventRegistry.PushEvent(&ListComponentNamesEvent{Filter: filter, Options: options, Names: componentNames}) + cs.eventRegistry.PushEvent(&ListComponentCcrnsEvent{Filter: filter, Options: options, CCRNs: componentCcrns}) - return componentNames, nil + return componentCcrns, nil } diff --git a/internal/app/component/component_handler_events.go b/internal/app/component/component_handler_events.go index 91c6bef0..1a155577 100644 --- a/internal/app/component/component_handler_events.go +++ b/internal/app/component/component_handler_events.go @@ -13,7 +13,7 @@ const ( CreateComponentEventName event.EventName = "CreateComponent" UpdateComponentEventName event.EventName = "UpdateComponent" DeleteComponentEventName event.EventName = "DeleteComponent" - ListComponentNamesEventName event.EventName = "ListComponentNames" + ListComponentCcrnsEventName event.EventName = "ListComponentCcrns" ) type ListComponentsEvent struct { @@ -50,12 +50,12 @@ func (e *DeleteComponentEvent) Name() event.EventName { return DeleteComponentEventName } -type ListComponentNamesEvent struct { +type ListComponentCcrnsEvent struct { Filter *entity.ComponentFilter Options *entity.ListOptions - Names []string + CCRNs []string } -func (e *ListComponentNamesEvent) Name() event.EventName { - return ListComponentNamesEventName +func (e *ListComponentCcrnsEvent) Name() event.EventName { + return ListComponentCcrnsEventName } diff --git a/internal/app/component/component_handler_interface.go b/internal/app/component/component_handler_interface.go index 1c7d453b..0fdcf772 100644 --- a/internal/app/component/component_handler_interface.go +++ b/internal/app/component/component_handler_interface.go @@ -10,5 +10,5 @@ type ComponentHandler interface { CreateComponent(*entity.Component) (*entity.Component, error) UpdateComponent(*entity.Component) (*entity.Component, error) DeleteComponent(int64) error - ListComponentNames(*entity.ComponentFilter, *entity.ListOptions) ([]string, error) + ListComponentCcrns(*entity.ComponentFilter, *entity.ListOptions) ([]string, error) } diff --git a/internal/app/component/component_handler_test.go b/internal/app/component/component_handler_test.go index 2be75328..335337d1 100644 --- a/internal/app/component/component_handler_test.go +++ b/internal/app/component/component_handler_test.go @@ -31,13 +31,13 @@ var _ = BeforeSuite(func() { }) func getComponentFilter() *entity.ComponentFilter { - cName := "SomeNotExistingComponent" + cCCRN := "SomeNotExistingComponent" return &entity.ComponentFilter{ Paginated: entity.Paginated{ First: nil, After: nil, }, - Name: []*string{&cName}, + CCRN: []*string{&cCCRN}, } } @@ -124,7 +124,7 @@ var _ = Describe("When creating Component", Label("app", "CreateComponent"), fun }) It("creates component", func() { - filter.Name = []*string{&component.Name} + filter.CCRN = []*string{&component.CCRN} db.On("CreateComponent", &component).Return(&component, nil) db.On("GetComponents", filter).Return([]entity.Component{}, nil) componentHandler = c.NewComponentHandler(db, er) @@ -132,7 +132,7 @@ var _ = Describe("When creating Component", Label("app", "CreateComponent"), fun Expect(err).To(BeNil(), "no error should be thrown") Expect(newComponent.Id).NotTo(BeEquivalentTo(0)) By("setting fields", func() { - Expect(newComponent.Name).To(BeEquivalentTo(component.Name)) + Expect(newComponent.CCRN).To(BeEquivalentTo(component.CCRN)) Expect(newComponent.Type).To(BeEquivalentTo(component.Type)) }) }) @@ -163,13 +163,13 @@ var _ = Describe("When updating Component", Label("app", "UpdateComponent"), fun It("updates component", func() { db.On("UpdateComponent", &component).Return(nil) componentHandler = c.NewComponentHandler(db, er) - component.Name = "NewComponent" + component.CCRN = "NewComponent" filter.Id = []*int64{&component.Id} db.On("GetComponents", filter).Return([]entity.Component{component}, nil) updatedComponent, err := componentHandler.UpdateComponent(&component) Expect(err).To(BeNil(), "no error should be thrown") By("setting fields", func() { - Expect(updatedComponent.Name).To(BeEquivalentTo(component.Name)) + Expect(updatedComponent.CCRN).To(BeEquivalentTo(component.CCRN)) Expect(updatedComponent.Type).To(BeEquivalentTo(component.Type)) }) }) diff --git a/internal/app/issue/issue_handler_test.go b/internal/app/issue/issue_handler_test.go index d91b0b36..3ea773da 100644 --- a/internal/app/issue/issue_handler_test.go +++ b/internal/app/issue/issue_handler_test.go @@ -31,13 +31,13 @@ var _ = BeforeSuite(func() { }) func getIssueFilter() *entity.IssueFilter { - serviceName := "SomeNotExistingService" + serviceCcrn := "SomeNotExistingService" return &entity.IssueFilter{ Paginated: entity.Paginated{ First: nil, After: nil, }, - ServiceName: []*string{&serviceName}, + ServiceCCRN: []*string{&serviceCcrn}, Id: nil, IssueMatchStatus: nil, IssueMatchDiscoveryDate: nil, diff --git a/internal/app/issue_match/issue_match_handler_test.go b/internal/app/issue_match/issue_match_handler_test.go index 79876ec6..9f10e321 100644 --- a/internal/app/issue_match/issue_match_handler_test.go +++ b/internal/app/issue_match/issue_match_handler_test.go @@ -44,7 +44,7 @@ func getIssueMatchFilter() *entity.IssueMatchFilter { After: nil, }, Id: nil, - AffectedServiceName: nil, + AffectedServiceCCRN: nil, SeverityValue: nil, Status: nil, IssueId: nil, diff --git a/internal/app/issue_repository/issue_repository_handler_test.go b/internal/app/issue_repository/issue_repository_handler_test.go index 4dff1a5d..2a22fb57 100644 --- a/internal/app/issue_repository/issue_repository_handler_test.go +++ b/internal/app/issue_repository/issue_repository_handler_test.go @@ -39,7 +39,7 @@ func getIssueRepositoryFilter() *entity.IssueRepositoryFilter { Name: nil, Id: nil, ServiceId: nil, - ServiceName: []*string{&sName}, + ServiceCCRN: []*string{&sName}, } } diff --git a/internal/app/issue_variant/issue_variant_handler_test.go b/internal/app/issue_variant/issue_variant_handler_test.go index 60715a6a..8c2b620a 100644 --- a/internal/app/issue_variant/issue_variant_handler_test.go +++ b/internal/app/issue_variant/issue_variant_handler_test.go @@ -53,7 +53,7 @@ func issueRepositoryFilter() *entity.IssueRepositoryFilter { Id: nil, ServiceId: nil, Name: nil, - ServiceName: nil, + ServiceCCRN: nil, } } diff --git a/internal/app/service/service_handler.go b/internal/app/service/service_handler.go index 55374648..8429cbf1 100644 --- a/internal/app/service/service_handler.go +++ b/internal/app/service/service_handler.go @@ -155,7 +155,7 @@ func (s *serviceHandler) ListServices(filter *entity.ServiceFilter, options *ent func (s *serviceHandler) CreateService(service *entity.Service) (*entity.Service, error) { f := &entity.ServiceFilter{ - Name: []*string{&service.Name}, + CCRN: []*string{&service.CCRN}, } l := logrus.WithFields(logrus.Fields{ @@ -172,7 +172,7 @@ func (s *serviceHandler) CreateService(service *entity.Service) (*entity.Service } if len(services.Elements) > 0 { - return nil, NewServiceHandlerError(fmt.Sprintf("Duplicated entry %s for name.", service.Name)) + return nil, NewServiceHandlerError(fmt.Sprintf("Duplicated entry %s for name.", service.CCRN)) } newService, err := s.database.CreateService(service) @@ -299,20 +299,20 @@ func (s *serviceHandler) RemoveIssueRepositoryFromService(serviceId, issueReposi return s.GetService(serviceId) } -func (s *serviceHandler) ListServiceNames(filter *entity.ServiceFilter, options *entity.ListOptions) ([]string, error) { +func (s *serviceHandler) ListServiceCcrns(filter *entity.ServiceFilter, options *entity.ListOptions) ([]string, error) { l := logrus.WithFields(logrus.Fields{ - "event": ListServiceNamesEventName, + "event": ListServiceCcrnsEventName, "filter": filter, }) - serviceNames, err := s.database.GetServiceNames(filter) + serviceCcrns, err := s.database.GetServiceCcrns(filter) if err != nil { l.Error(err) - return nil, NewServiceHandlerError("Internal error while retrieving serviceNames.") + return nil, NewServiceHandlerError("Internal error while retrieving serviceCCRNs.") } - s.eventRegistry.PushEvent(&ListServiceNamesEvent{Filter: filter, Options: options, Names: serviceNames}) + s.eventRegistry.PushEvent(&ListServiceCcrnsEvent{Filter: filter, Options: options, Ccrns: serviceCcrns}) - return serviceNames, nil + return serviceCcrns, nil } diff --git a/internal/app/service/service_handler_events.go b/internal/app/service/service_handler_events.go index 8d213552..d5789a93 100644 --- a/internal/app/service/service_handler_events.go +++ b/internal/app/service/service_handler_events.go @@ -18,7 +18,7 @@ const ( RemoveOwnerFromServiceEventName event.EventName = "RemoveOwnerFromService" ListServicesEventName event.EventName = "ListServices" GetServiceEventName event.EventName = "GetService" - ListServiceNamesEventName event.EventName = "ListServiceNames" + ListServiceCcrnsEventName event.EventName = "ListServiceCcrns" AddIssueRepositoryToServiceEventName event.EventName = "AddIssueRepositoryToService" RemoveIssueRepositoryFromServiceEventName event.EventName = "RemoveIssueRepositoryFromService" ) @@ -84,14 +84,14 @@ func (e *GetServiceEvent) Name() event.EventName { return GetServiceEventName } -type ListServiceNamesEvent struct { +type ListServiceCcrnsEvent struct { Filter *entity.ServiceFilter Options *entity.ListOptions - Names []string + Ccrns []string } -func (e *ListServiceNamesEvent) Name() event.EventName { - return ListServiceNamesEventName +func (e *ListServiceCcrnsEvent) Name() event.EventName { + return ListServiceCcrnsEventName } type AddIssueRepositoryToServiceEvent struct { diff --git a/internal/app/service/service_handler_interface.go b/internal/app/service/service_handler_interface.go index 569b6131..42378c9c 100644 --- a/internal/app/service/service_handler_interface.go +++ b/internal/app/service/service_handler_interface.go @@ -13,7 +13,7 @@ type ServiceHandler interface { DeleteService(id int64) error AddOwnerToService(serviceId, ownerId int64) (*entity.Service, error) RemoveOwnerFromService(serviceId, ownerId int64) (*entity.Service, error) - ListServiceNames(filter *entity.ServiceFilter, options *entity.ListOptions) ([]string, error) + ListServiceCcrns(filter *entity.ServiceFilter, options *entity.ListOptions) ([]string, error) AddIssueRepositoryToService(int64, int64, int64) (*entity.Service, error) RemoveIssueRepositoryFromService(int64, int64) (*entity.Service, error) } diff --git a/internal/app/service/service_handler_test.go b/internal/app/service/service_handler_test.go index ef75f4cb..a3690bca 100644 --- a/internal/app/service/service_handler_test.go +++ b/internal/app/service/service_handler_test.go @@ -47,9 +47,9 @@ func getServiceFilter() *entity.ServiceFilter { First: nil, After: nil, }, - Name: nil, + CCRN: nil, Id: nil, - SupportGroupName: []*string{&sgName}, + SupportGroupCCRN: []*string{&sgName}, } } @@ -224,7 +224,7 @@ var _ = Describe("When creating Service", Label("app", "CreateService"), func() }) It("creates service", func() { - filter.Name = []*string{&service.Name} + filter.CCRN = []*string{&service.CCRN} db.On("CreateService", &service).Return(&service, nil) db.On("GetServices", filter).Return([]entity.Service{}, nil) @@ -233,7 +233,7 @@ var _ = Describe("When creating Service", Label("app", "CreateService"), func() Expect(err).To(BeNil(), "no error should be thrown") Expect(newService.Id).NotTo(BeEquivalentTo(0)) By("setting fields", func() { - Expect(newService.Name).To(BeEquivalentTo(service.Name)) + Expect(newService.CCRN).To(BeEquivalentTo(service.CCRN)) }) }) @@ -337,13 +337,13 @@ var _ = Describe("When updating Service", Label("app", "UpdateService"), func() It("updates service", func() { db.On("UpdateService", &service).Return(nil) serviceHandler = s.NewServiceHandler(db, er) - service.Name = "SecretService" + service.CCRN = "SecretService" filter.Id = []*int64{&service.Id} db.On("GetServices", filter).Return([]entity.Service{service}, nil) updatedService, err := serviceHandler.UpdateService(&service) Expect(err).To(BeNil(), "no error should be thrown") By("setting fields", func() { - Expect(updatedService.Name).To(BeEquivalentTo(service.Name)) + Expect(updatedService.CCRN).To(BeEquivalentTo(service.CCRN)) }) }) }) @@ -474,7 +474,7 @@ var _ = Describe("When modifying relationship of issueRepository and Service", L }) }) -var _ = Describe("When listing serviceNames", Label("app", "ListServicesNames"), func() { +var _ = Describe("When listing serviceCcrns", Label("app", "ListServicesCcrns"), func() { var ( db *mocks.MockDatabase serviceHandler s.ServiceHandler @@ -493,29 +493,29 @@ var _ = Describe("When listing serviceNames", Label("app", "ListServicesNames"), When("no filters are used", func() { BeforeEach(func() { - db.On("GetServiceNames", filter).Return([]string{}, nil) + db.On("GetServiceCcrns", filter).Return([]string{}, nil) }) It("it return the results", func() { serviceHandler = s.NewServiceHandler(db, er) - res, err := serviceHandler.ListServiceNames(filter, options) + res, err := serviceHandler.ListServiceCcrns(filter, options) Expect(err).To(BeNil(), "no error should be thrown") Expect(res).Should(BeEmpty(), "return correct result") }) }) - When("specific serviceNames filter is applied", func() { + When("specific serviceCcrns filter is applied", func() { BeforeEach(func() { filter = &entity.ServiceFilter{ - Name: []*string{&name}, + CCRN: []*string{&name}, } - db.On("GetServiceNames", filter).Return([]string{name}, nil) + db.On("GetServiceCcrns", filter).Return([]string{name}, nil) }) It("returns filtered services according to the service type", func() { serviceHandler = s.NewServiceHandler(db, er) - res, err := serviceHandler.ListServiceNames(filter, options) + res, err := serviceHandler.ListServiceCcrns(filter, options) Expect(err).To(BeNil(), "no error should be thrown") - Expect(res).Should(ConsistOf(name), "should only consist of serviceName") + Expect(res).Should(ConsistOf(name), "should only consist of serviceCcrn") }) }) }) diff --git a/internal/app/support_group/support_group_handler.go b/internal/app/support_group/support_group_handler.go index bb76a40b..47b6e316 100644 --- a/internal/app/support_group/support_group_handler.go +++ b/internal/app/support_group/support_group_handler.go @@ -139,7 +139,7 @@ func (sg *supportGroupHandler) CreateSupportGroup(supportGroup *entity.SupportGr }) f := &entity.SupportGroupFilter{ - Name: []*string{&supportGroup.Name}, + CCRN: []*string{&supportGroup.CCRN}, } supportGroups, err := sg.ListSupportGroups(f, &entity.ListOptions{}) @@ -150,7 +150,7 @@ func (sg *supportGroupHandler) CreateSupportGroup(supportGroup *entity.SupportGr } if len(supportGroups.Elements) > 0 { - return nil, NewSupportGroupHandlerError(fmt.Sprintf("Duplicated entry %s for name.", supportGroup.Name)) + return nil, NewSupportGroupHandlerError(fmt.Sprintf("Duplicated entry %s for ccrn.", supportGroup.CCRN)) } newSupportGroup, err := sg.database.CreateSupportGroup(supportGroup) @@ -279,24 +279,24 @@ func (sg *supportGroupHandler) RemoveUserFromSupportGroup(supportGroupId int64, return sg.GetSupportGroup(supportGroupId) } -func (sg *supportGroupHandler) ListSupportGroupNames(filter *entity.SupportGroupFilter, options *entity.ListOptions) ([]string, error) { +func (sg *supportGroupHandler) ListSupportGroupCcrns(filter *entity.SupportGroupFilter, options *entity.ListOptions) ([]string, error) { l := logrus.WithFields(logrus.Fields{ - "event": ListSupportGroupNamesEventName, + "event": ListSupportGroupCcrnsEventName, "filter": filter, }) - supportGroupNames, err := sg.database.GetSupportGroupNames(filter) + supportGroupCcrns, err := sg.database.GetSupportGroupCcrns(filter) if err != nil { l.Error(err) - return nil, NewSupportGroupHandlerError("Internal error while retrieving supportGroupNames.") + return nil, NewSupportGroupHandlerError("Internal error while retrieving supportGroupCcrns.") } - sg.eventRegistry.PushEvent(&ListSupportGroupNamesEvent{ + sg.eventRegistry.PushEvent(&ListSupportGroupCcrnsEvent{ Filter: filter, Options: options, - Names: supportGroupNames, + Ccrns: supportGroupCcrns, }) - return supportGroupNames, nil + return supportGroupCcrns, nil } diff --git a/internal/app/support_group/support_group_handler_events.go b/internal/app/support_group/support_group_handler_events.go index 8ec8ebed..bdd17bd5 100644 --- a/internal/app/support_group/support_group_handler_events.go +++ b/internal/app/support_group/support_group_handler_events.go @@ -18,7 +18,7 @@ const ( RemoveServiceFromSupportGroupEventName event.EventName = "RemoveServiceFromSupportGroup" AddUserToSupportGroupEventName event.EventName = "AddUserToSupportGroup" RemoveUserFromSupportGroupEventName event.EventName = "RemoveUserFromSupportGroup" - ListSupportGroupNamesEventName event.EventName = "ListSupportGroupNames" + ListSupportGroupCcrnsEventName event.EventName = "ListSupportGroupCcrns" ) type ListSupportGroupsEvent struct { @@ -100,12 +100,12 @@ func (e *RemoveUserFromSupportGroupEvent) Name() event.EventName { return RemoveUserFromSupportGroupEventName } -type ListSupportGroupNamesEvent struct { +type ListSupportGroupCcrnsEvent struct { Filter *entity.SupportGroupFilter Options *entity.ListOptions - Names []string + Ccrns []string } -func (e *ListSupportGroupNamesEvent) Name() event.EventName { - return ListSupportGroupNamesEventName +func (e *ListSupportGroupCcrnsEvent) Name() event.EventName { + return ListSupportGroupCcrnsEventName } diff --git a/internal/app/support_group/support_group_handler_interface.go b/internal/app/support_group/support_group_handler_interface.go index 404d72dd..b596f618 100644 --- a/internal/app/support_group/support_group_handler_interface.go +++ b/internal/app/support_group/support_group_handler_interface.go @@ -15,5 +15,5 @@ type SupportGroupHandler interface { RemoveServiceFromSupportGroup(int64, int64) (*entity.SupportGroup, error) AddUserToSupportGroup(int64, int64) (*entity.SupportGroup, error) RemoveUserFromSupportGroup(int64, int64) (*entity.SupportGroup, error) - ListSupportGroupNames(*entity.SupportGroupFilter, *entity.ListOptions) ([]string, error) + ListSupportGroupCcrns(*entity.SupportGroupFilter, *entity.ListOptions) ([]string, error) } diff --git a/internal/app/support_group/support_group_handler_test.go b/internal/app/support_group/support_group_handler_test.go index 22bdb101..859ddacd 100644 --- a/internal/app/support_group/support_group_handler_test.go +++ b/internal/app/support_group/support_group_handler_test.go @@ -121,7 +121,7 @@ var _ = Describe("When creating SupportGroup", Label("app", "CreateSupportGroup" }) It("creates supportGroup", func() { - filter.Name = []*string{&supportGroup.Name} + filter.CCRN = []*string{&supportGroup.CCRN} db.On("CreateSupportGroup", &supportGroup).Return(&supportGroup, nil) db.On("GetSupportGroups", filter).Return([]entity.SupportGroup{}, nil) supportGroupHandler = sg.NewSupportGroupHandler(db, er) @@ -129,7 +129,7 @@ var _ = Describe("When creating SupportGroup", Label("app", "CreateSupportGroup" Expect(err).To(BeNil(), "no error should be thrown") Expect(newSupportGroup.Id).NotTo(BeEquivalentTo(0)) By("setting fields", func() { - Expect(newSupportGroup.Name).To(BeEquivalentTo(supportGroup.Name)) + Expect(newSupportGroup.CCRN).To(BeEquivalentTo(supportGroup.CCRN)) }) }) }) @@ -159,13 +159,13 @@ var _ = Describe("When updating SupportGroup", Label("app", "UpdateSupportGroup" It("updates supportGroup", func() { db.On("UpdateSupportGroup", &supportGroup).Return(nil) supportGroupHandler = sg.NewSupportGroupHandler(db, er) - supportGroup.Name = "Team Alone" + supportGroup.CCRN = "Team Alone" filter.Id = []*int64{&supportGroup.Id} db.On("GetSupportGroups", filter).Return([]entity.SupportGroup{supportGroup}, nil) updatedSupportGroup, err := supportGroupHandler.UpdateSupportGroup(&supportGroup) Expect(err).To(BeNil(), "no error should be thrown") By("setting fields", func() { - Expect(updatedSupportGroup.Name).To(BeEquivalentTo(supportGroup.Name)) + Expect(updatedSupportGroup.CCRN).To(BeEquivalentTo(supportGroup.CCRN)) }) }) }) @@ -293,48 +293,48 @@ var _ = Describe("When modifying relationship of User and SupportGroup", Label(" Expect(supportGroup).NotTo(BeNil(), "supportGroup should be returned") }) }) -var _ = Describe("When listing supportGroupNames", Label("app", "ListSupportGroupNames"), func() { +var _ = Describe("When listing supportGroupCcrns", Label("app", "ListSupportGroupCcrns"), func() { var ( db *mocks.MockDatabase supportGroupHandler sg.SupportGroupHandler filter *entity.SupportGroupFilter options *entity.ListOptions - name string + ccrn string ) BeforeEach(func() { db = mocks.NewMockDatabase(GinkgoT()) options = entity.NewListOptions() filter = getSupportGroupFilter() - name = "src" + ccrn = "src" }) When("no filters are used", func() { BeforeEach(func() { - db.On("GetSupportGroupNames", filter).Return([]string{}, nil) + db.On("GetSupportGroupCcrns", filter).Return([]string{}, nil) }) It("it return the results", func() { supportGroupHandler = sg.NewSupportGroupHandler(db, er) - res, err := supportGroupHandler.ListSupportGroupNames(filter, options) + res, err := supportGroupHandler.ListSupportGroupCcrns(filter, options) Expect(err).To(BeNil(), "no error should be thrown") Expect(res).Should(BeEmpty(), "return correct result") }) }) - When("specific supportGroupNames filter is applied", func() { + When("specific supportGroupCcrns filter is applied", func() { BeforeEach(func() { filter = &entity.SupportGroupFilter{ - Name: []*string{&name}, + CCRN: []*string{&ccrn}, } - db.On("GetSupportGroupNames", filter).Return([]string{name}, nil) + db.On("GetSupportGroupCcrns", filter).Return([]string{ccrn}, nil) }) It("returns filtered userGroups according to the service type", func() { supportGroupHandler = sg.NewSupportGroupHandler(db, er) - res, err := supportGroupHandler.ListSupportGroupNames(filter, options) + res, err := supportGroupHandler.ListSupportGroupCcrns(filter, options) Expect(err).To(BeNil(), "no error should be thrown") - Expect(res).Should(ConsistOf(name), "should only consist of supportGroup") + Expect(res).Should(ConsistOf(ccrn), "should only consist of supportGroup") }) }) }) diff --git a/internal/database/interface.go b/internal/database/interface.go index 61a43f2d..6bc94636 100644 --- a/internal/database/interface.go +++ b/internal/database/interface.go @@ -52,7 +52,7 @@ type Database interface { RemoveEvidenceFromIssueMatch(int64, int64) error GetServices(*entity.ServiceFilter) ([]entity.Service, error) - GetServicesWithAggregations(*entity.ServiceFilter) ([]entity.ServiceWithAggregations, error) + GetServicesWithAggregations(*entity.ServiceFilter) ([]entity.ServiceWithAggregations, error) GetAllServiceIds(*entity.ServiceFilter) ([]int64, error) CountServices(*entity.ServiceFilter) (int64, error) CreateService(*entity.Service) (*entity.Service, error) @@ -62,7 +62,7 @@ type Database interface { RemoveOwnerFromService(int64, int64) error AddIssueRepositoryToService(int64, int64, int64) error RemoveIssueRepositoryFromService(int64, int64) error - GetServiceNames(*entity.ServiceFilter) ([]string, error) + GetServiceCcrns(*entity.ServiceFilter) ([]string, error) GetUsers(*entity.UserFilter) ([]entity.User, error) GetAllUserIds(*entity.UserFilter) ([]int64, error) @@ -83,7 +83,7 @@ type Database interface { RemoveServiceFromSupportGroup(int64, int64) error AddUserToSupportGroup(int64, int64) error RemoveUserFromSupportGroup(int64, int64) error - GetSupportGroupNames(*entity.SupportGroupFilter) ([]string, error) + GetSupportGroupCcrns(*entity.SupportGroupFilter) ([]string, error) GetComponentInstances(*entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error) GetAllComponentInstanceIds(*entity.ComponentInstanceFilter) ([]int64, error) @@ -91,7 +91,7 @@ type Database interface { CreateComponentInstance(*entity.ComponentInstance) (*entity.ComponentInstance, error) UpdateComponentInstance(*entity.ComponentInstance) error DeleteComponentInstance(int64) error - GetComponentNames(filter *entity.ComponentFilter) ([]string, error) + GetComponentCcrns(filter *entity.ComponentFilter) ([]string, error) GetCcrn(filter *entity.ComponentInstanceFilter) ([]string, error) GetActivities(*entity.ActivityFilter) ([]entity.Activity, error) diff --git a/internal/database/mariadb/activity.go b/internal/database/mariadb/activity.go index 681f0543..4f6e1c5f 100644 --- a/internal/database/mariadb/activity.go +++ b/internal/database/mariadb/activity.go @@ -27,7 +27,7 @@ func (s *SqlDatabase) ensureActivityFilter(f *entity.ActivityFilter) *entity.Act Id: nil, Status: nil, ServiceId: nil, - ServiceName: nil, + ServiceCCRN: nil, IssueId: nil, EvidenceId: nil, } @@ -35,10 +35,10 @@ func (s *SqlDatabase) ensureActivityFilter(f *entity.ActivityFilter) *entity.Act func (s *SqlDatabase) getActivityJoins(filter *entity.ActivityFilter) string { joins := "" - if len(filter.ServiceId) > 0 || len(filter.ServiceName) > 0 { + if len(filter.ServiceId) > 0 || len(filter.ServiceCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, "LEFT JOIN ActivityHasService AHS on A.activity_id = AHS.activityhasservice_activity_id") } - if len(filter.ServiceName) > 0 { + if len(filter.ServiceCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, "LEFT JOIN Service S on AHS.activityhasservice_service_id = S.service_id") } if len(filter.EvidenceId) > 0 { @@ -55,7 +55,7 @@ func (s *SqlDatabase) getActivityFilterString(filter *entity.ActivityFilter) str fl = append(fl, buildFilterQuery(filter.Id, "A.activity_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Status, "A.activity_status = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ServiceId, "AHS.activityhasservice_service_id = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.ServiceName, "S.service_name= ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.ServiceCCRN, "S.service_ccrn= ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.EvidenceId, "E.evidence_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.IssueId, "AHI.activityhasissue_issue_id = ?", OP_OR)) fl = append(fl, "A.activity_deleted_at IS NULL") @@ -113,7 +113,7 @@ func (s *SqlDatabase) buildActivityStatement(baseQuery string, filter *entity.Ac filterParameters = buildQueryParameters(filterParameters, filter.Id) filterParameters = buildQueryParameters(filterParameters, filter.Status) filterParameters = buildQueryParameters(filterParameters, filter.ServiceId) - filterParameters = buildQueryParameters(filterParameters, filter.ServiceName) + filterParameters = buildQueryParameters(filterParameters, filter.ServiceCCRN) filterParameters = buildQueryParameters(filterParameters, filter.EvidenceId) filterParameters = buildQueryParameters(filterParameters, filter.IssueId) if withCursor { diff --git a/internal/database/mariadb/activity_test.go b/internal/database/mariadb/activity_test.go index 83e61573..05238133 100644 --- a/internal/database/mariadb/activity_test.go +++ b/internal/database/mariadb/activity_test.go @@ -229,7 +229,7 @@ var _ = Describe("Activity", Label("database", "Activity"), func() { } } - filter := &entity.ActivityFilter{ServiceName: []*string{&serviceRow.Name.String}} + filter := &entity.ActivityFilter{ServiceCCRN: []*string{&serviceRow.CCRN.String}} entries, err := db.GetActivities(filter) @@ -386,7 +386,7 @@ var _ = Describe("Activity", Label("database", "Activity"), func() { } } - filter := &entity.ActivityFilter{ServiceName: []*string{&serviceRow.Name.String}} + filter := &entity.ActivityFilter{ServiceCCRN: []*string{&serviceRow.CCRN.String}} entries, err := db.CountActivities(filter) By("throwing no error", func() { diff --git a/internal/database/mariadb/component.go b/internal/database/mariadb/component.go index 83814441..cffb0c87 100644 --- a/internal/database/mariadb/component.go +++ b/internal/database/mariadb/component.go @@ -14,7 +14,7 @@ import ( func (s *SqlDatabase) getComponentFilterString(filter *entity.ComponentFilter) string { var fl []string - fl = append(fl, buildFilterQuery(filter.Name, "C.component_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.CCRN, "C.component_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Id, "C.component_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ComponentVersionId, "CV.componentversion_id = ?", OP_OR)) fl = append(fl, "C.component_deleted_at IS NULL") @@ -31,7 +31,7 @@ func (s *SqlDatabase) ensureComponentFilter(f *entity.ComponentFilter) *entity.C First: &first, After: &after, }, - Name: nil, + CCRN: nil, Id: nil, ComponentVersionId: nil, } @@ -58,8 +58,8 @@ func (s *SqlDatabase) getComponentJoins(filter *entity.ComponentFilter) string { func (s *SqlDatabase) getComponentUpdateFields(component *entity.Component) string { fl := []string{} - if component.Name != "" { - fl = append(fl, "component_name = :component_name") + if component.CCRN != "" { + fl = append(fl, "component_ccrn = :component_ccrn") } if component.Type != "" { fl = append(fl, "component_type = :component_type") @@ -106,7 +106,7 @@ func (s *SqlDatabase) buildComponentStatement(baseQuery string, filter *entity.C //adding parameters var filterParameters []interface{} - filterParameters = buildQueryParameters(filterParameters, filter.Name) + filterParameters = buildQueryParameters(filterParameters, filter.CCRN) filterParameters = buildQueryParameters(filterParameters, filter.Id) filterParameters = buildQueryParameters(filterParameters, filter.ComponentVersionId) if withCursor { @@ -201,10 +201,10 @@ func (s *SqlDatabase) CreateComponent(component *entity.Component) (*entity.Comp query := ` INSERT INTO Component ( - component_name, + component_ccrn, component_type ) VALUES ( - :component_name, + :component_ccrn, :component_type ) ` @@ -268,17 +268,17 @@ func (s *SqlDatabase) DeleteComponent(id int64) error { return err } -func (s *SqlDatabase) GetComponentNames(filter *entity.ComponentFilter) ([]string, error) { +func (s *SqlDatabase) GetComponentCcrns(filter *entity.ComponentFilter) ([]string, error) { l := logrus.WithFields(logrus.Fields{ "filter": filter, - "event": "database.GetComponentNames", + "event": "database.GetComponentCcrns", }) baseQuery := ` - SELECT C.component_name FROM Component C + SELECT C.component_ccrn FROM Component C %s %s - ORDER BY C.component_name + ORDER BY C.component_ccrn ` // Ensure the filter is initialized @@ -301,19 +301,19 @@ func (s *SqlDatabase) GetComponentNames(filter *entity.ComponentFilter) ([]strin defer rows.Close() // Collect the results - componentNames := []string{} + componentCcrns := []string{} var name string for rows.Next() { if err := rows.Scan(&name); err != nil { l.Error("Error scanning row: ", err) continue } - componentNames = append(componentNames, name) + componentCcrns = append(componentCcrns, name) } if err = rows.Err(); err != nil { l.Error("Row iteration error: ", err) return nil, err } - return componentNames, nil + return componentCcrns, nil } diff --git a/internal/database/mariadb/component_test.go b/internal/database/mariadb/component_test.go index fc6a1d29..30fe938a 100644 --- a/internal/database/mariadb/component_test.go +++ b/internal/database/mariadb/component_test.go @@ -146,7 +146,7 @@ var _ = Describe("Component", Label("database", "Component"), func() { for _, r := range res { for _, row := range seedCollection.ComponentRows { if r.Id == row.Id.Int64 { - Expect(r.Name).Should(BeEquivalentTo(row.Name.String), "Name should match") + Expect(r.CCRN).Should(BeEquivalentTo(row.CCRN.String), "CCRN should match") Expect(r.Type).Should(BeEquivalentTo(row.Type.String), "Type should match") Expect(r.CreatedAt).ShouldNot(BeEquivalentTo(row.CreatedAt.Time), "CreatedAt matches") Expect(r.UpdatedAt).ShouldNot(BeEquivalentTo(row.UpdatedAt.Time), "UpdatedAt matches") @@ -169,15 +169,15 @@ var _ = Describe("Component", Label("database", "Component"), func() { By("returning some results", func() { Expect(entries).NotTo(BeEmpty()) }) - By("returning entries include the component name", func() { + By("returning entries include the component ccrn", func() { for _, entry := range entries { Expect(entry.Id).To(BeEquivalentTo(row.Id.Int64)) } }) }) - It("can filter by a single name", func() { + It("can filter by a single ccrn", func() { row := seedCollection.ComponentRows[rand.Intn(len(seedCollection.ComponentRows))] - filter := &entity.ComponentFilter{Name: []*string{&row.Name.String}} + filter := &entity.ComponentFilter{CCRN: []*string{&row.CCRN.String}} entries, err := db.GetComponents(filter) @@ -187,15 +187,15 @@ var _ = Describe("Component", Label("database", "Component"), func() { By("returning some results", func() { Expect(entries).NotTo(BeEmpty()) }) - By("returning entries include the component name", func() { + By("returning entries include the component ccrn", func() { for _, entry := range entries { - Expect(entry.Name).To(BeEquivalentTo(row.Name.String)) + Expect(entry.CCRN).To(BeEquivalentTo(row.CCRN.String)) } }) }) - It("can filter by a random non existing component name", func() { - nonExistingName := util.GenerateRandomString(40, nil) - filter := &entity.ComponentFilter{Name: []*string{&nonExistingName}} + It("can filter by a random non existing component ccrn", func() { + nonExistingCCRN := util.GenerateRandomString(40, nil) + filter := &entity.ComponentFilter{CCRN: []*string{&nonExistingCCRN}} entries, err := db.GetComponents(filter) @@ -206,13 +206,13 @@ var _ = Describe("Component", Label("database", "Component"), func() { Expect(entries).To(BeEmpty()) }) }) - It("can filter by all existing component names", func() { - componentNames := make([]*string, len(seedCollection.ComponentRows)) + It("can filter by all existing component ccrns", func() { + componentCCRNs := make([]*string, len(seedCollection.ComponentRows)) for i, row := range seedCollection.ComponentRows { - x := row.Name.String - componentNames[i] = &x + x := row.CCRN.String + componentCCRNs[i] = &x } - filter := &entity.ComponentFilter{Name: componentNames} + filter := &entity.ComponentFilter{CCRN: componentCCRNs} entries, err := db.GetComponents(filter) @@ -307,10 +307,10 @@ var _ = Describe("Component", Label("database", "Component"), func() { DescribeTable("can count with a filter", func(pageSize int, filterMatches int) { componentRow := seedCollection.ComponentRows[rand.Intn(len(seedCollection.ComponentRows))] - // collect all component ids that have the previously selected name + // collect all component ids that have the previously selected ccrn componentIds := []int64{} for _, cRow := range seedCollection.ComponentRows { - if cRow.Name.String == componentRow.Name.String { + if cRow.CCRN.String == componentRow.CCRN.String { componentIds = append(componentIds, cRow.Id.Int64) } } @@ -320,7 +320,7 @@ var _ = Describe("Component", Label("database", "Component"), func() { First: &pageSize, After: nil, }, - Name: []*string{&componentRow.Name.String}, + CCRN: []*string{&componentRow.CCRN.String}, } entries, err := db.CountComponents(filter) By("throwing no error", func() { @@ -370,11 +370,11 @@ var _ = Describe("Component", Label("database", "Component"), func() { }) By("setting fields", func() { Expect(c[0].Id).To(BeEquivalentTo(component.Id)) - Expect(c[0].Name).To(BeEquivalentTo(component.Name)) + Expect(c[0].CCRN).To(BeEquivalentTo(component.CCRN)) Expect(c[0].Type).To(BeEquivalentTo(component.Type)) }) }) - It("does not insert component with existing name", func() { + It("does not insert component with existing ccrn", func() { componentRow := seedCollection.ComponentRows[0] component := componentRow.AsComponent() newComponent, err := db.CreateComponent(&component) @@ -395,10 +395,10 @@ var _ = Describe("Component", Label("database", "Component"), func() { BeforeEach(func() { seedCollection = seeder.SeedDbWithNFakeData(10) }) - It("can update name correctly", func() { + It("can update ccrn correctly", func() { component := seedCollection.ComponentRows[0].AsComponent() - component.Name = "NewName" + component.CCRN = "NewCCRN" err := db.UpdateComponent(&component) By("throwing no error", func() { @@ -418,7 +418,7 @@ var _ = Describe("Component", Label("database", "Component"), func() { }) By("setting fields", func() { Expect(c[0].Id).To(BeEquivalentTo(component.Id)) - Expect(c[0].Name).To(BeEquivalentTo(component.Name)) + Expect(c[0].CCRN).To(BeEquivalentTo(component.CCRN)) Expect(c[0].Type).To(BeEquivalentTo(component.Type)) }) }) @@ -445,7 +445,7 @@ var _ = Describe("Component", Label("database", "Component"), func() { }) By("setting fields", func() { Expect(c[0].Id).To(BeEquivalentTo(component.Id)) - Expect(c[0].Name).To(BeEquivalentTo(component.Name)) + Expect(c[0].CCRN).To(BeEquivalentTo(component.CCRN)) Expect(c[0].Type).To(BeEquivalentTo(component.Type)) }) }) diff --git a/internal/database/mariadb/component_version.go b/internal/database/mariadb/component_version.go index 10c84973..8f4ec7b5 100644 --- a/internal/database/mariadb/component_version.go +++ b/internal/database/mariadb/component_version.go @@ -5,9 +5,10 @@ package mariadb import ( "fmt" - "github.com/cloudoperators/heureka/internal/database" "strings" + "github.com/cloudoperators/heureka/internal/database" + "github.com/cloudoperators/heureka/internal/entity" "github.com/jmoiron/sqlx" "github.com/sirupsen/logrus" @@ -24,7 +25,7 @@ func (s *SqlDatabase) ensureComponentVersionFilter(f *entity.ComponentVersionFil }, Id: nil, IssueId: nil, - ComponentName: nil, + ComponentCCRN: nil, ComponentId: nil, } } @@ -42,7 +43,7 @@ func (s *SqlDatabase) getComponentVersionJoins(filter *entity.ComponentVersionFi if len(filter.IssueId) > 0 { joins = fmt.Sprintf("%s\n%s", joins, "LEFT JOIN ComponentVersionIssue CVI on CV.componentversion_id = CVI.componentversionissue_component_version_id") } - if len(filter.ComponentName) > 0 { + if len(filter.ComponentCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, "LEFT JOIN Component C on CV.componentversion_component_id = C.component_id") } return joins @@ -65,7 +66,7 @@ func (s *SqlDatabase) getComponentVersionFilterString(filter *entity.ComponentVe fl = append(fl, buildFilterQuery(filter.IssueId, "CVI.componentversionissue_issue_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ComponentId, "CV.componentversion_component_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Version, "CV.componentversion_version = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.ComponentName, "C.component_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.ComponentCCRN, "C.component_ccrn = ?", OP_OR)) fl = append(fl, "CV.componentversion_deleted_at IS NULL") return combineFilterQueries(fl, OP_AND) @@ -114,7 +115,7 @@ func (s *SqlDatabase) buildComponentVersionStatement(baseQuery string, filter *e filterParameters = buildQueryParameters(filterParameters, filter.IssueId) filterParameters = buildQueryParameters(filterParameters, filter.ComponentId) filterParameters = buildQueryParameters(filterParameters, filter.Version) - filterParameters = buildQueryParameters(filterParameters, filter.ComponentName) + filterParameters = buildQueryParameters(filterParameters, filter.ComponentCCRN) if withCursor { filterParameters = append(filterParameters, cursor.Value) filterParameters = append(filterParameters, cursor.Limit) diff --git a/internal/database/mariadb/component_version_test.go b/internal/database/mariadb/component_version_test.go index 342a6a8c..a2237a75 100644 --- a/internal/database/mariadb/component_version_test.go +++ b/internal/database/mariadb/component_version_test.go @@ -245,16 +245,16 @@ var _ = Describe("ComponentVersion", Label("database", "ComponentVersion"), func It("can filter by a version and component", func() { cv := seedCollection.ComponentVersionRows[rand.Intn(len(seedCollection.ComponentVersionRows))] - componentName := "" + componentCCRN := "" for _, cr := range seedCollection.ComponentRows { if cr.Id.Int64 == cv.ComponentId.Int64 { - componentName = cr.Name.String + componentCCRN = cr.CCRN.String } } filter := &entity.ComponentVersionFilter{ Version: []*string{&cv.Version.String}, - ComponentName: []*string{&componentName}, + ComponentCCRN: []*string{&componentCCRN}, } entries, err := db.GetComponentVersions(filter) diff --git a/internal/database/mariadb/entity.go b/internal/database/mariadb/entity.go index 198f3896..c03c5577 100644 --- a/internal/database/mariadb/entity.go +++ b/internal/database/mariadb/entity.go @@ -395,7 +395,7 @@ func (siv *ServiceIssueVariantRow) AsServiceIssueVariantEntry() entity.ServiceIs type ComponentRow struct { Id sql.NullInt64 `db:"component_id" json:"id"` - Name sql.NullString `db:"component_name" json:"name"` + CCRN sql.NullString `db:"component_ccrn" json:"ccrn"` Type sql.NullString `db:"component_type" json:"type"` CreatedAt sql.NullTime `db:"component_created_at" json:"created_at"` DeletedAt sql.NullTime `db:"component_deleted_at" json:"deleted_at,omitempty"` @@ -405,7 +405,7 @@ type ComponentRow struct { func (cr *ComponentRow) AsComponent() entity.Component { return entity.Component{ Id: GetInt64Value(cr.Id), - Name: GetStringValue(cr.Name), + CCRN: GetStringValue(cr.CCRN), Type: GetStringValue(cr.Type), CreatedAt: GetTimeValue(cr.CreatedAt), DeletedAt: GetTimeValue(cr.DeletedAt), @@ -415,7 +415,7 @@ func (cr *ComponentRow) AsComponent() entity.Component { func (cr *ComponentRow) FromComponent(c *entity.Component) { cr.Id = sql.NullInt64{Int64: c.Id, Valid: true} - cr.Name = sql.NullString{String: c.Name, Valid: true} + cr.CCRN = sql.NullString{String: c.CCRN, Valid: true} cr.Type = sql.NullString{String: c.Type, Valid: true} cr.CreatedAt = sql.NullTime{Time: c.CreatedAt, Valid: true} cr.DeletedAt = sql.NullTime{Time: c.DeletedAt, Valid: true} @@ -453,7 +453,7 @@ func (cvr *ComponentVersionRow) FromComponentVersion(cv *entity.ComponentVersion type SupportGroupRow struct { Id sql.NullInt64 `db:"supportgroup_id" json:"id"` - Name sql.NullString `db:"supportgroup_name" json:"name"` + CCRN sql.NullString `db:"supportgroup_ccrn" json:"ccrn"` CreatedAt sql.NullTime `db:"supportgroup_created_at" json:"created_at"` DeletedAt sql.NullTime `db:"supportgroup_deleted_at" json:"deleted_at,omitempty"` UpdatedAt sql.NullTime `db:"supportgroup_updated_at" json:"updated_at"` @@ -462,7 +462,7 @@ type SupportGroupRow struct { func (sgr *SupportGroupRow) AsSupportGroup() entity.SupportGroup { return entity.SupportGroup{ Id: GetInt64Value(sgr.Id), - Name: GetStringValue(sgr.Name), + CCRN: GetStringValue(sgr.CCRN), CreatedAt: GetTimeValue(sgr.CreatedAt), DeletedAt: GetTimeValue(sgr.DeletedAt), UpdatedAt: GetTimeValue(sgr.UpdatedAt), @@ -471,7 +471,7 @@ func (sgr *SupportGroupRow) AsSupportGroup() entity.SupportGroup { func (sgr *SupportGroupRow) FromSupportGroup(sg *entity.SupportGroup) { sgr.Id = sql.NullInt64{Int64: sg.Id, Valid: true} - sgr.Name = sql.NullString{String: sg.Name, Valid: true} + sgr.CCRN = sql.NullString{String: sg.CCRN, Valid: true} sgr.CreatedAt = sql.NullTime{Time: sg.CreatedAt, Valid: true} sgr.DeletedAt = sql.NullTime{Time: sg.DeletedAt, Valid: true} sgr.UpdatedAt = sql.NullTime{Time: sg.UpdatedAt, Valid: true} @@ -484,7 +484,7 @@ type ServiceRow struct { type BaseServiceRow struct { Id sql.NullInt64 `db:"service_id" json:"id"` - Name sql.NullString `db:"service_name" json:"name"` + CCRN sql.NullString `db:"service_ccrn" json:"ccrn"` CreatedAt sql.NullTime `db:"service_created_at" json:"created_at"` DeletedAt sql.NullTime `db:"service_deleted_at" json:"deleted_at,omitempty"` UpdatedAt sql.NullTime `db:"service_updated_at" json:"updated_at"` @@ -493,7 +493,7 @@ type BaseServiceRow struct { func (bsr *BaseServiceRow) AsBaseService() entity.BaseService { return entity.BaseService{ Id: GetInt64Value(bsr.Id), - Name: GetStringValue(bsr.Name), + CCRN: GetStringValue(bsr.CCRN), Owners: []entity.User{}, Activities: []entity.Activity{}, CreatedAt: GetTimeValue(bsr.CreatedAt), @@ -513,7 +513,7 @@ func (sr *ServiceRow) AsService() entity.Service { return entity.Service{ BaseService: entity.BaseService{ Id: GetInt64Value(sr.Id), - Name: GetStringValue(sr.Name), + CCRN: GetStringValue(sr.CCRN), Owners: []entity.User{}, Activities: []entity.Activity{}, CreatedAt: GetTimeValue(sr.BaseServiceRow.CreatedAt), @@ -529,7 +529,7 @@ func (sr *ServiceRow) AsService() entity.Service { func (sr *ServiceRow) FromService(s *entity.Service) { sr.Id = sql.NullInt64{Int64: s.Id, Valid: true} - sr.Name = sql.NullString{String: s.Name, Valid: true} + sr.CCRN = sql.NullString{String: s.CCRN, Valid: true} sr.BaseServiceRow.CreatedAt = sql.NullTime{Time: s.BaseService.CreatedAt, Valid: true} sr.BaseServiceRow.DeletedAt = sql.NullTime{Time: s.BaseService.DeletedAt, Valid: true} sr.BaseServiceRow.UpdatedAt = sql.NullTime{Time: s.BaseService.UpdatedAt, Valid: true} @@ -554,7 +554,7 @@ func (sbr *GetServicesByRow) AsServiceWithAggregations() entity.ServiceWithAggre Service: entity.Service{ BaseService: entity.BaseService{ Id: GetInt64Value(sbr.BaseServiceRow.Id), - Name: GetStringValue(sbr.BaseServiceRow.Name), + CCRN: GetStringValue(sbr.BaseServiceRow.CCRN), Owners: []entity.User{}, Activities: []entity.Activity{}, CreatedAt: GetTimeValue(sbr.BaseServiceRow.CreatedAt), diff --git a/internal/database/mariadb/init/schema.sql b/internal/database/mariadb/init/schema.sql index 2bf40894..c8b59885 100644 --- a/internal/database/mariadb/init/schema.sql +++ b/internal/database/mariadb/init/schema.sql @@ -9,15 +9,15 @@ create table if not exists Component ( component_id int unsigned auto_increment primary key, - component_name varchar(256) not null, + component_ccrn varchar(256) not null, component_type varchar(256) not null, component_created_at timestamp default current_timestamp() not null, component_deleted_at timestamp null, component_updated_at timestamp default current_timestamp() not null on update current_timestamp(), constraint component_id_UNIQUE unique (component_id), - constraint component_name_UNIQUE - unique (component_name) + constraint component_ccrn_UNIQUE + unique (component_ccrn) ); create table if not exists ComponentVersion @@ -42,28 +42,28 @@ create table if not exists SupportGroup ( supportgroup_id int unsigned auto_increment primary key, - supportgroup_name varchar(256) not null, + supportgroup_ccrn varchar(256) not null, supportgroup_created_at timestamp default current_timestamp() not null, supportgroup_deleted_at timestamp null, supportgroup_updated_at timestamp default current_timestamp() not null on update current_timestamp(), constraint supportgroup_id_UNIQUE unique (supportgroup_id), - constraint supportgroup_name_UNIQUE - unique (supportgroup_name) + constraint supportgroup_ccrn_UNIQUE + unique (supportgroup_ccrn) ); create table if not exists Service ( service_id int unsigned auto_increment primary key, - service_name varchar(256) not null, + service_ccrn varchar(256) not null, service_created_at timestamp default current_timestamp() not null, service_deleted_at timestamp null, service_updated_at timestamp default current_timestamp() not null on update current_timestamp(), constraint service_id_UNIQUE unique (service_id), - constraint service_name_UNIQUE - unique (service_name) + constraint service_ccrn_UNIQUE + unique (service_ccrn) ); create table if not exists SupportGroupService diff --git a/internal/database/mariadb/issue.go b/internal/database/mariadb/issue.go index dd7674ca..ebfb98c7 100644 --- a/internal/database/mariadb/issue.go +++ b/internal/database/mariadb/issue.go @@ -21,7 +21,7 @@ const ( func (s *SqlDatabase) buildIssueFilterParameters(filter *entity.IssueFilter, withCursor bool, cursor entity.Cursor) []interface{} { var filterParameters []interface{} - filterParameters = buildQueryParameters(filterParameters, filter.ServiceName) + filterParameters = buildQueryParameters(filterParameters, filter.ServiceCCRN) filterParameters = buildQueryParameters(filterParameters, filter.Id) filterParameters = buildQueryParameters(filterParameters, filter.IssueMatchStatus) filterParameters = buildQueryParameters(filterParameters, filter.ActivityId) @@ -41,7 +41,7 @@ func (s *SqlDatabase) buildIssueFilterParameters(filter *entity.IssueFilter, wit func (s *SqlDatabase) getIssueFilterString(filter *entity.IssueFilter) string { var fl []string - fl = append(fl, buildFilterQuery(filter.ServiceName, "S.service_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.ServiceCCRN, "S.service_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Id, "I.issue_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.IssueMatchStatus, "IM.issuematch_status = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ActivityId, "A.activity_id = ?", OP_OR)) @@ -64,12 +64,12 @@ func (s *SqlDatabase) getIssueJoins(filter *entity.IssueFilter) string { LEFT JOIN Activity A on AHI.activityhasissue_activity_id = A.activity_id `) } - if len(filter.IssueMatchStatus) > 0 || len(filter.ServiceName) > 0 || len(filter.IssueMatchId) > 0 { + if len(filter.IssueMatchStatus) > 0 || len(filter.ServiceCCRN) > 0 || len(filter.IssueMatchId) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN IssueMatch IM ON I.issue_id = IM.issuematch_issue_id `) } - if len(filter.ServiceName) > 0 { + if len(filter.ServiceCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN ComponentInstance CI ON CI.componentinstance_id = IM.issuematch_component_instance_id LEFT JOIN ComponentVersion CV ON CI.componentinstance_component_version_id = CV.componentversion_id @@ -101,7 +101,7 @@ func (s *SqlDatabase) ensureIssueFilter(f *entity.IssueFilter) *entity.IssueFilt First: &first, After: &after, }, - ServiceName: nil, + ServiceCCRN: nil, Id: nil, ActivityId: nil, IssueMatchStatus: nil, @@ -200,7 +200,7 @@ func (s *SqlDatabase) GetIssuesWithAggregations(filter *entity.IssueFilter) ([]e SELECT I.*, count(distinct issuematch_id) as agg_issue_matches, count(distinct activity_id) as agg_activities, - count(distinct service_name) as agg_affected_services, + count(distinct service_ccrn) as agg_affected_services, count(distinct componentversionissue_component_version_id) as agg_component_versions, min(issuematch_target_remediation_date) as agg_earliest_target_remediation_date, min(issuematch_created_at) agg_earliest_discovery_date diff --git a/internal/database/mariadb/issue_match.go b/internal/database/mariadb/issue_match.go index e851ef82..015845d6 100644 --- a/internal/database/mariadb/issue_match.go +++ b/internal/database/mariadb/issue_match.go @@ -34,12 +34,12 @@ func (s *SqlDatabase) getIssueMatchFilterString(filter *entity.IssueMatchFilter) fl = append(fl, buildFilterQuery(filter.IssueId, "IM.issuematch_issue_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ComponentInstanceId, "IM.issuematch_component_instance_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.EvidenceId, "IME.issuematchevidence_evidence_id = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.AffectedServiceName, "S.service_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.AffectedServiceCCRN, "S.service_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.SeverityValue, "IM.issuematch_rating = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Status, "IM.issuematch_status = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.SupportGroupName, "SG.supportgroup_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.SupportGroupCCRN, "SG.supportgroup_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.PrimaryName, "I.issue_primary_name = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.ComponentName, "C.component_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.ComponentCCRN, "C.component_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.IssueType, "I.issue_type = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Search, wildCardFilterQuery, OP_OR)) fl = append(fl, "IM.issuematch_deleted_at IS NULL") @@ -67,26 +67,26 @@ func (s *SqlDatabase) getIssueMatchJoins(filter *entity.IssueMatchFilter) string `) } - if len(filter.AffectedServiceName) > 0 || len(filter.SupportGroupName) > 0 || len(filter.ComponentName) > 0 { + if len(filter.AffectedServiceCCRN) > 0 || len(filter.SupportGroupCCRN) > 0 || len(filter.ComponentCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN ComponentInstance CI on CI.componentinstance_id = IM.issuematch_component_instance_id `) - if len(filter.ComponentName) > 0 { + if len(filter.ComponentCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN ComponentVersion CV on CV.componentversion_id = CI.componentinstance_component_version_id LEFT JOIN Component C on C.component_id = CV.componentversion_component_id `) } - if len(filter.AffectedServiceName) > 0 || len(filter.SupportGroupName) > 0 { + if len(filter.AffectedServiceCCRN) > 0 || len(filter.SupportGroupCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN Service S on S.service_id = CI.componentinstance_service_id `) } - if len(filter.SupportGroupName) > 0 { + if len(filter.SupportGroupCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN SupportGroupService SGS on S.service_id = SGS.supportgroupservice_service_id LEFT JOIN SupportGroup SG on SG.supportgroup_id = SGS.supportgroupservice_support_group_id @@ -168,12 +168,12 @@ func (s *SqlDatabase) buildIssueMatchStatement(baseQuery string, filter *entity. filterParameters = buildQueryParameters(filterParameters, filter.IssueId) filterParameters = buildQueryParameters(filterParameters, filter.ComponentInstanceId) filterParameters = buildQueryParameters(filterParameters, filter.EvidenceId) - filterParameters = buildQueryParameters(filterParameters, filter.AffectedServiceName) + filterParameters = buildQueryParameters(filterParameters, filter.AffectedServiceCCRN) filterParameters = buildQueryParameters(filterParameters, filter.SeverityValue) filterParameters = buildQueryParameters(filterParameters, filter.Status) - filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupName) + filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupCCRN) filterParameters = buildQueryParameters(filterParameters, filter.PrimaryName) - filterParameters = buildQueryParameters(filterParameters, filter.ComponentName) + filterParameters = buildQueryParameters(filterParameters, filter.ComponentCCRN) filterParameters = buildQueryParameters(filterParameters, filter.IssueType) filterParameters = buildQueryParametersCount(filterParameters, filter.Search, wildCardFilterParamCount) diff --git a/internal/database/mariadb/issue_match_test.go b/internal/database/mariadb/issue_match_test.go index 985a2495..46dfd8fa 100644 --- a/internal/database/mariadb/issue_match_test.go +++ b/internal/database/mariadb/issue_match_test.go @@ -317,7 +317,7 @@ var _ = Describe("IssueMatch", Label("database", "IssueMatch"), func() { filter := &entity.IssueMatchFilter{ Paginated: entity.Paginated{}, - SupportGroupName: []*string{&supportGroup.Name.String}, + SupportGroupCCRN: []*string{&supportGroup.CCRN.String}, } // fixture creation does not guarantee that a support group is always present diff --git a/internal/database/mariadb/issue_repository.go b/internal/database/mariadb/issue_repository.go index 431d4735..e9f8eef5 100644 --- a/internal/database/mariadb/issue_repository.go +++ b/internal/database/mariadb/issue_repository.go @@ -16,7 +16,7 @@ func (s *SqlDatabase) getIssueRepositoryFilterString(filter *entity.IssueReposit var fl []string fl = append(fl, buildFilterQuery(filter.Name, "IR.issuerepository_name = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Id, "IR.issuerepository_id = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.ServiceName, "S.service_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.ServiceCCRN, "S.service_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ServiceId, "IRS.issuerepositoryservice_service_id = ?", OP_OR)) fl = append(fl, "IR.issuerepository_deleted_at IS NULL") @@ -25,12 +25,12 @@ func (s *SqlDatabase) getIssueRepositoryFilterString(filter *entity.IssueReposit func (s *SqlDatabase) getIssueRepositoryJoins(filter *entity.IssueRepositoryFilter) string { joins := "" - if len(filter.ServiceId) > 0 || len(filter.ServiceName) > 0 { + if len(filter.ServiceId) > 0 || len(filter.ServiceCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN IssueRepositoryService IRS on IR.issuerepository_id = IRS.issuerepositoryservice_issue_repository_id `) } - if len(filter.ServiceName) > 0 { + if len(filter.ServiceCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN Service S on S.service_id = IRS.issuerepositoryservice_service_id `) @@ -51,7 +51,7 @@ func (s *SqlDatabase) getIssueRepositoryUpdateFields(issueRepository *entity.Iss func (s *SqlDatabase) getIssueRepositoryColumns(filter *entity.IssueRepositoryFilter) string { columns := "IR.*" - if len(filter.ServiceId) > 0 || len(filter.ServiceName) > 0 { + if len(filter.ServiceId) > 0 || len(filter.ServiceCCRN) > 0 { columns = fmt.Sprintf("%s, %s", columns, "IRS.*") } return columns @@ -69,7 +69,7 @@ func (s *SqlDatabase) ensureIssueRepositoryFilter(f *entity.IssueRepositoryFilte ServiceId: nil, Name: nil, Id: nil, - ServiceName: nil, + ServiceCCRN: nil, } } if f.First == nil { @@ -122,7 +122,7 @@ func (s *SqlDatabase) buildIssueRepositoryStatement(baseQuery string, filter *en var filterParameters []interface{} filterParameters = buildQueryParameters(filterParameters, filter.Name) filterParameters = buildQueryParameters(filterParameters, filter.Id) - filterParameters = buildQueryParameters(filterParameters, filter.ServiceName) + filterParameters = buildQueryParameters(filterParameters, filter.ServiceCCRN) filterParameters = buildQueryParameters(filterParameters, filter.ServiceId) if withCursor { filterParameters = append(filterParameters, cursor.Value) diff --git a/internal/database/mariadb/issue_repository_test.go b/internal/database/mariadb/issue_repository_test.go index d6ac4358..5bd2c4c5 100644 --- a/internal/database/mariadb/issue_repository_test.go +++ b/internal/database/mariadb/issue_repository_test.go @@ -187,7 +187,7 @@ var _ = Describe("IssueRepository", Label("database", "IssueRepository"), func() } } - filter := &entity.IssueRepositoryFilter{ServiceName: []*string{&sRow.Name.String}} + filter := &entity.IssueRepositoryFilter{ServiceCCRN: []*string{&sRow.CCRN.String}} entries, err := db.GetIssueRepositories(filter) @@ -326,7 +326,7 @@ var _ = Describe("IssueRepository", Label("database", "IssueRepository"), func() First: &pageSize, After: nil, }, - ServiceName: []*string{&sRow.Name.String}, + ServiceCCRN: []*string{&sRow.CCRN.String}, } entries, err := db.CountIssueRepositories(filter) By("throwing no error", func() { diff --git a/internal/database/mariadb/issue_test.go b/internal/database/mariadb/issue_test.go index 3ab3852f..cb2720da 100644 --- a/internal/database/mariadb/issue_test.go +++ b/internal/database/mariadb/issue_test.go @@ -173,7 +173,7 @@ var _ = Describe("Issue", Label("database", "Issue"), func() { issueRows = seedCollection.GetIssueByService(&row) searchingRow = len(issueRows) == 0 } - filter := &entity.IssueFilter{ServiceName: []*string{&row.Name.String}} + filter := &entity.IssueFilter{ServiceCCRN: []*string{&row.CCRN.String}} entries, err := db.GetIssues(filter) @@ -189,7 +189,7 @@ var _ = Describe("Issue", Label("database", "Issue"), func() { }) It("can filter a non existing service name", func() { nonExistingName := util.GenerateRandomString(40, nil) - filter := &entity.IssueFilter{ServiceName: []*string{&nonExistingName}} + filter := &entity.IssueFilter{ServiceCCRN: []*string{&nonExistingName}} entries, err := db.GetIssues(filter) @@ -201,15 +201,15 @@ var _ = Describe("Issue", Label("database", "Issue"), func() { }) }) It("can filter by multiple existing service names", func() { - serviceNames := make([]*string, len(seedCollection.ServiceRows)) + serviceCcrns := make([]*string, len(seedCollection.ServiceRows)) var expectedIssues []mariadb.IssueRow for i, row := range seedCollection.ServiceRows { - x := row.Name.String + x := row.CCRN.String expectedIssues = append(expectedIssues, seedCollection.GetIssueByService(&row)...) - serviceNames[i] = &x + serviceCcrns[i] = &x } expectedIssues = lo.Uniq(expectedIssues) - filter := &entity.IssueFilter{ServiceName: serviceNames} + filter := &entity.IssueFilter{ServiceCCRN: serviceCcrns} entries, err := db.GetIssues(filter) @@ -534,7 +534,7 @@ var _ = Describe("Issue", Label("database", "Issue"), func() { issueRows = seedCollection.GetIssueByService(&row) searchingRow = len(issueRows) > 0 } - filter := &entity.IssueFilter{ServiceName: []*string{&row.Name.String}} + filter := &entity.IssueFilter{ServiceCCRN: []*string{&row.CCRN.String}} count, err := db.CountIssues(filter) diff --git a/internal/database/mariadb/service.go b/internal/database/mariadb/service.go index b00eeb34..21ff8495 100644 --- a/internal/database/mariadb/service.go +++ b/internal/database/mariadb/service.go @@ -13,13 +13,13 @@ import ( ) const ( - serviceWildCardFilterQuery = "S.service_name LIKE Concat('%',?,'%')" + serviceWildCardFilterQuery = "S.service_ccrn LIKE Concat('%',?,'%')" ) func (s *SqlDatabase) buildServiceFilterParameters(filter *entity.ServiceFilter, withCursor bool, cursor entity.Cursor) []interface{} { var filterParameters []interface{} - filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupName) - filterParameters = buildQueryParameters(filterParameters, filter.Name) + filterParameters = buildQueryParameters(filterParameters, filter.SupportGroupCCRN) + filterParameters = buildQueryParameters(filterParameters, filter.CCRN) filterParameters = buildQueryParameters(filterParameters, filter.Id) filterParameters = buildQueryParameters(filterParameters, filter.OwnerName) filterParameters = buildQueryParameters(filterParameters, filter.ActivityId) @@ -37,9 +37,9 @@ func (s *SqlDatabase) buildServiceFilterParameters(filter *entity.ServiceFilter, func (s *SqlDatabase) getServiceFilterString(filter *entity.ServiceFilter) string { var fl []string - fl = append(fl, buildFilterQuery(filter.Name, "S.service_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.CCRN, "S.service_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.Id, "S.service_id = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.SupportGroupName, "SG.supportgroup_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.SupportGroupCCRN, "SG.supportgroup_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.OwnerName, "U.user_name = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ActivityId, "A.activity_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ComponentInstanceId, "CI.componentinstance_id = ?", OP_OR)) @@ -64,12 +64,12 @@ func (s *SqlDatabase) getServiceJoins(filter *entity.ServiceFilter) string { LEFT JOIN User U on U.user_id = O.owner_user_id `) } - if len(filter.SupportGroupName) > 0 || len(filter.SupportGroupId) > 0 { + if len(filter.SupportGroupCCRN) > 0 || len(filter.SupportGroupId) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN SupportGroupService SGS on S.service_id = SGS.supportgroupservice_service_id `) } - if len(filter.SupportGroupName) > 0 { + if len(filter.SupportGroupCCRN) > 0 { joins = fmt.Sprintf("%s\n%s", joins, ` LEFT JOIN SupportGroup SG on SG.supportgroup_id = SGS.supportgroupservice_support_group_id `) @@ -110,8 +110,8 @@ func (s *SqlDatabase) ensureServiceFilter(f *entity.ServiceFilter) *entity.Servi First: &first, After: &after, }, - SupportGroupName: nil, - Name: nil, + SupportGroupCCRN: nil, + CCRN: nil, Id: nil, OwnerName: nil, SupportGroupId: nil, @@ -131,8 +131,8 @@ func (s *SqlDatabase) ensureServiceFilter(f *entity.ServiceFilter) *entity.Servi func (s *SqlDatabase) getServiceUpdateFields(service *entity.Service) string { fl := []string{} - if service.Name != "" { - fl = append(fl, "service_name = :service_name") + if service.CCRN != "" { + fl = append(fl, "service_ccrn = :service_ccrn") } return strings.Join(fl, ", ") } @@ -341,9 +341,9 @@ func (s *SqlDatabase) CreateService(service *entity.Service) (*entity.Service, e query := ` INSERT INTO Service ( - service_name + service_ccrn ) VALUES ( - :service_name + :service_ccrn ) ` @@ -509,17 +509,17 @@ func (s *SqlDatabase) RemoveIssueRepositoryFromService(serviceId int64, issueRep return err } -func (s *SqlDatabase) GetServiceNames(filter *entity.ServiceFilter) ([]string, error) { +func (s *SqlDatabase) GetServiceCcrns(filter *entity.ServiceFilter) ([]string, error) { l := logrus.WithFields(logrus.Fields{ "filter": filter, - "event": "database.GetServiceNames", + "event": "database.GetServiceCcrns", }) baseQuery := ` - SELECT service_name FROM Service S + SELECT service_ccrn FROM Service S %s %s - ORDER BY S.service_name + ORDER BY S.service_ccrn ` // Ensure the filter is initialized @@ -542,19 +542,19 @@ func (s *SqlDatabase) GetServiceNames(filter *entity.ServiceFilter) ([]string, e defer rows.Close() // Collect the results - serviceNames := []string{} - var name string + serviceCcrns := []string{} + var ccrn string for rows.Next() { - if err := rows.Scan(&name); err != nil { + if err := rows.Scan(&ccrn); err != nil { l.Error("Error scanning row: ", err) continue } - serviceNames = append(serviceNames, name) + serviceCcrns = append(serviceCcrns, ccrn) } if err = rows.Err(); err != nil { l.Error("Row iteration error: ", err) return nil, err } - return serviceNames, nil + return serviceCcrns, nil } diff --git a/internal/database/mariadb/service_test.go b/internal/database/mariadb/service_test.go index a0662803..e160fa90 100644 --- a/internal/database/mariadb/service_test.go +++ b/internal/database/mariadb/service_test.go @@ -148,7 +148,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { for _, r := range res { for _, row := range seedCollection.ServiceRows { if r.Id == row.Id.Int64 { - Expect(r.Name).Should(BeEquivalentTo(row.Name.String), "Name should match") + Expect(r.CCRN).Should(BeEquivalentTo(row.CCRN.String), "Name should match") Expect(r.BaseService.CreatedAt).ShouldNot(BeEquivalentTo(row.CreatedAt.Time), "CreatedAt matches") Expect(r.BaseService.UpdatedAt).ShouldNot(BeEquivalentTo(row.UpdatedAt.Time), "UpdatedAt matches") } @@ -160,7 +160,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { Context("and using a filter", func() { It("can filter by a single name", func() { row := seedCollection.ServiceRows[rand.Intn(len(seedCollection.ServiceRows))] - filter := &entity.ServiceFilter{Name: []*string{&row.Name.String}} + filter := &entity.ServiceFilter{CCRN: []*string{&row.CCRN.String}} entries, err := db.GetServices(filter) @@ -172,13 +172,13 @@ var _ = Describe("Service", Label("database", "Service"), func() { }) By("returning entries include the service name", func() { for _, entry := range entries { - Expect(entry.Name).To(BeEquivalentTo(row.Name.String)) + Expect(entry.CCRN).To(BeEquivalentTo(row.CCRN.String)) } }) }) It("can filter by a random non existing service name", func() { nonExistingName := util.GenerateRandomString(40, nil) - filter := &entity.ServiceFilter{Name: []*string{&nonExistingName}} + filter := &entity.ServiceFilter{CCRN: []*string{&nonExistingName}} entries, err := db.GetServices(filter) @@ -190,12 +190,12 @@ var _ = Describe("Service", Label("database", "Service"), func() { }) }) It("can filter by all existing service names", func() { - serviceNames := make([]*string, len(seedCollection.ServiceRows)) + serviceCcrns := make([]*string, len(seedCollection.ServiceRows)) for i, row := range seedCollection.ServiceRows { - x := row.Name.String - serviceNames[i] = &x + x := row.CCRN.String + serviceCcrns[i] = &x } - filter := &entity.ServiceFilter{Name: serviceNames} + filter := &entity.ServiceFilter{CCRN: serviceCcrns} entries, err := db.GetServices(filter) @@ -233,7 +233,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { } } - filter := &entity.ServiceFilter{SupportGroupName: []*string{&sgRow.Name.String}} + filter := &entity.ServiceFilter{SupportGroupCCRN: []*string{&sgRow.CCRN.String}} entries, err := db.GetServices(filter) @@ -378,7 +378,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { } }) }) - It("can filter service ServiceName using wild card search", func() { + It("can filter service ServiceCcrn using wild card search", func() { row := seedCollection.ServiceRows[rand.Intn(len(seedCollection.ServiceRows))] const charactersToRemoveFromBeginning = 2 @@ -386,18 +386,18 @@ var _ = Describe("Service", Label("database", "Service"), func() { const minimalCharactersToKeep = 2 start := charactersToRemoveFromBeginning - end := len(row.Name.String) - charactersToRemoveFromEnd + end := len(row.CCRN.String) - charactersToRemoveFromEnd Expect(start+minimalCharactersToKeep < end).To(BeTrue()) - searchStr := row.Name.String[start:end] + searchStr := row.CCRN.String[start:end] filter := &entity.ServiceFilter{Search: []*string{&searchStr}} entries, err := db.GetServices(filter) names := []string{} for _, entry := range entries { - names = append(names, entry.Name) + names = append(names, entry.CCRN) } By("throwing no error", func() { @@ -409,7 +409,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { }) By("returning the expected elements", func() { - Expect(names).To(ContainElement(row.Name.String)) + Expect(names).To(ContainElement(row.CCRN.String)) }) }) }) @@ -568,7 +568,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { First: &pageSize, After: nil, }, - SupportGroupName: []*string{&sgRow.Name.String}, + SupportGroupCCRN: []*string{&sgRow.CCRN.String}, } entries, err := db.CountServices(filter) By("throwing no error", func() { @@ -619,7 +619,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { Expect(len(s)).To(BeEquivalentTo(1)) }) By("setting fields", func() { - Expect(s[0].Name).To(BeEquivalentTo(service.Name)) + Expect(s[0].CCRN).To(BeEquivalentTo(service.CCRN)) }) }) It("does not insert service with existing name", func() { @@ -646,7 +646,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { It("can update service name correctly", func() { service := seedCollection.ServiceRows[0].AsService() - service.Name = "SecretService" + service.CCRN = "SecretService" err := db.UpdateService(&service) By("throwing no error", func() { @@ -665,7 +665,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { Expect(len(s)).To(BeEquivalentTo(1)) }) By("setting fields", func() { - Expect(s[0].Name).To(BeEquivalentTo(service.Name)) + Expect(s[0].CCRN).To(BeEquivalentTo(service.CCRN)) }) }) }) @@ -830,10 +830,10 @@ var _ = Describe("Service", Label("database", "Service"), func() { }) }) }) - When("Getting ServiceNames", Label("GetServiceNames"), func() { + When("Getting ServiceCcrns", Label("GetServiceCcrns"), func() { Context("and the database is empty", func() { It("can perform the list query", func() { - res, err := db.GetServiceNames(nil) + res, err := db.GetServiceCcrns(nil) By("throwing no error", func() { Expect(err).To(BeNil()) }) @@ -850,7 +850,7 @@ var _ = Describe("Service", Label("database", "Service"), func() { Context("and using no filter", func() { It("can fetch the items correctly", func() { - res, err := db.GetServiceNames(nil) + res, err := db.GetServiceCcrns(nil) By("throwing no error", func() { Expect(err).Should(BeNil()) @@ -860,21 +860,21 @@ var _ = Describe("Service", Label("database", "Service"), func() { Expect(len(res)).Should(BeIdenticalTo(len(seedCollection.ServiceRows))) }) - existingServiceNames := lo.Map(seedCollection.ServiceRows, func(s mariadb.BaseServiceRow, index int) string { - return s.Name.String + existingServiceCcrns := lo.Map(seedCollection.ServiceRows, func(s mariadb.BaseServiceRow, index int) string { + return s.CCRN.String }) By("returning the correct names", func() { - left, right := lo.Difference(res, existingServiceNames) + left, right := lo.Difference(res, existingServiceCcrns) Expect(left).Should(BeEmpty()) Expect(right).Should(BeEmpty()) }) }) }) - Context("and using a ServiceName filter", func() { + Context("and using a ServiceCcrn filter", func() { var filter *entity.ServiceFilter - var expectedServiceNames []string + var expectedServiceCcrns []string BeforeEach(func() { namePointers := []*string{} @@ -882,22 +882,22 @@ var _ = Describe("Service", Label("database", "Service"), func() { namePointers = append(namePointers, &name) filter = &entity.ServiceFilter{ - Name: namePointers, + CCRN: namePointers, } It("can fetch the filtered items correctly", func() { - res, err := db.GetServiceNames(filter) + res, err := db.GetServiceCcrns(filter) By("throwing no error", func() { Expect(err).Should(BeNil()) }) By("returning the correct number of results", func() { - Expect(len(res)).Should(BeIdenticalTo(len(expectedServiceNames))) + Expect(len(res)).Should(BeIdenticalTo(len(expectedServiceCcrns))) }) By("returning the correct names", func() { - left, right := lo.Difference(res, expectedServiceNames) + left, right := lo.Difference(res, expectedServiceCcrns) Expect(left).Should(BeEmpty()) Expect(right).Should(BeEmpty()) }) @@ -907,16 +907,16 @@ var _ = Describe("Service", Label("database", "Service"), func() { var anotherFilter *entity.ServiceFilter BeforeEach(func() { - nonExistentServiceName := "NonexistentService" + nonExistentServiceCcrn := "NonexistentService" - nonExistentServiceNames := []*string{&nonExistentServiceName} + nonExistentServiceCcrns := []*string{&nonExistentServiceCcrn} anotherFilter = &entity.ServiceFilter{ - Name: nonExistentServiceNames, + CCRN: nonExistentServiceCcrns, } It("returns an empty list when no services match the filter", func() { - res, err := db.GetServiceNames(anotherFilter) + res, err := db.GetServiceCcrns(anotherFilter) Expect(err).Should(BeNil()) Expect(res).Should(BeEmpty()) diff --git a/internal/database/mariadb/support_group.go b/internal/database/mariadb/support_group.go index 67d21d46..f407af2e 100644 --- a/internal/database/mariadb/support_group.go +++ b/internal/database/mariadb/support_group.go @@ -16,7 +16,7 @@ func (s *SqlDatabase) getSupportGroupFilterString(filter *entity.SupportGroupFil var fl []string fl = append(fl, buildFilterQuery(filter.Id, "SG.supportgroup_id = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.ServiceId, "SGS.supportgroupservice_service_id = ?", OP_OR)) - fl = append(fl, buildFilterQuery(filter.Name, "SG.supportgroup_name = ?", OP_OR)) + fl = append(fl, buildFilterQuery(filter.CCRN, "SG.supportgroup_ccrn = ?", OP_OR)) fl = append(fl, buildFilterQuery(filter.UserId, "SGU.supportgroupuser_user_id = ?", OP_OR)) fl = append(fl, "SG.supportgroup_deleted_at IS NULL") @@ -25,8 +25,8 @@ func (s *SqlDatabase) getSupportGroupFilterString(filter *entity.SupportGroupFil func (s *SqlDatabase) getSupportGroupUpdateFields(supportGroup *entity.SupportGroup) string { fl := []string{} - if supportGroup.Name != "" { - fl = append(fl, "supportgroup_name = :supportgroup_name") + if supportGroup.CCRN != "" { + fl = append(fl, "supportgroup_ccrn = :supportgroup_ccrn") } return strings.Join(fl, ", ") @@ -59,7 +59,7 @@ func (s *SqlDatabase) ensureSupportGroupFilter(f *entity.SupportGroupFilter) *en Id: nil, ServiceId: nil, UserId: nil, - Name: nil, + CCRN: nil, } } if f.First == nil { @@ -112,7 +112,7 @@ func (s *SqlDatabase) buildSupportGroupStatement(baseQuery string, filter *entit var filterParameters []interface{} filterParameters = buildQueryParameters(filterParameters, filter.Id) filterParameters = buildQueryParameters(filterParameters, filter.ServiceId) - filterParameters = buildQueryParameters(filterParameters, filter.Name) + filterParameters = buildQueryParameters(filterParameters, filter.CCRN) filterParameters = buildQueryParameters(filterParameters, filter.UserId) if withCursor { filterParameters = append(filterParameters, cursor.Value) @@ -206,9 +206,9 @@ func (s *SqlDatabase) CreateSupportGroup(supportGroup *entity.SupportGroup) (*en query := ` INSERT INTO SupportGroup ( - supportgroup_name + supportgroup_ccrn ) VALUES ( - :supportgroup_name + :supportgroup_ccrn ) ` @@ -371,17 +371,17 @@ func (s *SqlDatabase) RemoveUserFromSupportGroup(supportGroupId int64, userId in return err } -func (s *SqlDatabase) GetSupportGroupNames(filter *entity.SupportGroupFilter) ([]string, error) { +func (s *SqlDatabase) GetSupportGroupCcrns(filter *entity.SupportGroupFilter) ([]string, error) { l := logrus.WithFields(logrus.Fields{ "filter": filter, - "event": "database.GetSupportGroupNames", + "event": "database.GetSupportGroupCcrns", }) baseQuery := ` - SELECT SG.supportgroup_name FROM SupportGroup SG + SELECT SG.supportgroup_ccrn FROM SupportGroup SG %s %s - ORDER BY SG.supportgroup_name + ORDER BY SG.supportgroup_ccrn ` // Ensure the filter is initialized @@ -404,19 +404,19 @@ func (s *SqlDatabase) GetSupportGroupNames(filter *entity.SupportGroupFilter) ([ defer rows.Close() // Collect the results - supportGroupNames := []string{} - var name string + supportGroupCcrns := []string{} + var ccrn string for rows.Next() { - if err := rows.Scan(&name); err != nil { + if err := rows.Scan(&ccrn); err != nil { l.Error("Error scanning row: ", err) continue } - supportGroupNames = append(supportGroupNames, name) + supportGroupCcrns = append(supportGroupCcrns, ccrn) } if err = rows.Err(); err != nil { l.Error("Row iteration error: ", err) return nil, err } - return supportGroupNames, nil + return supportGroupCcrns, nil } diff --git a/internal/database/mariadb/support_group_test.go b/internal/database/mariadb/support_group_test.go index fea82f0e..a94986ac 100644 --- a/internal/database/mariadb/support_group_test.go +++ b/internal/database/mariadb/support_group_test.go @@ -147,7 +147,7 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { for _, r := range res { for _, row := range seedCollection.SupportGroupRows { if r.Id == row.Id.Int64 { - Expect(r.Name).Should(BeEquivalentTo(row.Name.String), "Name matches") + Expect(r.CCRN).Should(BeEquivalentTo(row.CCRN.String), "CCRN matches") Expect(r.CreatedAt.Unix()).ShouldNot(BeEquivalentTo(row.CreatedAt.Time.Unix()), "CreatedAt got set") Expect(r.UpdatedAt.Unix()).ShouldNot(BeEquivalentTo(row.UpdatedAt.Time.Unix()), "UpdatedAt got set") } @@ -229,10 +229,10 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { } }) }) - It("can filter by a single support group name", func() { + It("can filter by a single support group ccrn", func() { row := seedCollection.SupportGroupRows[rand.Intn(len(seedCollection.SupportGroupRows))] - filter := &entity.SupportGroupFilter{Name: []*string{&row.Name.String}} + filter := &entity.SupportGroupFilter{CCRN: []*string{&row.CCRN.String}} entries, err := db.GetSupportGroups(filter) @@ -244,7 +244,7 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { }) By("returning expected number of results", func() { for _, entry := range entries { - Expect(entry.Name).To(BeEquivalentTo(row.Name.String)) + Expect(entry.CCRN).To(BeEquivalentTo(row.CCRN.String)) } }) }) @@ -340,7 +340,7 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { }) By("setting fields", func() { Expect(sg[0].Id).To(BeEquivalentTo(supportGroup.Id)) - Expect(sg[0].Name).To(BeEquivalentTo(supportGroup.Name)) + Expect(sg[0].CCRN).To(BeEquivalentTo(supportGroup.CCRN)) }) }) }) @@ -351,10 +351,10 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { BeforeEach(func() { seedCollection = seeder.SeedDbWithNFakeData(10) }) - It("can update name correctly", func() { + It("can update ccrn correctly", func() { supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() - supportGroup.Name = "Team Alone" + supportGroup.CCRN = "Team Alone" err := db.UpdateSupportGroup(&supportGroup) By("throwing no error", func() { @@ -374,7 +374,7 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { }) By("setting fields", func() { Expect(sg[0].Id).To(BeEquivalentTo(supportGroup.Id)) - Expect(sg[0].Name).To(BeEquivalentTo(supportGroup.Name)) + Expect(sg[0].CCRN).To(BeEquivalentTo(supportGroup.CCRN)) }) }) }) @@ -538,10 +538,10 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { }) }) }) - When("Getting SupportGroupNames", Label("GetSupportGroupNames"), func() { + When("Getting SupportGroupCcrns", Label("GetSupportGroupCcrns"), func() { Context("and the database is empty", func() { It("can perform the list query", func() { - res, err := db.GetSupportGroupNames(nil) + res, err := db.GetSupportGroupCcrns(nil) By("throwing no error", func() { Expect(err).To(BeNil()) }) @@ -558,7 +558,7 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { Context("and using no filter", func() { It("can fetch the items correctly", func() { - res, err := db.GetSupportGroupNames(nil) + res, err := db.GetSupportGroupCcrns(nil) By("throwing no error", func() { Expect(err).Should(BeNil()) @@ -568,44 +568,44 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { Expect(len(res)).Should(BeIdenticalTo(len(seedCollection.SupportGroupRows))) }) - existingSupportGroupNames := lo.Map(seedCollection.SupportGroupRows, func(s mariadb.SupportGroupRow, index int) string { - return s.Name.String + existingSupportGroupCcrns := lo.Map(seedCollection.SupportGroupRows, func(s mariadb.SupportGroupRow, index int) string { + return s.CCRN.String }) - By("returning the correct names", func() { - left, right := lo.Difference(res, existingSupportGroupNames) + By("returning the correct ccrns", func() { + left, right := lo.Difference(res, existingSupportGroupCcrns) Expect(left).Should(BeEmpty()) Expect(right).Should(BeEmpty()) }) }) }) - Context("and using a SupportGroupNames filter", func() { + Context("and using a SupportGroupCcrns filter", func() { var filter *entity.SupportGroupFilter - var expectedSupportGroupNames []string + var expectedSupportGroupCcrns []string BeforeEach(func() { - namePointers := []*string{} + ccrnPointers := []*string{} - name := "f1" - namePointers = append(namePointers, &name) + ccrn := "f1" + ccrnPointers = append(ccrnPointers, &ccrn) filter = &entity.SupportGroupFilter{ - Name: namePointers, + CCRN: ccrnPointers, } It("can fetch the filtered items correctly", func() { - res, err := db.GetSupportGroupNames(filter) + res, err := db.GetSupportGroupCcrns(filter) By("throwing no error", func() { Expect(err).Should(BeNil()) }) By("returning the correct number of results", func() { - Expect(len(res)).Should(BeIdenticalTo(len(expectedSupportGroupNames))) + Expect(len(res)).Should(BeIdenticalTo(len(expectedSupportGroupCcrns))) }) - By("returning the correct names", func() { - left, right := lo.Difference(res, expectedSupportGroupNames) + By("returning the correct ccrns", func() { + left, right := lo.Difference(res, expectedSupportGroupCcrns) Expect(left).Should(BeEmpty()) Expect(right).Should(BeEmpty()) }) @@ -615,16 +615,16 @@ var _ = Describe("SupportGroup", Label("database", "SupportGroup"), func() { var anotherFilter *entity.SupportGroupFilter BeforeEach(func() { - nonExistentSupportGroupName := "NonexistentService" + nonExistentSupportGroupCcrn := "NonexistentService" - nonExistentSupportGroupNames := []*string{&nonExistentSupportGroupName} + nonExistentSupportGroupCcrns := []*string{&nonExistentSupportGroupCcrn} anotherFilter = &entity.SupportGroupFilter{ - Name: nonExistentSupportGroupNames, + CCRN: nonExistentSupportGroupCcrns, } It("returns an empty list when no supportGroup match the filter", func() { - res, err := db.GetSupportGroupNames(anotherFilter) + res, err := db.GetSupportGroupCcrns(anotherFilter) Expect(err).Should(BeNil()) Expect(res).Should(BeEmpty()) diff --git a/internal/database/mariadb/test/fixture.go b/internal/database/mariadb/test/fixture.go index bb7beff6..e4e36ef3 100644 --- a/internal/database/mariadb/test/fixture.go +++ b/internal/database/mariadb/test/fixture.go @@ -908,9 +908,9 @@ func (s *DatabaseSeeder) InsertFakeComponentInstance(ci mariadb.ComponentInstanc func (s *DatabaseSeeder) InsertFakeBaseService(service mariadb.BaseServiceRow) (int64, error) { query := ` INSERT INTO Service ( - service_name + service_ccrn ) VALUES ( - :service_name + :service_ccrn )` return s.ExecPreparedNamed(query, service) } @@ -918,9 +918,9 @@ func (s *DatabaseSeeder) InsertFakeBaseService(service mariadb.BaseServiceRow) ( func (s *DatabaseSeeder) InsertFakeSupportGroup(sg mariadb.SupportGroupRow) (int64, error) { query := ` INSERT INTO SupportGroup ( - supportgroup_name + supportgroup_ccrn ) VALUES ( - :supportgroup_name + :supportgroup_ccrn )` return s.ExecPreparedNamed(query, sg) } @@ -928,9 +928,9 @@ func (s *DatabaseSeeder) InsertFakeSupportGroup(sg mariadb.SupportGroupRow) (int func (s *DatabaseSeeder) InsertFakeComponent(component mariadb.ComponentRow) (int64, error) { query := ` INSERT INTO Component ( - component_name, component_type + component_ccrn, component_type ) VALUES ( - :component_name, + :component_ccrn, :component_type )` return s.ExecPreparedNamed(query, component) @@ -1166,7 +1166,7 @@ func NewFakeIssueRepository() mariadb.IssueRepositoryRow { func NewFakeBaseService() mariadb.BaseServiceRow { return mariadb.BaseServiceRow{ - Name: sql.NullString{String: fmt.Sprintf("%s-%s", gofakeit.AppName(), gofakeit.UUID()), Valid: true}, + CCRN: sql.NullString{String: fmt.Sprintf("%s-%s", gofakeit.AppName(), gofakeit.UUID()), Valid: true}, } } @@ -1181,15 +1181,15 @@ func NewFakeService() mariadb.ServiceRow { func NewFakeSupportGroup() mariadb.SupportGroupRow { return mariadb.SupportGroupRow{ - Name: sql.NullString{String: fmt.Sprintf("%s-%s", gofakeit.AppName(), gofakeit.UUID()), Valid: true}, + CCRN: sql.NullString{String: fmt.Sprintf("%s-%s", gofakeit.AppName(), gofakeit.UUID()), Valid: true}, } } func NewFakeComponent() mariadb.ComponentRow { types := []string{"containerImage", "virtualMachineImage", "repository"} - name := fmt.Sprintf("%s-%d", gofakeit.AppName(), gofakeit.UUID()) + ccrn := fmt.Sprintf("%s-%d", gofakeit.AppName(), gofakeit.UUID()) return mariadb.ComponentRow{ - Name: sql.NullString{String: name, Valid: true}, + CCRN: sql.NullString{String: ccrn, Valid: true}, Type: sql.NullString{String: gofakeit.RandomString(types), Valid: true}, } } @@ -1318,7 +1318,7 @@ func (s *DatabaseSeeder) SeedRealSupportGroups() map[string]mariadb.SupportGroup for _, sg := range sgs { supportGroup := mariadb.SupportGroupRow{ - Name: sql.NullString{String: sg, Valid: true}, + CCRN: sql.NullString{String: sg, Valid: true}, } supportGroupId, err := s.InsertFakeSupportGroup(supportGroup) if err != nil { @@ -1394,7 +1394,7 @@ func (s *DatabaseSeeder) SeedRealServices() map[string]mariadb.BaseServiceRow { for _, sv := range svs { service := mariadb.BaseServiceRow{ - Name: sql.NullString{String: sv, Valid: true}, + CCRN: sql.NullString{String: sv, Valid: true}, } serviceId, err := s.InsertFakeBaseService(service) if err != nil { diff --git a/internal/e2e/activity_query_test.go b/internal/e2e/activity_query_test.go index aa42f507..3afd9465 100644 --- a/internal/e2e/activity_query_test.go +++ b/internal/e2e/activity_query_test.go @@ -159,7 +159,7 @@ var _ = Describe("Getting Activities via API", Label("e2e", "Activity"), func() } for _, s := range activity.Node.Services.Edges { Expect(s.Node.ID).ToNot(BeEmpty()) - Expect(*s.Node.Name).ToNot(BeEmpty()) + Expect(*s.Node.Ccrn).ToNot(BeEmpty()) } for _, e := range activity.Node.Evidences.Edges { Expect(e.Node.ID).ToNot(BeEmpty()) diff --git a/internal/e2e/component_filter_query_test.go b/internal/e2e/component_filter_query_test.go index 2d55f883..4d7b239b 100644 --- a/internal/e2e/component_filter_query_test.go +++ b/internal/e2e/component_filter_query_test.go @@ -46,10 +46,10 @@ var _ = Describe("Getting ComponentFilterValues via API", Label("e2e", "Componen }) When("the database is empty", func() { - It("returns empty for componentNames", func() { + It("returns empty for componentCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentFilter/componentName.graphqls") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentFilter/componentCcrn.graphqls") Expect(err).To(BeNil()) str := string(b) @@ -65,7 +65,7 @@ var _ = Describe("Getting ComponentFilterValues via API", Label("e2e", "Componen logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(respData.ComponentFilterValues.ComponentName.Values).To(BeEmpty()) + Expect(respData.ComponentFilterValues.ComponentCcrn.Values).To(BeEmpty()) }) }) @@ -76,10 +76,10 @@ var _ = Describe("Getting ComponentFilterValues via API", Label("e2e", "Componen seedCollection = seeder.SeedDbWithNFakeData(10) }) Context("and no additional filters are present", func() { - It("returns correct componentNames", func() { + It("returns correct componentCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentFilter/componentName.graphqls") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentFilter/componentCcrn.graphqls") Expect(err).To(BeNil()) str := string(b) @@ -95,14 +95,14 @@ var _ = Describe("Getting ComponentFilterValues via API", Label("e2e", "Componen logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(len(respData.ComponentFilterValues.ComponentName.Values)).To(Equal(len(seedCollection.ComponentRows))) + Expect(len(respData.ComponentFilterValues.ComponentCcrn.Values)).To(Equal(len(seedCollection.ComponentRows))) - existingComponentNames := lo.Map(seedCollection.ComponentRows, func(s mariadb.ComponentRow, index int) string { - return s.Name.String + existingComponentCcrns := lo.Map(seedCollection.ComponentRows, func(s mariadb.ComponentRow, index int) string { + return s.CCRN.String }) - for _, name := range respData.ComponentFilterValues.ComponentName.Values { - Expect(lo.Contains(existingComponentNames, *name)).To(BeTrue()) + for _, ccrn := range respData.ComponentFilterValues.ComponentCcrn.Values { + Expect(lo.Contains(existingComponentCcrns, *ccrn)).To(BeTrue()) } }) }) diff --git a/internal/e2e/component_instance_filter_test.go b/internal/e2e/component_instance_filter_test.go index e123e247..7e6c38fb 100644 --- a/internal/e2e/component_instance_filter_test.go +++ b/internal/e2e/component_instance_filter_test.go @@ -69,10 +69,10 @@ var _ = Describe("Getting ComponentInstanceFilterValues via API", Label("e2e", " Expect(respData.ComponentInstanceFilterValues.Ccrn.Values).To(BeEmpty()) }) - It("returns empty for serviceNames", func() { + It("returns empty for serviceCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/serviceName.graphqls") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/serviceCcrn.graphqls") Expect(err).To(BeNil()) str := string(b) @@ -88,12 +88,12 @@ var _ = Describe("Getting ComponentInstanceFilterValues via API", Label("e2e", " logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(respData.ComponentInstanceFilterValues.ServiceName.Values).To(BeEmpty()) + Expect(respData.ComponentInstanceFilterValues.ServiceCcrn.Values).To(BeEmpty()) }) - It("returns empty for supportGroupName", func() { + It("returns empty for supportGroupCcrn", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupName.graphqls") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupCcrn.graphqls") Expect(err).To(BeNil()) str := string(b) @@ -109,7 +109,7 @@ var _ = Describe("Getting ComponentInstanceFilterValues via API", Label("e2e", " logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(respData.ComponentInstanceFilterValues.SupportGroupName.Values).To(BeEmpty()) + Expect(respData.ComponentInstanceFilterValues.SupportGroupCcrn.Values).To(BeEmpty()) }) }) @@ -149,10 +149,10 @@ var _ = Describe("Getting ComponentInstanceFilterValues via API", Label("e2e", " Expect(lo.Contains(existingCcrn, *name)).To(BeTrue()) } }) - It("returns correct supportGroupNames", func() { + It("returns correct supportGroupCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupName.graphqls") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/supportGroupCcrn.graphqls") Expect(err).To(BeNil()) str := string(b) @@ -168,20 +168,20 @@ var _ = Describe("Getting ComponentInstanceFilterValues via API", Label("e2e", " logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(len(respData.ComponentInstanceFilterValues.SupportGroupName.Values)).To(Equal(len(seedCollection.SupportGroupRows))) + Expect(len(respData.ComponentInstanceFilterValues.SupportGroupCcrn.Values)).To(Equal(len(seedCollection.SupportGroupRows))) - existingSupportGroupNames := lo.Map(seedCollection.SupportGroupRows, func(s mariadb.SupportGroupRow, index int) string { - return s.Name.String + existingSupportGroupCcrns := lo.Map(seedCollection.SupportGroupRows, func(s mariadb.SupportGroupRow, index int) string { + return s.CCRN.String }) - for _, name := range respData.ComponentInstanceFilterValues.SupportGroupName.Values { - Expect(lo.Contains(existingSupportGroupNames, *name)).To(BeTrue()) + for _, ccrn := range respData.ComponentInstanceFilterValues.SupportGroupCcrn.Values { + Expect(lo.Contains(existingSupportGroupCcrns, *ccrn)).To(BeTrue()) } }) - It("returns correct serviceNames", func() { + It("returns correct serviceCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/serviceName.graphqls") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/componentInstanceFilter/serviceCcrn.graphqls") Expect(err).To(BeNil()) str := string(b) @@ -197,14 +197,14 @@ var _ = Describe("Getting ComponentInstanceFilterValues via API", Label("e2e", " logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(len(respData.ComponentInstanceFilterValues.ServiceName.Values)).To(Equal(len(seedCollection.ServiceRows))) + Expect(len(respData.ComponentInstanceFilterValues.ServiceCcrn.Values)).To(Equal(len(seedCollection.ServiceRows))) - existingServiceNames := lo.Map(seedCollection.ServiceRows, func(s mariadb.BaseServiceRow, index int) string { - return s.Name.String + existingServiceCcrns := lo.Map(seedCollection.ServiceRows, func(s mariadb.BaseServiceRow, index int) string { + return s.CCRN.String }) - for _, name := range respData.ComponentInstanceFilterValues.ServiceName.Values { - Expect(lo.Contains(existingServiceNames, *name)).To(BeTrue()) + for _, ccrn := range respData.ComponentInstanceFilterValues.ServiceCcrn.Values { + Expect(lo.Contains(existingServiceCcrns, *ccrn)).To(BeTrue()) } }) }) diff --git a/internal/e2e/component_instance_query_test.go b/internal/e2e/component_instance_query_test.go index b7344aa3..848dee01 100644 --- a/internal/e2e/component_instance_query_test.go +++ b/internal/e2e/component_instance_query_test.go @@ -169,7 +169,7 @@ var _ = Describe("Getting ComponentInstances via API", Label("e2e", "ComponentIn service := ci.Node.Service Expect(service.ID).ToNot(BeNil(), "service has a ID set") - Expect(service.Name).ToNot(BeNil(), "service has a name set") + Expect(service.Ccrn).ToNot(BeNil(), "service has a name set") _, serviceFound := lo.Find(seedCollection.ServiceRows, func(row mariadb.BaseServiceRow) bool { return fmt.Sprintf("%d", row.Id.Int64) == service.ID diff --git a/internal/e2e/component_query_test.go b/internal/e2e/component_query_test.go index 431fab88..6a1ff71f 100644 --- a/internal/e2e/component_query_test.go +++ b/internal/e2e/component_query_test.go @@ -226,7 +226,7 @@ var _ = Describe("Creating Component via API", Label("e2e", "Components"), func( req.Var("input", map[string]string{ "type": component.Type, - "name": component.Name, + "ccrn": component.CCRN, }) req.Header.Set("Cache-Control", "no-cache") @@ -239,7 +239,7 @@ var _ = Describe("Creating Component via API", Label("e2e", "Components"), func( logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(*respData.Component.Name).To(Equal(component.Name)) + Expect(*respData.Component.Ccrn).To(Equal(component.CCRN)) Expect(respData.Component.Type.String()).To(Equal(component.Type)) }) }) @@ -289,11 +289,11 @@ var _ = Describe("Updating Component via API", Label("e2e", "Components"), func( req := graphql.NewRequest(str) component := seedCollection.ComponentRows[0].AsComponent() - component.Name = "NewName" + component.CCRN = "NewCCRN" req.Var("id", fmt.Sprintf("%d", component.Id)) req.Var("input", map[string]string{ - "name": component.Name, + "ccrn": component.CCRN, }) req.Header.Set("Cache-Control", "no-cache") @@ -306,7 +306,7 @@ var _ = Describe("Updating Component via API", Label("e2e", "Components"), func( logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(*respData.Component.Name).To(Equal(component.Name)) + Expect(*respData.Component.Ccrn).To(Equal(component.CCRN)) }) }) }) diff --git a/internal/e2e/component_version_query_test.go b/internal/e2e/component_version_query_test.go index 44577805..b59e73e0 100644 --- a/internal/e2e/component_version_query_test.go +++ b/internal/e2e/component_version_query_test.go @@ -173,7 +173,7 @@ var _ = Describe("Getting ComponentVersions via API", Label("e2e", "ComponentVer if cv.Node.Component != nil { Expect(cv.Node.Component.ID).ToNot(BeNil(), "component has a ID set") - Expect(cv.Node.Component.Name).ToNot(BeNil(), "component has a name set") + Expect(cv.Node.Component.Ccrn).ToNot(BeNil(), "component has a ccrn set") Expect(cv.Node.Component.Type).ToNot(BeNil(), "component has a type set") } } diff --git a/internal/e2e/issue_repository_query_test.go b/internal/e2e/issue_repository_query_test.go index 5a5c6a9e..7a424b25 100644 --- a/internal/e2e/issue_repository_query_test.go +++ b/internal/e2e/issue_repository_query_test.go @@ -172,7 +172,7 @@ var _ = Describe("Getting IssueRepositories via API", Label("e2e", "IssueReposit for _, service := range ir.Node.Services.Edges { Expect(service.Node.ID).ToNot(BeNil(), "Service has a ID set") - Expect(service.Node.Name).ToNot(BeNil(), "Service has a name set") + Expect(service.Node.Ccrn).ToNot(BeNil(), "Service has a name set") Expect(service.Priority).ToNot(BeNil(), "Service has a priority set") _, serviceFound := lo.Find(seedCollection.IssueRepositoryServiceRows, func(row mariadb.IssueRepositoryServiceRow) bool { diff --git a/internal/e2e/service_filter_query_test.go b/internal/e2e/service_filter_query_test.go index 7c513f97..73ca78a9 100644 --- a/internal/e2e/service_filter_query_test.go +++ b/internal/e2e/service_filter_query_test.go @@ -51,7 +51,7 @@ var _ = Describe("Getting ServiceFilterValues via API", Label("e2e", "ServiceFil client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) //@todo may need to make this more fault proof?! What if the test is executed from the root dir? does it still work? - b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/serviceNames.graphql") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/serviceCcrns.graphql") Expect(err).To(BeNil()) str := string(b) @@ -67,12 +67,12 @@ var _ = Describe("Getting ServiceFilterValues via API", Label("e2e", "ServiceFil logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(respData.ServiceFilterValues.ServiceName.Values).To(BeEmpty()) + Expect(respData.ServiceFilterValues.ServiceCcrn.Values).To(BeEmpty()) }) - It("returns empty for supportGroupNames", func() { + It("returns empty for supportGroupCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/supportGroupNames.graphql") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/supportGroupCcrns.graphql") Expect(err).To(BeNil()) str := string(b) @@ -88,7 +88,7 @@ var _ = Describe("Getting ServiceFilterValues via API", Label("e2e", "ServiceFil logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(respData.ServiceFilterValues.SupportGroupName.Values).To(BeEmpty()) + Expect(respData.ServiceFilterValues.SupportGroupCcrn.Values).To(BeEmpty()) }) It("returns empty for userNames", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) @@ -141,10 +141,10 @@ var _ = Describe("Getting ServiceFilterValues via API", Label("e2e", "ServiceFil seedCollection = seeder.SeedDbWithNFakeData(10) }) Context("and no additional filters are present", func() { - It("returns correct serviceNames", func() { + It("returns correct serviceCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/serviceNames.graphql") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/serviceCcrns.graphql") Expect(err).To(BeNil()) str := string(b) @@ -160,20 +160,20 @@ var _ = Describe("Getting ServiceFilterValues via API", Label("e2e", "ServiceFil logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(len(respData.ServiceFilterValues.ServiceName.Values)).To(Equal(len(seedCollection.ServiceRows))) + Expect(len(respData.ServiceFilterValues.ServiceCcrn.Values)).To(Equal(len(seedCollection.ServiceRows))) - existingServiceNames := lo.Map(seedCollection.ServiceRows, func(s mariadb.BaseServiceRow, index int) string { - return s.Name.String + existingServiceCcrns := lo.Map(seedCollection.ServiceRows, func(s mariadb.BaseServiceRow, index int) string { + return s.CCRN.String }) - for _, name := range respData.ServiceFilterValues.ServiceName.Values { - Expect(lo.Contains(existingServiceNames, *name)).To(BeTrue()) + for _, ccrn := range respData.ServiceFilterValues.ServiceCcrn.Values { + Expect(lo.Contains(existingServiceCcrns, *ccrn)).To(BeTrue()) } }) - It("returns correct supportGroupNames", func() { + It("returns correct supportGroupCcrns", func() { client := graphql.NewClient(fmt.Sprintf("http://localhost:%s/query", cfg.Port)) - b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/supportGroupNames.graphql") + b, err := os.ReadFile("../api/graphql/graph/queryCollection/serviceFilter/supportGroupCcrns.graphql") Expect(err).To(BeNil()) str := string(b) @@ -189,14 +189,14 @@ var _ = Describe("Getting ServiceFilterValues via API", Label("e2e", "ServiceFil logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(len(respData.ServiceFilterValues.SupportGroupName.Values)).To(Equal(len(seedCollection.SupportGroupRows))) + Expect(len(respData.ServiceFilterValues.SupportGroupCcrn.Values)).To(Equal(len(seedCollection.SupportGroupRows))) - existingSupportGroupNames := lo.Map(seedCollection.SupportGroupRows, func(s mariadb.SupportGroupRow, index int) string { - return s.Name.String + existingsupportGroupCcrns := lo.Map(seedCollection.SupportGroupRows, func(s mariadb.SupportGroupRow, index int) string { + return s.CCRN.String }) - for _, name := range respData.ServiceFilterValues.SupportGroupName.Values { - Expect(lo.Contains(existingSupportGroupNames, *name)).To(BeTrue()) + for _, ccrn := range respData.ServiceFilterValues.SupportGroupCcrn.Values { + Expect(lo.Contains(existingsupportGroupCcrns, *ccrn)).To(BeTrue()) } }) It("returns correct userNames", func() { diff --git a/internal/e2e/service_query_test.go b/internal/e2e/service_query_test.go index 2af44899..b7b46656 100644 --- a/internal/e2e/service_query_test.go +++ b/internal/e2e/service_query_test.go @@ -207,7 +207,7 @@ var _ = Describe("Getting Services via API", Label("e2e", "Services"), func() { for _, sg := range service.Node.SupportGroups.Edges { Expect(sg.Node.ID).ToNot(BeNil(), "supportGroup has a ID set") - Expect(sg.Node.Name).ToNot(BeNil(), "supportGroup has a name set") + Expect(sg.Node.Ccrn).ToNot(BeNil(), "supportGroup has a ccrn set") _, sgFound := lo.Find(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow) bool { return fmt.Sprintf("%d", row.SupportGroupId.Int64) == sg.Node.ID && // correct sg @@ -308,7 +308,7 @@ var _ = Describe("Creating Service via API", Label("e2e", "Services"), func() { req := graphql.NewRequest(str) req.Var("input", map[string]string{ - "name": service.Name, + "ccrn": service.CCRN, }) req.Header.Set("Cache-Control", "no-cache") @@ -321,7 +321,7 @@ var _ = Describe("Creating Service via API", Label("e2e", "Services"), func() { logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(*respData.Service.Name).To(Equal(service.Name)) + Expect(*respData.Service.Ccrn).To(Equal(service.CCRN)) }) }) }) @@ -370,11 +370,11 @@ var _ = Describe("Updating service via API", Label("e2e", "Services"), func() { req := graphql.NewRequest(str) service := seedCollection.ServiceRows[0].AsService() - service.Name = "SecretService" + service.CCRN = "SecretService" req.Var("id", fmt.Sprintf("%d", service.Id)) req.Var("input", map[string]string{ - "name": service.Name, + "ccrn": service.CCRN, }) req.Header.Set("Cache-Control", "no-cache") @@ -387,7 +387,7 @@ var _ = Describe("Updating service via API", Label("e2e", "Services"), func() { logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(*respData.Service.Name).To(Equal(service.Name)) + Expect(*respData.Service.Ccrn).To(Equal(service.CCRN)) }) }) }) diff --git a/internal/e2e/support_group_query_test.go b/internal/e2e/support_group_query_test.go index 399b8a25..20cf2d34 100644 --- a/internal/e2e/support_group_query_test.go +++ b/internal/e2e/support_group_query_test.go @@ -174,11 +174,11 @@ var _ = Describe("Getting SupportGroups via API", Label("e2e", "SupportGroups"), for _, sg := range respData.SupportGroups.Edges { Expect(sg.Node.ID).ToNot(BeNil(), "supportGroup has a ID set") - Expect(sg.Node.Name).ToNot(BeNil(), "supportGroup has a name set") + Expect(sg.Node.Ccrn).ToNot(BeNil(), "supportGroup has a ccrn set") for _, service := range sg.Node.Services.Edges { Expect(service.Node.ID).ToNot(BeNil(), "Service has a ID set") - Expect(service.Node.Name).ToNot(BeNil(), "Service has a name set") + Expect(service.Node.Ccrn).ToNot(BeNil(), "Service has a ccrn set") _, serviceFound := lo.Find(seedCollection.SupportGroupServiceRows, func(row mariadb.SupportGroupServiceRow) bool { return fmt.Sprintf("%d", row.SupportGroupId.Int64) == sg.Node.ID && // correct support group @@ -258,7 +258,7 @@ var _ = Describe("Creating SupportGroup via API", Label("e2e", "SupportGroups"), req := graphql.NewRequest(str) req.Var("input", map[string]string{ - "name": supportGroup.Name, + "ccrn": supportGroup.CCRN, }) req.Header.Set("Cache-Control", "no-cache") @@ -271,7 +271,7 @@ var _ = Describe("Creating SupportGroup via API", Label("e2e", "SupportGroups"), logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(*respData.SupportGroup.Name).To(Equal(supportGroup.Name)) + Expect(*respData.SupportGroup.Ccrn).To(Equal(supportGroup.CCRN)) }) }) }) @@ -320,11 +320,11 @@ var _ = Describe("Updating SupportGroup via API", Label("e2e", "SupportGroups"), req := graphql.NewRequest(str) supportGroup := seedCollection.SupportGroupRows[0].AsSupportGroup() - supportGroup.Name = "Team Alone" + supportGroup.CCRN = "Team Alone" req.Var("id", fmt.Sprintf("%d", supportGroup.Id)) req.Var("input", map[string]string{ - "name": supportGroup.Name, + "ccrn": supportGroup.CCRN, }) req.Header.Set("Cache-Control", "no-cache") @@ -337,7 +337,7 @@ var _ = Describe("Updating SupportGroup via API", Label("e2e", "SupportGroups"), logrus.WithError(err).WithField("request", req).Fatalln("Error while unmarshaling") } - Expect(*respData.SupportGroup.Name).To(Equal(supportGroup.Name)) + Expect(*respData.SupportGroup.Ccrn).To(Equal(supportGroup.CCRN)) }) }) }) diff --git a/internal/e2e/user_query_test.go b/internal/e2e/user_query_test.go index d57ab0ad..f32fe6c5 100644 --- a/internal/e2e/user_query_test.go +++ b/internal/e2e/user_query_test.go @@ -162,7 +162,7 @@ var _ = Describe("Getting Users via API", Label("e2e", "Users"), func() { for _, service := range user.Node.Services.Edges { Expect(service.Node.ID).ToNot(BeNil(), "Service has a ID set") - Expect(service.Node.Name).ToNot(BeNil(), "Service has a name set") + Expect(service.Node.Ccrn).ToNot(BeNil(), "Service has a name set") _, serviceFound := lo.Find(seedCollection.OwnerRows, func(row mariadb.OwnerRow) bool { return fmt.Sprintf("%d", row.UserId.Int64) == user.Node.ID && // correct user @@ -173,7 +173,7 @@ var _ = Describe("Getting Users via API", Label("e2e", "Users"), func() { for _, sg := range user.Node.SupportGroups.Edges { Expect(sg.Node.ID).ToNot(BeNil(), "supportGroup has a ID set") - Expect(sg.Node.Name).ToNot(BeNil(), "supportGroup has a name set") + Expect(sg.Node.Ccrn).ToNot(BeNil(), "supportGroup has a ccrn set") _, sgFound := lo.Find(seedCollection.SupportGroupUserRows, func(row mariadb.SupportGroupUserRow) bool { return fmt.Sprintf("%d", row.SupportGroupId.Int64) == sg.Node.ID && // correct support group diff --git a/internal/entity/activity.go b/internal/entity/activity.go index d5a4e4a6..4769e363 100644 --- a/internal/entity/activity.go +++ b/internal/entity/activity.go @@ -64,7 +64,7 @@ type ActivityAggregations struct { type ActivityFilter struct { Paginated Status []*string `json:"status"` - ServiceName []*string `json:"service_name"` + ServiceCCRN []*string `json:"service_ccrn"` Id []*int64 `json:"id"` ServiceId []*int64 `json:"service_id"` IssueId []*int64 `json:"issue_id"` diff --git a/internal/entity/component.go b/internal/entity/component.go index 28204808..45eff250 100644 --- a/internal/entity/component.go +++ b/internal/entity/component.go @@ -7,7 +7,7 @@ import "time" type Component struct { Id int64 `json:"id"` - Name string `json:"name"` + CCRN string `json:"ccrn"` Type string `json:"type"` CreatedAt time.Time `json:"created_at"` DeletedAt time.Time `json:"deleted_at,omitempty"` @@ -22,7 +22,7 @@ type ComponentResult struct { type ComponentFilter struct { Paginated - Name []*string `json:"name"` + CCRN []*string `json:"ccrn"` Id []*int64 `json:"id"` ComponentVersionId []*int64 `json:"component_version_id"` } diff --git a/internal/entity/component_version.go b/internal/entity/component_version.go index 2d23e336..6ea5d88b 100644 --- a/internal/entity/component_version.go +++ b/internal/entity/component_version.go @@ -9,7 +9,7 @@ type ComponentVersionFilter struct { Paginated Id []*int64 `json:"id"` IssueId []*int64 `json:"issue_id"` - ComponentName []*string `json:"component_name"` + ComponentCCRN []*string `json:"component_ccrn"` ComponentId []*int64 `json:"component_id"` Version []*string `json:"version"` } diff --git a/internal/entity/issue.go b/internal/entity/issue.go index 84478240..95ecb1ef 100644 --- a/internal/entity/issue.go +++ b/internal/entity/issue.go @@ -52,7 +52,7 @@ type IssueResult struct { type IssueFilter struct { Paginated PrimaryName []*string `json:"primary_name"` - ServiceName []*string `json:"service_name"` + ServiceCCRN []*string `json:"service_ccrn"` Type []*string `json:"type"` Id []*int64 `json:"id"` ActivityId []*int64 `json:"activity_id"` diff --git a/internal/entity/issue_match.go b/internal/entity/issue_match.go index d79c8a83..fbd0ea7e 100644 --- a/internal/entity/issue_match.go +++ b/internal/entity/issue_match.go @@ -59,15 +59,15 @@ type IssueMatch struct { type IssueMatchFilter struct { Paginated Id []*int64 `json:"id"` - AffectedServiceName []*string `json:"affected_service_name"` + AffectedServiceCCRN []*string `json:"affected_service_ccrn"` SeverityValue []*string `json:"severity_value"` Status []*string `json:"status"` IssueId []*int64 `json:"issue_id"` EvidenceId []*int64 `json:"evidence_id"` ComponentInstanceId []*int64 `json:"component_instance_id"` - SupportGroupName []*string `json:"support_group_name"` + SupportGroupCCRN []*string `json:"support_group_ccrn"` Search []*string `json:"search"` - ComponentName []*string `json:"component_name"` + ComponentCCRN []*string `json:"component_ccrn"` PrimaryName []*string `json:"primary_name"` IssueType []*string `json:"issue_type"` } diff --git a/internal/entity/issue_repository.go b/internal/entity/issue_repository.go index 0be984f5..75013371 100644 --- a/internal/entity/issue_repository.go +++ b/internal/entity/issue_repository.go @@ -21,7 +21,7 @@ type IssueRepositoryFilter struct { Id []*int64 `json:"id"` ServiceId []*int64 `json:"service_id"` Name []*string `json:"name"` - ServiceName []*string `json:"service_name"` + ServiceCCRN []*string `json:"service_ccrn"` } func NewIssueRepositoryFilter() *IssueRepositoryFilter { @@ -33,7 +33,7 @@ func NewIssueRepositoryFilter() *IssueRepositoryFilter { Id: nil, ServiceId: nil, Name: nil, - ServiceName: nil, + ServiceCCRN: nil, } } diff --git a/internal/entity/service.go b/internal/entity/service.go index 80785cdc..bd034086 100644 --- a/internal/entity/service.go +++ b/internal/entity/service.go @@ -7,7 +7,7 @@ import "time" type BaseService struct { Id int64 `json:"id"` - Name string `json:"name"` + CCRN string `json:"ccrn"` SupportGroup *SupportGroup `json:"support_group,omitempty"` SupportGroupId int64 `db:"service_support_group_id"` Owners []User `json:"owners,omitempty"` @@ -30,9 +30,9 @@ type ServiceWithAggregations struct { type ServiceFilter struct { Paginated - SupportGroupName []*string `json:"support_group_name"` + SupportGroupCCRN []*string `json:"support_group_ccrn"` Id []*int64 `json:"id"` - Name []*string `json:"name"` + CCRN []*string `json:"ccrn"` OwnerName []*string `json:"owner_name"` OwnerId []*int64 `json:"owner_id"` ActivityId []*int64 `json:"activity_id"` diff --git a/internal/entity/support_group.go b/internal/entity/support_group.go index ca280db0..75259174 100644 --- a/internal/entity/support_group.go +++ b/internal/entity/support_group.go @@ -7,7 +7,7 @@ import "time" type SupportGroup struct { Id int64 `json:"id"` - Name string `json:"name"` + CCRN string `json:"ccrn"` CreatedAt time.Time `json:"created_at"` DeletedAt time.Time `json:"deleted_at,omitempty"` UpdatedAt time.Time `json:"updated_at"` @@ -18,7 +18,7 @@ type SupportGroupFilter struct { Id []*int64 `json:"id"` ServiceId []*int64 `json:"service_id"` UserId []*int64 `json:"user_id"` - Name []*string `json:"name"` + CCRN []*string `json:"ccrn"` } type SupportGroupAggregations struct { diff --git a/internal/entity/test/component.go b/internal/entity/test/component.go index 3b12ede3..867fae84 100644 --- a/internal/entity/test/component.go +++ b/internal/entity/test/component.go @@ -11,7 +11,7 @@ import ( func NewFakeComponentEntity() entity.Component { return entity.Component{ Id: int64(gofakeit.Number(1, 10000000)), - Name: gofakeit.Name(), + CCRN: gofakeit.Name(), Type: gofakeit.Word(), CreatedAt: gofakeit.Date(), DeletedAt: gofakeit.Date(), diff --git a/internal/entity/test/service.go b/internal/entity/test/service.go index 9381a189..50cb5fae 100644 --- a/internal/entity/test/service.go +++ b/internal/entity/test/service.go @@ -12,7 +12,7 @@ func NewFakeServiceEntity() entity.Service { return entity.Service{ BaseService: entity.BaseService{ Id: int64(gofakeit.Number(1, 10000000)), - Name: gofakeit.Name(), + CCRN: gofakeit.Name(), SupportGroup: nil, Activities: nil, Owners: nil, diff --git a/internal/entity/test/support_group.go b/internal/entity/test/support_group.go index fc72b935..17719720 100644 --- a/internal/entity/test/support_group.go +++ b/internal/entity/test/support_group.go @@ -11,7 +11,7 @@ import ( func NewFakeSupportGroupEntity() entity.SupportGroup { return entity.SupportGroup{ Id: int64(gofakeit.Number(1, 10000000)), - Name: gofakeit.AppName(), + CCRN: gofakeit.AppName(), CreatedAt: gofakeit.Date(), DeletedAt: gofakeit.Date(), UpdatedAt: gofakeit.Date(), diff --git a/internal/mocks/mock_Database.go b/internal/mocks/mock_Database.go index d40d75af..18efde38 100644 --- a/internal/mocks/mock_Database.go +++ b/internal/mocks/mock_Database.go @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors // SPDX-License-Identifier: Apache-2.0 -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package mocks @@ -3395,20 +3395,20 @@ func (_c *MockDatabase_GetAllUserIds_Call) RunAndReturn(run func(*entity.UserFil return _c } -// GetCcrn provides a mock function with given fields: filter -func (_m *MockDatabase) GetCcrn(filter *entity.ComponentInstanceFilter) ([]string, error) { +// GetComponentCcrns provides a mock function with given fields: filter +func (_m *MockDatabase) GetComponentCcrns(filter *entity.ComponentFilter) ([]string, error) { ret := _m.Called(filter) if len(ret) == 0 { - panic("no return value specified for GetCcrn") + panic("no return value specified for GetComponentCcrns") } var r0 []string var r1 error - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter) ([]string, error)); ok { + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) ([]string, error)); ok { return rf(filter) } - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter) []string); ok { + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) []string); ok { r0 = rf(filter) } else { if ret.Get(0) != nil { @@ -3416,7 +3416,7 @@ func (_m *MockDatabase) GetCcrn(filter *entity.ComponentInstanceFilter) ([]strin } } - if rf, ok := ret.Get(1).(func(*entity.ComponentInstanceFilter) error); ok { + if rf, ok := ret.Get(1).(func(*entity.ComponentFilter) error); ok { r1 = rf(filter) } else { r1 = ret.Error(1) @@ -3425,57 +3425,57 @@ func (_m *MockDatabase) GetCcrn(filter *entity.ComponentInstanceFilter) ([]strin return r0, r1 } -// MockDatabase_GetCcrn_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetCcrn' -type MockDatabase_GetCcrn_Call struct { +// MockDatabase_GetComponentCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentCcrns' +type MockDatabase_GetComponentCcrns_Call struct { *mock.Call } -// GetCcrn is a helper method to define mock.On call -// - filter *entity.ComponentInstanceFilter -func (_e *MockDatabase_Expecter) GetCcrn(filter interface{}) *MockDatabase_GetCcrn_Call { - return &MockDatabase_GetCcrn_Call{Call: _e.mock.On("GetCcrn", filter)} +// GetComponentCcrns is a helper method to define mock.On call +// - filter *entity.ComponentFilter +func (_e *MockDatabase_Expecter) GetComponentCcrns(filter interface{}) *MockDatabase_GetComponentCcrns_Call { + return &MockDatabase_GetComponentCcrns_Call{Call: _e.mock.On("GetComponentCcrns", filter)} } -func (_c *MockDatabase_GetCcrn_Call) Run(run func(filter *entity.ComponentInstanceFilter)) *MockDatabase_GetCcrn_Call { +func (_c *MockDatabase_GetComponentCcrns_Call) Run(run func(filter *entity.ComponentFilter)) *MockDatabase_GetComponentCcrns_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ComponentInstanceFilter)) + run(args[0].(*entity.ComponentFilter)) }) return _c } -func (_c *MockDatabase_GetCcrn_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetCcrn_Call { +func (_c *MockDatabase_GetComponentCcrns_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetComponentCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDatabase_GetCcrn_Call) RunAndReturn(run func(*entity.ComponentInstanceFilter) ([]string, error)) *MockDatabase_GetCcrn_Call { +func (_c *MockDatabase_GetComponentCcrns_Call) RunAndReturn(run func(*entity.ComponentFilter) ([]string, error)) *MockDatabase_GetComponentCcrns_Call { _c.Call.Return(run) return _c } -// GetComponentInstances provides a mock function with given fields: _a0 -func (_m *MockDatabase) GetComponentInstances(_a0 *entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error) { - ret := _m.Called(_a0) +// GetComponentCcrns provides a mock function with given fields: filter +func (_m *MockDatabase) GetComponentCcrns(filter *entity.ComponentFilter) ([]string, error) { + ret := _m.Called(filter) if len(ret) == 0 { - panic("no return value specified for GetComponentInstances") + panic("no return value specified for GetComponentCcrns") } - var r0 []entity.ComponentInstance + var r0 []string var r1 error - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error)); ok { - return rf(_a0) + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) ([]string, error)); ok { + return rf(filter) } - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter) []entity.ComponentInstance); ok { - r0 = rf(_a0) + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) []string); ok { + r0 = rf(filter) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]entity.ComponentInstance) + r0 = ret.Get(0).([]string) } } - if rf, ok := ret.Get(1).(func(*entity.ComponentInstanceFilter) error); ok { - r1 = rf(_a0) + if rf, ok := ret.Get(1).(func(*entity.ComponentFilter) error); ok { + r1 = rf(filter) } else { r1 = ret.Error(1) } @@ -3483,57 +3483,57 @@ func (_m *MockDatabase) GetComponentInstances(_a0 *entity.ComponentInstanceFilte return r0, r1 } -// MockDatabase_GetComponentInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentInstances' -type MockDatabase_GetComponentInstances_Call struct { +// MockDatabase_GetComponentCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentCcrns' +type MockDatabase_GetComponentCcrns_Call struct { *mock.Call } -// GetComponentInstances is a helper method to define mock.On call -// - _a0 *entity.ComponentInstanceFilter -func (_e *MockDatabase_Expecter) GetComponentInstances(_a0 interface{}) *MockDatabase_GetComponentInstances_Call { - return &MockDatabase_GetComponentInstances_Call{Call: _e.mock.On("GetComponentInstances", _a0)} +// GetComponentCcrns is a helper method to define mock.On call +// - filter *entity.ComponentFilter +func (_e *MockDatabase_Expecter) GetComponentCcrns(filter interface{}) *MockDatabase_GetComponentCcrns_Call { + return &MockDatabase_GetComponentCcrns_Call{Call: _e.mock.On("GetComponentCcrns", filter)} } -func (_c *MockDatabase_GetComponentInstances_Call) Run(run func(_a0 *entity.ComponentInstanceFilter)) *MockDatabase_GetComponentInstances_Call { +func (_c *MockDatabase_GetComponentCcrns_Call) Run(run func(filter *entity.ComponentFilter)) *MockDatabase_GetComponentCcrns_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ComponentInstanceFilter)) + run(args[0].(*entity.ComponentFilter)) }) return _c } -func (_c *MockDatabase_GetComponentInstances_Call) Return(_a0 []entity.ComponentInstance, _a1 error) *MockDatabase_GetComponentInstances_Call { +func (_c *MockDatabase_GetComponentCcrns_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetComponentCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDatabase_GetComponentInstances_Call) RunAndReturn(run func(*entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error)) *MockDatabase_GetComponentInstances_Call { +func (_c *MockDatabase_GetComponentCcrns_Call) RunAndReturn(run func(*entity.ComponentFilter) ([]string, error)) *MockDatabase_GetComponentCcrns_Call { _c.Call.Return(run) return _c } -// GetComponentNames provides a mock function with given fields: filter -func (_m *MockDatabase) GetComponentNames(filter *entity.ComponentFilter) ([]string, error) { - ret := _m.Called(filter) +// GetComponentInstances provides a mock function with given fields: _a0 +func (_m *MockDatabase) GetComponentInstances(_a0 *entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error) { + ret := _m.Called(_a0) if len(ret) == 0 { - panic("no return value specified for GetComponentNames") + panic("no return value specified for GetComponentInstances") } - var r0 []string + var r0 []entity.ComponentInstance var r1 error - if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) ([]string, error)); ok { - return rf(filter) + if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error)); ok { + return rf(_a0) } - if rf, ok := ret.Get(0).(func(*entity.ComponentFilter) []string); ok { - r0 = rf(filter) + if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter) []entity.ComponentInstance); ok { + r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) + r0 = ret.Get(0).([]entity.ComponentInstance) } } - if rf, ok := ret.Get(1).(func(*entity.ComponentFilter) error); ok { - r1 = rf(filter) + if rf, ok := ret.Get(1).(func(*entity.ComponentInstanceFilter) error); ok { + r1 = rf(_a0) } else { r1 = ret.Error(1) } @@ -3541,30 +3541,30 @@ func (_m *MockDatabase) GetComponentNames(filter *entity.ComponentFilter) ([]str return r0, r1 } -// MockDatabase_GetComponentNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentNames' -type MockDatabase_GetComponentNames_Call struct { +// MockDatabase_GetComponentInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetComponentInstances' +type MockDatabase_GetComponentInstances_Call struct { *mock.Call } -// GetComponentNames is a helper method to define mock.On call -// - filter *entity.ComponentFilter -func (_e *MockDatabase_Expecter) GetComponentNames(filter interface{}) *MockDatabase_GetComponentNames_Call { - return &MockDatabase_GetComponentNames_Call{Call: _e.mock.On("GetComponentNames", filter)} +// GetComponentInstances is a helper method to define mock.On call +// - _a0 *entity.ComponentInstanceFilter +func (_e *MockDatabase_Expecter) GetComponentInstances(_a0 interface{}) *MockDatabase_GetComponentInstances_Call { + return &MockDatabase_GetComponentInstances_Call{Call: _e.mock.On("GetComponentInstances", _a0)} } -func (_c *MockDatabase_GetComponentNames_Call) Run(run func(filter *entity.ComponentFilter)) *MockDatabase_GetComponentNames_Call { +func (_c *MockDatabase_GetComponentInstances_Call) Run(run func(_a0 *entity.ComponentInstanceFilter)) *MockDatabase_GetComponentInstances_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ComponentFilter)) + run(args[0].(*entity.ComponentInstanceFilter)) }) return _c } -func (_c *MockDatabase_GetComponentNames_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetComponentNames_Call { +func (_c *MockDatabase_GetComponentInstances_Call) Return(_a0 []entity.ComponentInstance, _a1 error) *MockDatabase_GetComponentInstances_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDatabase_GetComponentNames_Call) RunAndReturn(run func(*entity.ComponentFilter) ([]string, error)) *MockDatabase_GetComponentNames_Call { +func (_c *MockDatabase_GetComponentInstances_Call) RunAndReturn(run func(*entity.ComponentInstanceFilter) ([]entity.ComponentInstance, error)) *MockDatabase_GetComponentInstances_Call { _c.Call.Return(run) return _c } @@ -4239,28 +4239,28 @@ func (_c *MockDatabase_GetIssuesWithAggregations_Call) RunAndReturn(run func(*en return _c } -// GetServiceIssueVariants provides a mock function with given fields: _a0 -func (_m *MockDatabase) GetServiceIssueVariants(_a0 *entity.ServiceIssueVariantFilter) ([]entity.ServiceIssueVariant, error) { +// GetServiceCcrns provides a mock function with given fields: _a0 +func (_m *MockDatabase) GetServiceCcrns(_a0 *entity.ServiceFilter) ([]string, error) { ret := _m.Called(_a0) if len(ret) == 0 { - panic("no return value specified for GetServiceIssueVariants") + panic("no return value specified for GetServiceCcrns") } - var r0 []entity.ServiceIssueVariant + var r0 []string var r1 error - if rf, ok := ret.Get(0).(func(*entity.ServiceIssueVariantFilter) ([]entity.ServiceIssueVariant, error)); ok { + if rf, ok := ret.Get(0).(func(*entity.ServiceFilter) ([]string, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(*entity.ServiceIssueVariantFilter) []entity.ServiceIssueVariant); ok { + if rf, ok := ret.Get(0).(func(*entity.ServiceFilter) []string); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]entity.ServiceIssueVariant) + r0 = ret.Get(0).([]string) } } - if rf, ok := ret.Get(1).(func(*entity.ServiceIssueVariantFilter) error); ok { + if rf, ok := ret.Get(1).(func(*entity.ServiceFilter) error); ok { r1 = rf(_a0) } else { r1 = ret.Error(1) @@ -4269,56 +4269,56 @@ func (_m *MockDatabase) GetServiceIssueVariants(_a0 *entity.ServiceIssueVariantF return r0, r1 } -// MockDatabase_GetServiceIssueVariants_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetServiceIssueVariants' -type MockDatabase_GetServiceIssueVariants_Call struct { +// MockDatabase_GetServiceCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetServiceCcrns' +type MockDatabase_GetServiceCcrns_Call struct { *mock.Call } -// GetServiceIssueVariants is a helper method to define mock.On call -// - _a0 *entity.ServiceIssueVariantFilter -func (_e *MockDatabase_Expecter) GetServiceIssueVariants(_a0 interface{}) *MockDatabase_GetServiceIssueVariants_Call { - return &MockDatabase_GetServiceIssueVariants_Call{Call: _e.mock.On("GetServiceIssueVariants", _a0)} +// GetServiceCcrns is a helper method to define mock.On call +// - _a0 *entity.ServiceFilter +func (_e *MockDatabase_Expecter) GetServiceCcrns(_a0 interface{}) *MockDatabase_GetServiceCcrns_Call { + return &MockDatabase_GetServiceCcrns_Call{Call: _e.mock.On("GetServiceCcrns", _a0)} } -func (_c *MockDatabase_GetServiceIssueVariants_Call) Run(run func(_a0 *entity.ServiceIssueVariantFilter)) *MockDatabase_GetServiceIssueVariants_Call { +func (_c *MockDatabase_GetServiceCcrns_Call) Run(run func(_a0 *entity.ServiceFilter)) *MockDatabase_GetServiceCcrns_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ServiceIssueVariantFilter)) + run(args[0].(*entity.ServiceFilter)) }) return _c } -func (_c *MockDatabase_GetServiceIssueVariants_Call) Return(_a0 []entity.ServiceIssueVariant, _a1 error) *MockDatabase_GetServiceIssueVariants_Call { +func (_c *MockDatabase_GetServiceCcrns_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetServiceCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDatabase_GetServiceIssueVariants_Call) RunAndReturn(run func(*entity.ServiceIssueVariantFilter) ([]entity.ServiceIssueVariant, error)) *MockDatabase_GetServiceIssueVariants_Call { +func (_c *MockDatabase_GetServiceCcrns_Call) RunAndReturn(run func(*entity.ServiceFilter) ([]string, error)) *MockDatabase_GetServiceCcrns_Call { _c.Call.Return(run) return _c } -// GetServiceNames provides a mock function with given fields: _a0 -func (_m *MockDatabase) GetServiceNames(_a0 *entity.ServiceFilter) ([]string, error) { +// GetServiceIssueVariants provides a mock function with given fields: _a0 +func (_m *MockDatabase) GetServiceIssueVariants(_a0 *entity.ServiceIssueVariantFilter) ([]entity.ServiceIssueVariant, error) { ret := _m.Called(_a0) if len(ret) == 0 { - panic("no return value specified for GetServiceNames") + panic("no return value specified for GetServiceIssueVariants") } - var r0 []string + var r0 []entity.ServiceIssueVariant var r1 error - if rf, ok := ret.Get(0).(func(*entity.ServiceFilter) ([]string, error)); ok { + if rf, ok := ret.Get(0).(func(*entity.ServiceIssueVariantFilter) ([]entity.ServiceIssueVariant, error)); ok { return rf(_a0) } - if rf, ok := ret.Get(0).(func(*entity.ServiceFilter) []string); ok { + if rf, ok := ret.Get(0).(func(*entity.ServiceIssueVariantFilter) []entity.ServiceIssueVariant); ok { r0 = rf(_a0) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) + r0 = ret.Get(0).([]entity.ServiceIssueVariant) } } - if rf, ok := ret.Get(1).(func(*entity.ServiceFilter) error); ok { + if rf, ok := ret.Get(1).(func(*entity.ServiceIssueVariantFilter) error); ok { r1 = rf(_a0) } else { r1 = ret.Error(1) @@ -4327,30 +4327,30 @@ func (_m *MockDatabase) GetServiceNames(_a0 *entity.ServiceFilter) ([]string, er return r0, r1 } -// MockDatabase_GetServiceNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetServiceNames' -type MockDatabase_GetServiceNames_Call struct { +// MockDatabase_GetServiceIssueVariants_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetServiceIssueVariants' +type MockDatabase_GetServiceIssueVariants_Call struct { *mock.Call } -// GetServiceNames is a helper method to define mock.On call -// - _a0 *entity.ServiceFilter -func (_e *MockDatabase_Expecter) GetServiceNames(_a0 interface{}) *MockDatabase_GetServiceNames_Call { - return &MockDatabase_GetServiceNames_Call{Call: _e.mock.On("GetServiceNames", _a0)} +// GetServiceIssueVariants is a helper method to define mock.On call +// - _a0 *entity.ServiceIssueVariantFilter +func (_e *MockDatabase_Expecter) GetServiceIssueVariants(_a0 interface{}) *MockDatabase_GetServiceIssueVariants_Call { + return &MockDatabase_GetServiceIssueVariants_Call{Call: _e.mock.On("GetServiceIssueVariants", _a0)} } -func (_c *MockDatabase_GetServiceNames_Call) Run(run func(_a0 *entity.ServiceFilter)) *MockDatabase_GetServiceNames_Call { +func (_c *MockDatabase_GetServiceIssueVariants_Call) Run(run func(_a0 *entity.ServiceIssueVariantFilter)) *MockDatabase_GetServiceIssueVariants_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ServiceFilter)) + run(args[0].(*entity.ServiceIssueVariantFilter)) }) return _c } -func (_c *MockDatabase_GetServiceNames_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetServiceNames_Call { +func (_c *MockDatabase_GetServiceIssueVariants_Call) Return(_a0 []entity.ServiceIssueVariant, _a1 error) *MockDatabase_GetServiceIssueVariants_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDatabase_GetServiceNames_Call) RunAndReturn(run func(*entity.ServiceFilter) ([]string, error)) *MockDatabase_GetServiceNames_Call { +func (_c *MockDatabase_GetServiceIssueVariants_Call) RunAndReturn(run func(*entity.ServiceIssueVariantFilter) ([]entity.ServiceIssueVariant, error)) *MockDatabase_GetServiceIssueVariants_Call { _c.Call.Return(run) return _c } @@ -4413,8 +4413,8 @@ func (_c *MockDatabase_GetServices_Call) RunAndReturn(run func(*entity.ServiceFi return _c } -// GetServicesWithAggregations provides a mock function with given fields: _a0 -func (_m *MockDatabase) GetServicesWithAggregations(_a0 *entity.ServiceFilter) ([]entity.ServiceWithAggregations, error) { +// GetSupportGroupCcrns provides a mock function with given fields: _a0 +func (_m *MockDatabase) GetSupportGroupCcrns(_a0 *entity.SupportGroupFilter) ([]string, error) { ret := _m.Called(_a0) if len(ret) == 0 { @@ -4471,12 +4471,12 @@ func (_c *MockDatabase_GetServicesWithAggregations_Call) RunAndReturn(run func(* return _c } -// GetSupportGroupNames provides a mock function with given fields: _a0 -func (_m *MockDatabase) GetSupportGroupNames(_a0 *entity.SupportGroupFilter) ([]string, error) { +// GetSupportGroupCcrns provides a mock function with given fields: _a0 +func (_m *MockDatabase) GetSupportGroupCcrns(_a0 *entity.SupportGroupFilter) ([]string, error) { ret := _m.Called(_a0) if len(ret) == 0 { - panic("no return value specified for GetSupportGroupNames") + panic("no return value specified for GetSupportGroupCcrns") } var r0 []string @@ -4501,30 +4501,30 @@ func (_m *MockDatabase) GetSupportGroupNames(_a0 *entity.SupportGroupFilter) ([] return r0, r1 } -// MockDatabase_GetSupportGroupNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSupportGroupNames' -type MockDatabase_GetSupportGroupNames_Call struct { +// MockDatabase_GetSupportGroupCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'GetSupportGroupCcrns' +type MockDatabase_GetSupportGroupCcrns_Call struct { *mock.Call } -// GetSupportGroupNames is a helper method to define mock.On call +// GetSupportGroupCcrns is a helper method to define mock.On call // - _a0 *entity.SupportGroupFilter -func (_e *MockDatabase_Expecter) GetSupportGroupNames(_a0 interface{}) *MockDatabase_GetSupportGroupNames_Call { - return &MockDatabase_GetSupportGroupNames_Call{Call: _e.mock.On("GetSupportGroupNames", _a0)} +func (_e *MockDatabase_Expecter) GetSupportGroupCcrns(_a0 interface{}) *MockDatabase_GetSupportGroupCcrns_Call { + return &MockDatabase_GetSupportGroupCcrns_Call{Call: _e.mock.On("GetSupportGroupCcrns", _a0)} } -func (_c *MockDatabase_GetSupportGroupNames_Call) Run(run func(_a0 *entity.SupportGroupFilter)) *MockDatabase_GetSupportGroupNames_Call { +func (_c *MockDatabase_GetSupportGroupCcrns_Call) Run(run func(_a0 *entity.SupportGroupFilter)) *MockDatabase_GetSupportGroupCcrns_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(*entity.SupportGroupFilter)) }) return _c } -func (_c *MockDatabase_GetSupportGroupNames_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetSupportGroupNames_Call { +func (_c *MockDatabase_GetSupportGroupCcrns_Call) Return(_a0 []string, _a1 error) *MockDatabase_GetSupportGroupCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockDatabase_GetSupportGroupNames_Call) RunAndReturn(run func(*entity.SupportGroupFilter) ([]string, error)) *MockDatabase_GetSupportGroupNames_Call { +func (_c *MockDatabase_GetSupportGroupCcrns_Call) RunAndReturn(run func(*entity.SupportGroupFilter) ([]string, error)) *MockDatabase_GetSupportGroupCcrns_Call { _c.Call.Return(run) return _c } diff --git a/internal/mocks/mock_Heureka.go b/internal/mocks/mock_Heureka.go index 87603d69..1ee4a87c 100644 --- a/internal/mocks/mock_Heureka.go +++ b/internal/mocks/mock_Heureka.go @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors // SPDX-License-Identifier: Apache-2.0 -// Code generated by mockery v2.45.0. DO NOT EDIT. +// Code generated by mockery v2.46.2. DO NOT EDIT. package mocks @@ -2197,29 +2197,29 @@ func (_c *MockHeureka_ListActivities_Call) RunAndReturn(run func(*entity.Activit return _c } -// ListCcrns provides a mock function with given fields: filter, options -func (_m *MockHeureka) ListCcrns(filter *entity.ComponentInstanceFilter, options *entity.ListOptions) ([]string, error) { - ret := _m.Called(filter, options) +// ListComponentCcrns provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListComponentCcrns(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions) ([]string, error) { + ret := _m.Called(_a0, _a1) if len(ret) == 0 { - panic("no return value specified for ListCcrns") + panic("no return value specified for ListComponentCcrns") } var r0 []string var r1 error - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) ([]string, error)); ok { - return rf(filter, options) + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)); ok { + return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) []string); ok { - r0 = rf(filter, options) + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) []string); ok { + r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { r0 = ret.Get(0).([]string) } } - if rf, ok := ret.Get(1).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) error); ok { - r1 = rf(filter, options) + if rf, ok := ret.Get(1).(func(*entity.ComponentFilter, *entity.ListOptions) error); ok { + r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) } @@ -2227,57 +2227,57 @@ func (_m *MockHeureka) ListCcrns(filter *entity.ComponentInstanceFilter, options return r0, r1 } -// MockHeureka_ListCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListCcrns' -type MockHeureka_ListCcrns_Call struct { +// MockHeureka_ListComponentCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComponentCcrns' +type MockHeureka_ListComponentCcrns_Call struct { *mock.Call } -// ListCcrns is a helper method to define mock.On call -// - filter *entity.ComponentInstanceFilter -// - options *entity.ListOptions -func (_e *MockHeureka_Expecter) ListCcrns(filter interface{}, options interface{}) *MockHeureka_ListCcrns_Call { - return &MockHeureka_ListCcrns_Call{Call: _e.mock.On("ListCcrns", filter, options)} +// ListComponentCcrns is a helper method to define mock.On call +// - _a0 *entity.ComponentFilter +// - _a1 *entity.ListOptions +func (_e *MockHeureka_Expecter) ListComponentCcrns(_a0 interface{}, _a1 interface{}) *MockHeureka_ListComponentCcrns_Call { + return &MockHeureka_ListComponentCcrns_Call{Call: _e.mock.On("ListComponentCcrns", _a0, _a1)} } -func (_c *MockHeureka_ListCcrns_Call) Run(run func(filter *entity.ComponentInstanceFilter, options *entity.ListOptions)) *MockHeureka_ListCcrns_Call { +func (_c *MockHeureka_ListComponentCcrns_Call) Run(run func(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions)) *MockHeureka_ListComponentCcrns_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ComponentInstanceFilter), args[1].(*entity.ListOptions)) + run(args[0].(*entity.ComponentFilter), args[1].(*entity.ListOptions)) }) return _c } -func (_c *MockHeureka_ListCcrns_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListCcrns_Call { +func (_c *MockHeureka_ListComponentCcrns_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListComponentCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListCcrns_Call) RunAndReturn(run func(*entity.ComponentInstanceFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListCcrns_Call { +func (_c *MockHeureka_ListComponentCcrns_Call) RunAndReturn(run func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListComponentCcrns_Call { _c.Call.Return(run) return _c } -// ListComponentInstances provides a mock function with given fields: _a0, _a1 -func (_m *MockHeureka) ListComponentInstances(_a0 *entity.ComponentInstanceFilter, _a1 *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error) { +// ListComponentCcrns provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListComponentCcrns(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions) ([]string, error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { - panic("no return value specified for ListComponentInstances") + panic("no return value specified for ListComponentCcrns") } - var r0 *entity.List[entity.ComponentInstanceResult] + var r0 []string var r1 error - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error)); ok { + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) *entity.List[entity.ComponentInstanceResult]); ok { + if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) []string); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).(*entity.List[entity.ComponentInstanceResult]) + r0 = ret.Get(0).([]string) } } - if rf, ok := ret.Get(1).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) error); ok { + if rf, ok := ret.Get(1).(func(*entity.ComponentFilter, *entity.ListOptions) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -2286,57 +2286,57 @@ func (_m *MockHeureka) ListComponentInstances(_a0 *entity.ComponentInstanceFilte return r0, r1 } -// MockHeureka_ListComponentInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComponentInstances' -type MockHeureka_ListComponentInstances_Call struct { +// MockHeureka_ListComponentCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComponentCcrns' +type MockHeureka_ListComponentCcrns_Call struct { *mock.Call } -// ListComponentInstances is a helper method to define mock.On call -// - _a0 *entity.ComponentInstanceFilter +// ListComponentCcrns is a helper method to define mock.On call +// - _a0 *entity.ComponentFilter // - _a1 *entity.ListOptions -func (_e *MockHeureka_Expecter) ListComponentInstances(_a0 interface{}, _a1 interface{}) *MockHeureka_ListComponentInstances_Call { - return &MockHeureka_ListComponentInstances_Call{Call: _e.mock.On("ListComponentInstances", _a0, _a1)} +func (_e *MockHeureka_Expecter) ListComponentCcrns(_a0 interface{}, _a1 interface{}) *MockHeureka_ListComponentCcrns_Call { + return &MockHeureka_ListComponentCcrns_Call{Call: _e.mock.On("ListComponentCcrns", _a0, _a1)} } -func (_c *MockHeureka_ListComponentInstances_Call) Run(run func(_a0 *entity.ComponentInstanceFilter, _a1 *entity.ListOptions)) *MockHeureka_ListComponentInstances_Call { +func (_c *MockHeureka_ListComponentCcrns_Call) Run(run func(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions)) *MockHeureka_ListComponentCcrns_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ComponentInstanceFilter), args[1].(*entity.ListOptions)) + run(args[0].(*entity.ComponentFilter), args[1].(*entity.ListOptions)) }) return _c } -func (_c *MockHeureka_ListComponentInstances_Call) Return(_a0 *entity.List[entity.ComponentInstanceResult], _a1 error) *MockHeureka_ListComponentInstances_Call { +func (_c *MockHeureka_ListComponentCcrns_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListComponentCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListComponentInstances_Call) RunAndReturn(run func(*entity.ComponentInstanceFilter, *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error)) *MockHeureka_ListComponentInstances_Call { +func (_c *MockHeureka_ListComponentCcrns_Call) RunAndReturn(run func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListComponentCcrns_Call { _c.Call.Return(run) return _c } -// ListComponentNames provides a mock function with given fields: _a0, _a1 -func (_m *MockHeureka) ListComponentNames(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions) ([]string, error) { +// ListComponentInstances provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListComponentInstances(_a0 *entity.ComponentInstanceFilter, _a1 *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { - panic("no return value specified for ListComponentNames") + panic("no return value specified for ListComponentInstances") } - var r0 []string + var r0 *entity.List[entity.ComponentInstanceResult] var r1 error - if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)); ok { + if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error)); ok { return rf(_a0, _a1) } - if rf, ok := ret.Get(0).(func(*entity.ComponentFilter, *entity.ListOptions) []string); ok { + if rf, ok := ret.Get(0).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) *entity.List[entity.ComponentInstanceResult]); ok { r0 = rf(_a0, _a1) } else { if ret.Get(0) != nil { - r0 = ret.Get(0).([]string) + r0 = ret.Get(0).(*entity.List[entity.ComponentInstanceResult]) } } - if rf, ok := ret.Get(1).(func(*entity.ComponentFilter, *entity.ListOptions) error); ok { + if rf, ok := ret.Get(1).(func(*entity.ComponentInstanceFilter, *entity.ListOptions) error); ok { r1 = rf(_a0, _a1) } else { r1 = ret.Error(1) @@ -2345,31 +2345,31 @@ func (_m *MockHeureka) ListComponentNames(_a0 *entity.ComponentFilter, _a1 *enti return r0, r1 } -// MockHeureka_ListComponentNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComponentNames' -type MockHeureka_ListComponentNames_Call struct { +// MockHeureka_ListComponentInstances_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListComponentInstances' +type MockHeureka_ListComponentInstances_Call struct { *mock.Call } -// ListComponentNames is a helper method to define mock.On call -// - _a0 *entity.ComponentFilter +// ListComponentInstances is a helper method to define mock.On call +// - _a0 *entity.ComponentInstanceFilter // - _a1 *entity.ListOptions -func (_e *MockHeureka_Expecter) ListComponentNames(_a0 interface{}, _a1 interface{}) *MockHeureka_ListComponentNames_Call { - return &MockHeureka_ListComponentNames_Call{Call: _e.mock.On("ListComponentNames", _a0, _a1)} +func (_e *MockHeureka_Expecter) ListComponentInstances(_a0 interface{}, _a1 interface{}) *MockHeureka_ListComponentInstances_Call { + return &MockHeureka_ListComponentInstances_Call{Call: _e.mock.On("ListComponentInstances", _a0, _a1)} } -func (_c *MockHeureka_ListComponentNames_Call) Run(run func(_a0 *entity.ComponentFilter, _a1 *entity.ListOptions)) *MockHeureka_ListComponentNames_Call { +func (_c *MockHeureka_ListComponentInstances_Call) Run(run func(_a0 *entity.ComponentInstanceFilter, _a1 *entity.ListOptions)) *MockHeureka_ListComponentInstances_Call { _c.Call.Run(func(args mock.Arguments) { - run(args[0].(*entity.ComponentFilter), args[1].(*entity.ListOptions)) + run(args[0].(*entity.ComponentInstanceFilter), args[1].(*entity.ListOptions)) }) return _c } -func (_c *MockHeureka_ListComponentNames_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListComponentNames_Call { +func (_c *MockHeureka_ListComponentInstances_Call) Return(_a0 *entity.List[entity.ComponentInstanceResult], _a1 error) *MockHeureka_ListComponentInstances_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListComponentNames_Call) RunAndReturn(run func(*entity.ComponentFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListComponentNames_Call { +func (_c *MockHeureka_ListComponentInstances_Call) RunAndReturn(run func(*entity.ComponentInstanceFilter, *entity.ListOptions) (*entity.List[entity.ComponentInstanceResult], error)) *MockHeureka_ListComponentInstances_Call { _c.Call.Return(run) return _c } @@ -2964,12 +2964,12 @@ func (_c *MockHeureka_ListIssues_Call) RunAndReturn(run func(*entity.IssueFilter return _c } -// ListServiceNames provides a mock function with given fields: filter, options -func (_m *MockHeureka) ListServiceNames(filter *entity.ServiceFilter, options *entity.ListOptions) ([]string, error) { +// ListServiceCcrns provides a mock function with given fields: filter, options +func (_m *MockHeureka) ListServiceCcrns(filter *entity.ServiceFilter, options *entity.ListOptions) ([]string, error) { ret := _m.Called(filter, options) if len(ret) == 0 { - panic("no return value specified for ListServiceNames") + panic("no return value specified for ListServiceCcrns") } var r0 []string @@ -2994,31 +2994,31 @@ func (_m *MockHeureka) ListServiceNames(filter *entity.ServiceFilter, options *e return r0, r1 } -// MockHeureka_ListServiceNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListServiceNames' -type MockHeureka_ListServiceNames_Call struct { +// MockHeureka_ListServiceCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListServiceCcrns' +type MockHeureka_ListServiceCcrns_Call struct { *mock.Call } -// ListServiceNames is a helper method to define mock.On call +// ListServiceCcrns is a helper method to define mock.On call // - filter *entity.ServiceFilter // - options *entity.ListOptions -func (_e *MockHeureka_Expecter) ListServiceNames(filter interface{}, options interface{}) *MockHeureka_ListServiceNames_Call { - return &MockHeureka_ListServiceNames_Call{Call: _e.mock.On("ListServiceNames", filter, options)} +func (_e *MockHeureka_Expecter) ListServiceCcrns(filter interface{}, options interface{}) *MockHeureka_ListServiceCcrns_Call { + return &MockHeureka_ListServiceCcrns_Call{Call: _e.mock.On("ListServiceCcrns", filter, options)} } -func (_c *MockHeureka_ListServiceNames_Call) Run(run func(filter *entity.ServiceFilter, options *entity.ListOptions)) *MockHeureka_ListServiceNames_Call { +func (_c *MockHeureka_ListServiceCcrns_Call) Run(run func(filter *entity.ServiceFilter, options *entity.ListOptions)) *MockHeureka_ListServiceCcrns_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(*entity.ServiceFilter), args[1].(*entity.ListOptions)) }) return _c } -func (_c *MockHeureka_ListServiceNames_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListServiceNames_Call { +func (_c *MockHeureka_ListServiceCcrns_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListServiceCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListServiceNames_Call) RunAndReturn(run func(*entity.ServiceFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListServiceNames_Call { +func (_c *MockHeureka_ListServiceCcrns_Call) RunAndReturn(run func(*entity.ServiceFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListServiceCcrns_Call { _c.Call.Return(run) return _c } @@ -3082,12 +3082,12 @@ func (_c *MockHeureka_ListServices_Call) RunAndReturn(run func(*entity.ServiceFi return _c } -// ListSupportGroupNames provides a mock function with given fields: _a0, _a1 -func (_m *MockHeureka) ListSupportGroupNames(_a0 *entity.SupportGroupFilter, _a1 *entity.ListOptions) ([]string, error) { +// ListSupportGroupCcrns provides a mock function with given fields: _a0, _a1 +func (_m *MockHeureka) ListSupportGroupCcrns(_a0 *entity.SupportGroupFilter, _a1 *entity.ListOptions) ([]string, error) { ret := _m.Called(_a0, _a1) if len(ret) == 0 { - panic("no return value specified for ListSupportGroupNames") + panic("no return value specified for ListSupportGroupCcrns") } var r0 []string @@ -3112,31 +3112,31 @@ func (_m *MockHeureka) ListSupportGroupNames(_a0 *entity.SupportGroupFilter, _a1 return r0, r1 } -// MockHeureka_ListSupportGroupNames_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSupportGroupNames' -type MockHeureka_ListSupportGroupNames_Call struct { +// MockHeureka_ListSupportGroupCcrns_Call is a *mock.Call that shadows Run/Return methods with type explicit version for method 'ListSupportGroupCcrns' +type MockHeureka_ListSupportGroupCcrns_Call struct { *mock.Call } -// ListSupportGroupNames is a helper method to define mock.On call +// ListSupportGroupCcrns is a helper method to define mock.On call // - _a0 *entity.SupportGroupFilter // - _a1 *entity.ListOptions -func (_e *MockHeureka_Expecter) ListSupportGroupNames(_a0 interface{}, _a1 interface{}) *MockHeureka_ListSupportGroupNames_Call { - return &MockHeureka_ListSupportGroupNames_Call{Call: _e.mock.On("ListSupportGroupNames", _a0, _a1)} +func (_e *MockHeureka_Expecter) ListSupportGroupCcrns(_a0 interface{}, _a1 interface{}) *MockHeureka_ListSupportGroupCcrns_Call { + return &MockHeureka_ListSupportGroupCcrns_Call{Call: _e.mock.On("ListSupportGroupCcrns", _a0, _a1)} } -func (_c *MockHeureka_ListSupportGroupNames_Call) Run(run func(_a0 *entity.SupportGroupFilter, _a1 *entity.ListOptions)) *MockHeureka_ListSupportGroupNames_Call { +func (_c *MockHeureka_ListSupportGroupCcrns_Call) Run(run func(_a0 *entity.SupportGroupFilter, _a1 *entity.ListOptions)) *MockHeureka_ListSupportGroupCcrns_Call { _c.Call.Run(func(args mock.Arguments) { run(args[0].(*entity.SupportGroupFilter), args[1].(*entity.ListOptions)) }) return _c } -func (_c *MockHeureka_ListSupportGroupNames_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListSupportGroupNames_Call { +func (_c *MockHeureka_ListSupportGroupCcrns_Call) Return(_a0 []string, _a1 error) *MockHeureka_ListSupportGroupCcrns_Call { _c.Call.Return(_a0, _a1) return _c } -func (_c *MockHeureka_ListSupportGroupNames_Call) RunAndReturn(run func(*entity.SupportGroupFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListSupportGroupNames_Call { +func (_c *MockHeureka_ListSupportGroupCcrns_Call) RunAndReturn(run func(*entity.SupportGroupFilter, *entity.ListOptions) ([]string, error)) *MockHeureka_ListSupportGroupCcrns_Call { _c.Call.Return(run) return _c } diff --git a/scanner/k8s-assets/client/generated.go b/scanner/k8s-assets/client/generated.go index dda1b2c4..3f7c7ff4 100644 --- a/scanner/k8s-assets/client/generated.go +++ b/scanner/k8s-assets/client/generated.go @@ -24,15 +24,15 @@ func (v *AddServiceToSupportGroupResponse) GetAddServiceToSupportGroup() *Suppor // Component includes the requested fields of the GraphQL type Component. type Component struct { Id string `json:"id"` - Name string `json:"name"` + Ccrn string `json:"ccrn"` Type ComponentTypeValues `json:"type"` } // GetId returns Component.Id, and is useful for accessing the field via an interface. func (v *Component) GetId() string { return v.Id } -// GetName returns Component.Name, and is useful for accessing the field via an interface. -func (v *Component) GetName() string { return v.Name } +// GetCcrn returns Component.Ccrn, and is useful for accessing the field via an interface. +func (v *Component) GetCcrn() string { return v.Ccrn } // GetType returns Component.Type, and is useful for accessing the field via an interface. func (v *Component) GetType() ComponentTypeValues { return v.Type } @@ -58,19 +58,19 @@ type ComponentConnectionEdgesComponentEdge struct { func (v *ComponentConnectionEdgesComponentEdge) GetNode() *Component { return v.Node } type ComponentFilter struct { - ComponentName []string `json:"componentName"` + ComponentCcrn []string `json:"componentCcrn"` } -// GetComponentName returns ComponentFilter.ComponentName, and is useful for accessing the field via an interface. -func (v *ComponentFilter) GetComponentName() []string { return v.ComponentName } +// GetComponentCcrn returns ComponentFilter.ComponentCcrn, and is useful for accessing the field via an interface. +func (v *ComponentFilter) GetComponentCcrn() []string { return v.ComponentCcrn } type ComponentInput struct { - Name string `json:"name"` + Ccrn string `json:"ccrn"` Type ComponentTypeValues `json:"type"` } -// GetName returns ComponentInput.Name, and is useful for accessing the field via an interface. -func (v *ComponentInput) GetName() string { return v.Name } +// GetCcrn returns ComponentInput.Ccrn, and is useful for accessing the field via an interface. +func (v *ComponentInput) GetCcrn() string { return v.Ccrn } // GetType returns ComponentInput.Type, and is useful for accessing the field via an interface. func (v *ComponentInput) GetType() ComponentTypeValues { return v.Type } @@ -100,14 +100,14 @@ func (v *ComponentInstance) GetComponentVersionId() string { return v.ComponentV func (v *ComponentInstance) GetServiceId() string { return v.ServiceId } type ComponentInstanceFilter struct { - ServiceName []string `json:"serviceName"` + ServiceCcrn []string `json:"serviceCcrn"` Ccrn []string `json:"ccrn"` SupportGroup []string `json:"supportGroup"` Search []string `json:"search"` } -// GetServiceName returns ComponentInstanceFilter.ServiceName, and is useful for accessing the field via an interface. -func (v *ComponentInstanceFilter) GetServiceName() []string { return v.ServiceName } +// GetServiceCcrn returns ComponentInstanceFilter.ServiceCcrn, and is useful for accessing the field via an interface. +func (v *ComponentInstanceFilter) GetServiceCcrn() []string { return v.ServiceCcrn } // GetCcrn returns ComponentInstanceFilter.Ccrn, and is useful for accessing the field via an interface. func (v *ComponentInstanceFilter) GetCcrn() []string { return v.Ccrn } @@ -187,7 +187,7 @@ func (v *ComponentVersionConnectionEdgesComponentVersionEdge) GetNode() *Compone type ComponentVersionFilter struct { ComponentId []string `json:"componentId"` - ComponentName []string `json:"componentName"` + ComponentCcrn []string `json:"componentCcrn"` IssueId []string `json:"issueId"` Version []string `json:"version"` } @@ -195,8 +195,8 @@ type ComponentVersionFilter struct { // GetComponentId returns ComponentVersionFilter.ComponentId, and is useful for accessing the field via an interface. func (v *ComponentVersionFilter) GetComponentId() []string { return v.ComponentId } -// GetComponentName returns ComponentVersionFilter.ComponentName, and is useful for accessing the field via an interface. -func (v *ComponentVersionFilter) GetComponentName() []string { return v.ComponentName } +// GetComponentCcrn returns ComponentVersionFilter.ComponentCcrn, and is useful for accessing the field via an interface. +func (v *ComponentVersionFilter) GetComponentCcrn() []string { return v.ComponentCcrn } // GetIssueId returns ComponentVersionFilter.IssueId, and is useful for accessing the field via an interface. func (v *ComponentVersionFilter) GetIssueId() []string { return v.IssueId } @@ -418,26 +418,26 @@ func (v *ListSupportGroupsSupportGroupsSupportGroupConnectionEdgesSupportGroupEd // Service includes the requested fields of the GraphQL type Service. type Service struct { Id string `json:"id"` - Name string `json:"name"` + Ccrn string `json:"ccrn"` } // GetId returns Service.Id, and is useful for accessing the field via an interface. func (v *Service) GetId() string { return v.Id } -// GetName returns Service.Name, and is useful for accessing the field via an interface. -func (v *Service) GetName() string { return v.Name } +// GetCcrn returns Service.Ccrn, and is useful for accessing the field via an interface. +func (v *Service) GetCcrn() string { return v.Ccrn } type ServiceFilter struct { - ServiceName []string `json:"serviceName"` + ServiceCcrn []string `json:"serviceCcrn"` UniqueUserId []string `json:"uniqueUserId"` Type []int `json:"type"` UserName []string `json:"userName"` - SupportGroupName []string `json:"supportGroupName"` + SupportGroupCcrn []string `json:"supportGroupCcrn"` Search []string `json:"search"` } -// GetServiceName returns ServiceFilter.ServiceName, and is useful for accessing the field via an interface. -func (v *ServiceFilter) GetServiceName() []string { return v.ServiceName } +// GetServiceCcrn returns ServiceFilter.ServiceCcrn, and is useful for accessing the field via an interface. +func (v *ServiceFilter) GetServiceCcrn() []string { return v.ServiceCcrn } // GetUniqueUserId returns ServiceFilter.UniqueUserId, and is useful for accessing the field via an interface. func (v *ServiceFilter) GetUniqueUserId() []string { return v.UniqueUserId } @@ -448,48 +448,48 @@ func (v *ServiceFilter) GetType() []int { return v.Type } // GetUserName returns ServiceFilter.UserName, and is useful for accessing the field via an interface. func (v *ServiceFilter) GetUserName() []string { return v.UserName } -// GetSupportGroupName returns ServiceFilter.SupportGroupName, and is useful for accessing the field via an interface. -func (v *ServiceFilter) GetSupportGroupName() []string { return v.SupportGroupName } +// GetSupportGroupCcrn returns ServiceFilter.SupportGroupCcrn, and is useful for accessing the field via an interface. +func (v *ServiceFilter) GetSupportGroupCcrn() []string { return v.SupportGroupCcrn } // GetSearch returns ServiceFilter.Search, and is useful for accessing the field via an interface. func (v *ServiceFilter) GetSearch() []string { return v.Search } type ServiceInput struct { - Name string `json:"name"` + Ccrn string `json:"ccrn"` } -// GetName returns ServiceInput.Name, and is useful for accessing the field via an interface. -func (v *ServiceInput) GetName() string { return v.Name } +// GetCcrn returns ServiceInput.Ccrn, and is useful for accessing the field via an interface. +func (v *ServiceInput) GetCcrn() string { return v.Ccrn } // SupportGroup includes the requested fields of the GraphQL type SupportGroup. type SupportGroup struct { Id string `json:"id"` - Name string `json:"name"` + Ccrn string `json:"ccrn"` } // GetId returns SupportGroup.Id, and is useful for accessing the field via an interface. func (v *SupportGroup) GetId() string { return v.Id } -// GetName returns SupportGroup.Name, and is useful for accessing the field via an interface. -func (v *SupportGroup) GetName() string { return v.Name } +// GetCcrn returns SupportGroup.Ccrn, and is useful for accessing the field via an interface. +func (v *SupportGroup) GetCcrn() string { return v.Ccrn } type SupportGroupFilter struct { - SupportGroupName []string `json:"supportGroupName"` + SupportGroupCcrn []string `json:"supportGroupCcrn"` UserIds []string `json:"userIds"` } -// GetSupportGroupName returns SupportGroupFilter.SupportGroupName, and is useful for accessing the field via an interface. -func (v *SupportGroupFilter) GetSupportGroupName() []string { return v.SupportGroupName } +// GetSupportGroupCcrn returns SupportGroupFilter.SupportGroupCcrn, and is useful for accessing the field via an interface. +func (v *SupportGroupFilter) GetSupportGroupCcrn() []string { return v.SupportGroupCcrn } // GetUserIds returns SupportGroupFilter.UserIds, and is useful for accessing the field via an interface. func (v *SupportGroupFilter) GetUserIds() []string { return v.UserIds } type SupportGroupInput struct { - Name string `json:"name"` + Ccrn string `json:"ccrn"` } -// GetName returns SupportGroupInput.Name, and is useful for accessing the field via an interface. -func (v *SupportGroupInput) GetName() string { return v.Name } +// GetCcrn returns SupportGroupInput.Ccrn, and is useful for accessing the field via an interface. +func (v *SupportGroupInput) GetCcrn() string { return v.Ccrn } // __AddServiceToSupportGroupInput is used internally by genqlient type __AddServiceToSupportGroupInput struct { @@ -588,7 +588,7 @@ const AddServiceToSupportGroup_Operation = ` mutation AddServiceToSupportGroup ($supportGroupId: ID!, $serviceId: ID!) { addServiceToSupportGroup(supportGroupId: $supportGroupId, serviceId: $serviceId) { id - name + ccrn } } ` @@ -626,7 +626,7 @@ const CreateComponent_Operation = ` mutation CreateComponent ($input: ComponentInput!) { createComponent(input: $input) { id - name + ccrn type } } @@ -739,7 +739,7 @@ const CreateService_Operation = ` mutation CreateService ($input: ServiceInput!) { createService(input: $input) { id - name + ccrn } } ` @@ -775,7 +775,7 @@ const CreateSupportGroup_Operation = ` mutation CreateSupportGroup ($input: SupportGroupInput!) { createSupportGroup(input: $input) { id - name + ccrn } } ` @@ -896,7 +896,7 @@ query ListComponents ($filter: ComponentFilter) { edges { node { id - name + ccrn type } } diff --git a/scanner/k8s-assets/client/query/addServiceToSupportGroup.graphql b/scanner/k8s-assets/client/query/addServiceToSupportGroup.graphql index 9082fd02..023d1163 100644 --- a/scanner/k8s-assets/client/query/addServiceToSupportGroup.graphql +++ b/scanner/k8s-assets/client/query/addServiceToSupportGroup.graphql @@ -8,6 +8,6 @@ mutation AddServiceToSupportGroup ($supportGroupId: ID!, $serviceId: ID!) { serviceId: $serviceId ) { id - name + ccrn } } \ No newline at end of file diff --git a/scanner/k8s-assets/client/query/component_create.graphql b/scanner/k8s-assets/client/query/component_create.graphql index 33849abf..6e4824b0 100644 --- a/scanner/k8s-assets/client/query/component_create.graphql +++ b/scanner/k8s-assets/client/query/component_create.graphql @@ -7,7 +7,7 @@ mutation CreateComponent($input: ComponentInput!) { input: $input ) { id - name + ccrn type } } \ No newline at end of file diff --git a/scanner/k8s-assets/client/query/component_query.graphql b/scanner/k8s-assets/client/query/component_query.graphql index 9b52a73d..de319f59 100644 --- a/scanner/k8s-assets/client/query/component_query.graphql +++ b/scanner/k8s-assets/client/query/component_query.graphql @@ -11,7 +11,7 @@ query ListComponents($filter: ComponentFilter) { # @genqlient(typename: "Component") node { id - name + ccrn type } } diff --git a/scanner/k8s-assets/client/query/service_create.graphql b/scanner/k8s-assets/client/query/service_create.graphql index 052a4cdf..7321ff44 100644 --- a/scanner/k8s-assets/client/query/service_create.graphql +++ b/scanner/k8s-assets/client/query/service_create.graphql @@ -7,6 +7,6 @@ mutation CreateService ($input: ServiceInput!) { input: $input ) { id - name + ccrn } } \ No newline at end of file diff --git a/scanner/k8s-assets/client/query/support_group_create.graphql b/scanner/k8s-assets/client/query/support_group_create.graphql index 6613ae2f..e5b50a6e 100644 --- a/scanner/k8s-assets/client/query/support_group_create.graphql +++ b/scanner/k8s-assets/client/query/support_group_create.graphql @@ -7,6 +7,6 @@ mutation CreateSupportGroup ($input: SupportGroupInput!) { input: $input ) { id - name + ccrn } } \ No newline at end of file diff --git a/scanner/k8s-assets/main.go b/scanner/k8s-assets/main.go index fbde412c..cac0af88 100644 --- a/scanner/k8s-assets/main.go +++ b/scanner/k8s-assets/main.go @@ -10,6 +10,8 @@ import ( "sync" "time" + "runtime" + kubeconfig "github.com/cloudoperators/heureka/scanners/k8s-assets/config" "github.com/cloudoperators/heureka/scanners/k8s-assets/processor" "github.com/cloudoperators/heureka/scanners/k8s-assets/scanner" @@ -19,7 +21,6 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" _ "k8s.io/client-go/plugin/pkg/client/auth/oidc" - "runtime" ) type Config struct { @@ -80,7 +81,7 @@ func processNamespace(ctx context.Context, s *scanner.Scanner, p *processor.Proc log.WithFields(log.Fields{ "error": err, "namespace": namespace, - "serviceName": serviceInfo.Name, + "serviceCcrn": serviceInfo.CCRN, }).Error("Failed to process service") } @@ -89,7 +90,7 @@ func processNamespace(ctx context.Context, s *scanner.Scanner, p *processor.Proc log.WithFields(log.Fields{ "error": err, "namespace": namespace, - "serviceName": serviceInfo.Name, + "serviceCcrn": serviceInfo.CCRN, "podName": podReplica.GenerateName, }).Error("Failed to process pod") } diff --git a/scanner/k8s-assets/processor/processor.go b/scanner/k8s-assets/processor/processor.go index dc21d691..0cd19f93 100644 --- a/scanner/k8s-assets/processor/processor.go +++ b/scanner/k8s-assets/processor/processor.go @@ -81,8 +81,8 @@ func NewProcessor(cfg Config) *Processor { func (p *Processor) ProcessService(ctx context.Context, serviceInfo scanner.ServiceInfo) (string, error) { var serviceId string - if serviceInfo.Name == "" { - serviceInfo.Name = "none" + if serviceInfo.CCRN == "" { + serviceInfo.CCRN = "none" } // The Service might already exist in the DB @@ -90,17 +90,17 @@ func (p *Processor) ProcessService(ctx context.Context, serviceInfo scanner.Serv _serviceId, err := p.getService(ctx, serviceInfo) if err != nil { log.WithError(err).WithFields(log.Fields{ - "serviceName": serviceInfo.Name, + "serviceCcrn": serviceInfo.CCRN, }).Error("failed to fetch service") // Create new Service createServiceInput := &client.ServiceInput{ - Name: serviceInfo.Name, + Ccrn: serviceInfo.CCRN, } createServiceResp, err := client.CreateService(ctx, *p.Client, createServiceInput) if err != nil { - return "", fmt.Errorf("failed to create Service %s: %w", serviceInfo.Name, err) + return "", fmt.Errorf("failed to create Service %s: %w", serviceInfo.CCRN, err) } else { serviceId = createServiceResp.CreateService.Id } @@ -112,12 +112,12 @@ func (p *Processor) ProcessService(ctx context.Context, serviceInfo scanner.Serv _supportGroupId, err := p.getSupportGroup(ctx, serviceInfo) if err != nil { log.WithError(err).WithFields(log.Fields{ - "serviceName": serviceInfo.Name, + "serviceCcrn": serviceInfo.CCRN, }).Error("failed to fetch service") // Create new SupportGroup createSupportGroupInput := &client.SupportGroupInput{ - Name: serviceInfo.SupportGroup, + Ccrn: serviceInfo.SupportGroup, } createSupportGroupResp, err := client.CreateSupportGroup(ctx, *p.Client, createSupportGroupInput) if err != nil { @@ -133,7 +133,7 @@ func (p *Processor) ProcessService(ctx context.Context, serviceInfo scanner.Serv if err != nil { log.WithError(err).WithFields(log.Fields{ - "serviceName": serviceInfo.Name, + "serviceCcrn": serviceInfo.CCRN, "supportGroup": serviceInfo.SupportGroup, }).Warning("Failed adding service to support group") } @@ -145,7 +145,7 @@ func (p *Processor) getSupportGroup(ctx context.Context, serviceInfo scanner.Ser var supportGroupId string listSupportGroupsFilter := client.SupportGroupFilter{ - SupportGroupName: []string{serviceInfo.SupportGroup}, + SupportGroupCcrn: []string{serviceInfo.SupportGroup}, } listSupportGroupsResp, err := client.ListSupportGroups(ctx, *p.Client, &listSupportGroupsFilter) if err != nil { @@ -165,7 +165,7 @@ func (p *Processor) getSupportGroup(ctx context.Context, serviceInfo scanner.Ser // getService returns (if any) a ServiceID func (p *Processor) getService(ctx context.Context, serviceInfo scanner.ServiceInfo) (string, error) { listServicesFilter := client.ServiceFilter{ - ServiceName: []string{serviceInfo.Name}, + ServiceCcrn: []string{serviceInfo.CCRN}, } listServicesResp, err := client.ListServices(ctx, *p.Client, &listServicesFilter) if err != nil { @@ -238,7 +238,7 @@ func (p *Processor) ProcessPodReplicaSet(ctx context.Context, namespace string, func (p *Processor) getComponentVersion(ctx context.Context, image string, version string) (string, error) { listComponentVersionFilter := client.ComponentVersionFilter{ - ComponentName: []string{image}, + ComponentCcrn: []string{image}, Version: []string{version}, } listCompoVersResp, err := client.ListComponentVersions(ctx, *p.Client, &listComponentVersionFilter) @@ -302,7 +302,7 @@ func (p *Processor) ProcessContainer( return fmt.Errorf("cannot create Component (one or more containerInfo fields are empty)") } componentId, err := p.createComponent(ctx, &client.ComponentInput{ - Name: fmt.Sprintf("%s/%s/%s", containerInfo.ImageRegistry, containerInfo.ImageAccount, containerInfo.ImageRepository), + Ccrn: fmt.Sprintf("%s/%s/%s", containerInfo.ImageRegistry, containerInfo.ImageAccount, containerInfo.ImageRepository), Type: client.ComponentTypeValuesContainerimage, }) if err != nil { diff --git a/scanner/k8s-assets/scanner/config.go b/scanner/k8s-assets/scanner/config.go index 2cf48ab4..60e5a158 100644 --- a/scanner/k8s-assets/scanner/config.go +++ b/scanner/k8s-assets/scanner/config.go @@ -8,6 +8,6 @@ type Config struct { KubeconfigContext string `envconfig:"KUBE_CONFIG_CONTEXT"` KubeconfigType string `envconfig:"KUBE_CONFIG_TYPE" default:"oidc"` SupportGroupLabel string `envconfig:"SUPPORT_GROUP_LABEL" default:"ccloud/support-group" required:"true"` - ServiceNameLabel string `envconfig:"SERVICE_NAME_LABEL" default:"ccloud/service" required:"true"` + ServiceCCRNLabel string `envconfig:"SERVICE_CCRN_LABEL" default:"ccloud/service" required:"true"` ScannerTimeout string `envconfig:"SCANNER_TIMEOUT" default:"30m"` } diff --git a/scanner/k8s-assets/scanner/scanner.go b/scanner/k8s-assets/scanner/scanner.go index dd9c4e72..f2480294 100644 --- a/scanner/k8s-assets/scanner/scanner.go +++ b/scanner/k8s-assets/scanner/scanner.go @@ -24,7 +24,7 @@ type Scanner struct { } type ServiceInfo struct { - Name string + CCRN string SupportGroup string Pods []PodInfo } @@ -62,7 +62,7 @@ type ContainerInfo struct { type PodLabels struct { SupportGroup string Owner string - ServiceName string + ServiceCCRN string } func NewScanner(kubeConfig *rest.Config, clientSet *kubernetes.Clientset, cfg Config) Scanner { @@ -87,8 +87,8 @@ func (s *Scanner) GetRelevantLabels(pod v1.Pod) PodLabels { podLabels := PodLabels{} for labelName, labelValue := range pod.Labels { switch labelName { - case s.Config.ServiceNameLabel: - podLabels.ServiceName = labelValue + case s.Config.ServiceCCRNLabel: + podLabels.ServiceCCRN = labelValue case s.Config.SupportGroupLabel: podLabels.SupportGroup = labelValue default: @@ -220,7 +220,7 @@ func (s *Scanner) GroupPodsByGenerateName(pods []v1.Pod) []PodReplicaSet { // GetServiceInfo extracts meta information from a PodInfo object func (s *Scanner) GetServiceInfo(podInfo PodInfo) ServiceInfo { return ServiceInfo{ - Name: podInfo.Labels.ServiceName, + CCRN: podInfo.Labels.ServiceCCRN, SupportGroup: podInfo.Labels.SupportGroup, } } diff --git a/scanner/keppel/client/generated.go b/scanner/keppel/client/generated.go index 738c3ab5..b6a680fa 100644 --- a/scanner/keppel/client/generated.go +++ b/scanner/keppel/client/generated.go @@ -24,15 +24,15 @@ func (v *AddComponentVersionToIssueResponse) GetAddComponentVersionToIssue() *Is // Component includes the requested fields of the GraphQL type Component. type Component struct { Id string `json:"id"` - Name string `json:"name"` + Ccrn string `json:"ccrn"` Type ComponentTypeValues `json:"type"` } // GetId returns Component.Id, and is useful for accessing the field via an interface. func (v *Component) GetId() string { return v.Id } -// GetName returns Component.Name, and is useful for accessing the field via an interface. -func (v *Component) GetName() string { return v.Name } +// GetCcrn returns Component.Ccrn, and is useful for accessing the field via an interface. +func (v *Component) GetCcrn() string { return v.Ccrn } // GetType returns Component.Type, and is useful for accessing the field via an interface. func (v *Component) GetType() ComponentTypeValues { return v.Type } @@ -40,7 +40,7 @@ func (v *Component) GetType() ComponentTypeValues { return v.Type } // ComponentAggregate includes the requested fields of the GraphQL type Component. type ComponentAggregate struct { Id string `json:"id"` - Name string `json:"name"` + Ccrn string `json:"ccrn"` Type ComponentTypeValues `json:"type"` ComponentVersions *ComponentVersions `json:"componentVersions"` } @@ -48,8 +48,8 @@ type ComponentAggregate struct { // GetId returns ComponentAggregate.Id, and is useful for accessing the field via an interface. func (v *ComponentAggregate) GetId() string { return v.Id } -// GetName returns ComponentAggregate.Name, and is useful for accessing the field via an interface. -func (v *ComponentAggregate) GetName() string { return v.Name } +// GetCcrn returns ComponentAggregate.Ccrn, and is useful for accessing the field via an interface. +func (v *ComponentAggregate) GetCcrn() string { return v.Ccrn } // GetType returns ComponentAggregate.Type, and is useful for accessing the field via an interface. func (v *ComponentAggregate) GetType() ComponentTypeValues { return v.Type } @@ -82,19 +82,19 @@ func (v *ComponentConnectionEdgesComponentEdge) GetNode() *ComponentAggregate { func (v *ComponentConnectionEdgesComponentEdge) GetCursor() string { return v.Cursor } type ComponentFilter struct { - ComponentName []string `json:"componentName"` + ComponentCcrn []string `json:"componentCcrn"` } -// GetComponentName returns ComponentFilter.ComponentName, and is useful for accessing the field via an interface. -func (v *ComponentFilter) GetComponentName() []string { return v.ComponentName } +// GetComponentCcrn returns ComponentFilter.ComponentCcrn, and is useful for accessing the field via an interface. +func (v *ComponentFilter) GetComponentCcrn() []string { return v.ComponentCcrn } type ComponentInput struct { - Name string `json:"name"` + Ccrn string `json:"ccrn"` Type ComponentTypeValues `json:"type"` } -// GetName returns ComponentInput.Name, and is useful for accessing the field via an interface. -func (v *ComponentInput) GetName() string { return v.Name } +// GetCcrn returns ComponentInput.Ccrn, and is useful for accessing the field via an interface. +func (v *ComponentInput) GetCcrn() string { return v.Ccrn } // GetType returns ComponentInput.Type, and is useful for accessing the field via an interface. func (v *ComponentInput) GetType() ComponentTypeValues { return v.Type } @@ -145,7 +145,7 @@ func (v *ComponentVersionConnectionEdgesComponentVersionEdge) GetNode() *Compone type ComponentVersionFilter struct { ComponentId []string `json:"componentId"` - ComponentName []string `json:"componentName"` + ComponentCcrn []string `json:"componentCcrn"` IssueId []string `json:"issueId"` Version []string `json:"version"` } @@ -153,8 +153,8 @@ type ComponentVersionFilter struct { // GetComponentId returns ComponentVersionFilter.ComponentId, and is useful for accessing the field via an interface. func (v *ComponentVersionFilter) GetComponentId() []string { return v.ComponentId } -// GetComponentName returns ComponentVersionFilter.ComponentName, and is useful for accessing the field via an interface. -func (v *ComponentVersionFilter) GetComponentName() []string { return v.ComponentName } +// GetComponentCcrn returns ComponentVersionFilter.ComponentCcrn, and is useful for accessing the field via an interface. +func (v *ComponentVersionFilter) GetComponentCcrn() []string { return v.ComponentCcrn } // GetIssueId returns ComponentVersionFilter.IssueId, and is useful for accessing the field via an interface. func (v *ComponentVersionFilter) GetIssueId() []string { return v.IssueId } @@ -455,7 +455,7 @@ const CreateComponent_Operation = ` mutation CreateComponent ($input: ComponentInput!) { createComponent(input: $input) { id - name + ccrn type } } @@ -611,7 +611,7 @@ query ListComponents ($filter: ComponentFilter, $first: Int, $after: String) { edges { node { id - name + ccrn type componentVersions { edges { diff --git a/scanner/keppel/client/query/createComponent.graphql b/scanner/keppel/client/query/createComponent.graphql index 33849abf..6e4824b0 100644 --- a/scanner/keppel/client/query/createComponent.graphql +++ b/scanner/keppel/client/query/createComponent.graphql @@ -7,7 +7,7 @@ mutation CreateComponent($input: ComponentInput!) { input: $input ) { id - name + ccrn type } } \ No newline at end of file diff --git a/scanner/keppel/client/query/listComponentsAndVersions.graphql b/scanner/keppel/client/query/listComponentsAndVersions.graphql index 785c1929..0c96e9b0 100644 --- a/scanner/keppel/client/query/listComponentsAndVersions.graphql +++ b/scanner/keppel/client/query/listComponentsAndVersions.graphql @@ -14,7 +14,7 @@ query ListComponents($filter: ComponentFilter, $first: Int, $after: String) { # @genqlient(typename: "ComponentAggregate") node { id - name + ccrn type # @genqlient(typename: "ComponentVersions") componentVersions { diff --git a/scanner/keppel/go.mod b/scanner/keppel/go.mod index a1337b2a..de386a77 100644 --- a/scanner/keppel/go.mod +++ b/scanner/keppel/go.mod @@ -12,6 +12,9 @@ require ( ) require ( + github.com/agnivade/levenshtein v1.1.1 // indirect + github.com/alexflint/go-arg v1.4.2 // indirect + github.com/alexflint/go-scalar v1.0.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-task/slim-sprig/v3 v3.0.0 // indirect github.com/google/go-cmp v0.6.0 // indirect @@ -19,9 +22,12 @@ require ( github.com/kr/pretty v0.3.1 // indirect github.com/vektah/gqlparser/v2 v2.5.15 // indirect golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 // indirect + golang.org/x/mod v0.20.0 // indirect golang.org/x/net v0.28.0 // indirect + golang.org/x/sync v0.8.0 // indirect golang.org/x/sys v0.24.0 // indirect golang.org/x/tools v0.24.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/scanner/keppel/go.sum b/scanner/keppel/go.sum index 5eed80a7..cde0ea95 100644 --- a/scanner/keppel/go.sum +++ b/scanner/keppel/go.sum @@ -1,16 +1,24 @@ github.com/Khan/genqlient v0.7.0 h1:GZ1meyRnzcDTK48EjqB8t3bcfYvHArCUUvgOwpz1D4w= github.com/Khan/genqlient v0.7.0/go.mod h1:HNyy3wZvuYwmW3Y7mkoQLZsa/R5n5yIRajS1kPBvSFM= +github.com/agnivade/levenshtein v1.1.1 h1:QY8M92nrzkmr798gCo3kmMyqXFzdQVpxLlGPRBij0P8= +github.com/agnivade/levenshtein v1.1.1/go.mod h1:veldBMzWxcCG2ZvUTKD2kJNRdCk5hVbJomOvKkmgYbo= +github.com/alexflint/go-arg v1.4.2 h1:lDWZAXxpAnZUq4qwb86p/3rIJJ2Li81EoMbTMujhVa0= +github.com/alexflint/go-arg v1.4.2/go.mod h1:9iRbDxne7LcR/GSvEr7ma++GLpdIU1zrghf2y2768kM= +github.com/alexflint/go-scalar v1.0.0 h1:NGupf1XV/Xb04wXskDFzS0KWOLH632W/EO4fAFi+A70= +github.com/alexflint/go-scalar v1.0.0/go.mod h1:GpHzbCOZXEKMEcygYQ5n/aa4Aq84zbxjy3MxYW0gjYw= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883 h1:bvNMNQO63//z+xNgfBlViaCIJKLlCJ6/fmUseuG0wVQ= github.com/andreyvit/diff v0.0.0-20170406064948-c7f18ee00883/go.mod h1:rCTlJbsFo29Kk6CurOXKm700vrz8f0KW0JNfpkRJY/8= github.com/aquasecurity/trivy v0.54.1 h1:/uNCF06PfdC69v5n3Zh4fXVf0xmXBml0c/ergf066SQ= github.com/aquasecurity/trivy v0.54.1/go.mod h1:i5S54WUtOEN9egFF0AHsxq6XT7QD11n9pSmIXhMJV0g= github.com/aquasecurity/trivy-db v0.0.0-20240718084044-d23a6ca8ba04 h1:6/T8sFdNVG/AwOGoK6X55h7hF7LYqK8bsuPz8iEz8jM= github.com/aquasecurity/trivy-db v0.0.0-20240718084044-d23a6ca8ba04/go.mod h1:0T6oy2t1Iedt+yi3Ml5cpOYp5FZT4MI1/mx+3p+PIs8= +github.com/arbovm/levenshtein v0.0.0-20160628152529-48b4e1c0c4d0/go.mod h1:t2tdKJDJF9BV14lnkjHmOQgcvEKgtqs5a1N3LNdJhGE= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgryski/trifles v0.0.0-20200323201526-dd97f9abfb48/go.mod h1:if7Fbed8SFyPtHLHbg49SI7NAdJiC5WIA09pe59rfAA= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-task/slim-sprig/v3 v3.0.0 h1:sUs3vkvUymDpBKi3qH1YSqBQk9+9D/8M2mN1vB6EwHI= @@ -49,6 +57,7 @@ github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3/go.mod h1:A0bzQcvG github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= @@ -57,9 +66,13 @@ github.com/vektah/gqlparser/v2 v2.5.15/go.mod h1:WQQjFc+I1YIzoPvZBhUQX7waZgg3pML golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56 h1:2dVuKD2vS7b0QIHQbpyTISPd0LeHDbnYEryqj5Q1ug8= golang.org/x/exp v0.0.0-20240719175910-8a7402abbf56/go.mod h1:M4RDyNAINzryxdtnbRXRL/OHtkFuWGRjvuhBJpk2IlY= +golang.org/x/mod v0.20.0 h1:utOm6MM3R3dnawAiJgn0y+xvuYRsm1RKM/4giyfDgV0= +golang.org/x/mod v0.20.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -80,6 +93,7 @@ google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWn gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/scanner/keppel/main.go b/scanner/keppel/main.go index 31bb7d43..c3b09a01 100644 --- a/scanner/keppel/main.go +++ b/scanner/keppel/main.go @@ -154,11 +154,11 @@ func processComponent( keppelScanner *scanner.Scanner, keppelProcessor *processor.Processor, ) error { - log.Infof("Processing component: %s", comp.Name) + log.Infof("Processing component: %s", comp.Ccrn) - imageInfo, err := keppelScanner.ExtractImageInfo(comp.Name) + imageInfo, err := keppelScanner.ExtractImageInfo(comp.Ccrn) if err != nil { - return fmt.Errorf("Cannot extract image information from component name: %w", err) + return fmt.Errorf("Cannot extract image information from component ccrn: %w", err) } for _, cv := range comp.ComponentVersions.Edges { diff --git a/scanner/keppel/processor/processor.go b/scanner/keppel/processor/processor.go index fedc64bc..18776b2b 100644 --- a/scanner/keppel/processor/processor.go +++ b/scanner/keppel/processor/processor.go @@ -28,7 +28,7 @@ func NewProcessor(cfg Config) *Processor { func (p *Processor) ProcessRepository(registry string, account models.Account, repository models.Repository) (*client.Component, error) { r, err := client.CreateComponent(context.Background(), *p.Client, &client.ComponentInput{ - Name: fmt.Sprintf("%s/%s/%s", registry, account.Name, repository.Name), + Ccrn: fmt.Sprintf("%s/%s/%s", registry, account.Name, repository.Name), Type: client.ComponentTypeValuesContainerimage, })