Skip to content
This repository has been archived by the owner on Jul 4, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into data-center-aggrregation-support
Browse files Browse the repository at this point in the history
  • Loading branch information
NickyMateev committed Apr 2, 2024
2 parents 957a059 + cb99a0d commit 0dd0d9f
Show file tree
Hide file tree
Showing 28 changed files with 1,593 additions and 77 deletions.
6 changes: 3 additions & 3 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -207,11 +207,11 @@ global:
name: compass-operations-controller
ord_service:
dir: dev/incubator/
version: "PR-127"
version: "PR-128"
name: compass-ord-service
schema_migrator:
dir: dev/incubator/
version: "PR-3779"
version: "PR-3763"
name: compass-schema-migrator
system_broker:
dir: dev/incubator/
Expand All @@ -232,7 +232,7 @@ global:
name: compass-console
e2e_tests:
dir: dev/incubator/
version: "PR-3702"
version: "PR-3777"
name: compass-e2e-tests
isLocalEnv: false
isForTesting: false
Expand Down

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

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

55 changes: 53 additions & 2 deletions components/director/internal/domain/application/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (
"fmt"
"strings"

"github.com/kyma-incubator/compass/components/director/pkg/resource"

"github.com/kyma-incubator/compass/components/director/internal/domain/scenarioassignment"
"github.com/kyma-incubator/compass/components/director/internal/open_resource_discovery/data"
"github.com/kyma-incubator/compass/components/director/pkg/consumer"
"github.com/kyma-incubator/compass/components/director/pkg/resource"
"github.com/kyma-incubator/compass/components/director/pkg/str"

pkgmodel "github.com/kyma-incubator/compass/components/director/pkg/model"
Expand Down Expand Up @@ -132,6 +132,13 @@ type BundleService interface {
CreateMultiple(ctx context.Context, resourceType resource.Type, resourceID string, in []*model.BundleCreateInput) error
}

// OperationService is responsible for the service-layer Operation operations
//
//go:generate mockery --name=OperationService --output=automock --outpkg=automock --case=underscore --disable-version-string
type OperationService interface {
GetByDataAndType(ctx context.Context, data interface{}, opType model.OperationType) (*model.Operation, error)
}

// APIDefinitionService missing godoc
//
//go:generate mockery --name=APIDefinitionService --output=automock --outpkg=automock --case=underscore --disable-version-string
Expand Down Expand Up @@ -204,6 +211,13 @@ type BundleConverter interface {
MultipleCreateInputFromGraphQL(in []*graphql.BundleCreateInput) ([]*model.BundleCreateInput, error)
}

// OperationConverter is responsible for converting between graphql and model objects
//
//go:generate mockery --name=OperationConverter --output=automock --outpkg=automock --case=underscore --disable-version-string
type OperationConverter interface {
MultipleToGraphQL(in []*model.Operation) ([]*graphql.Operation, error)
}

// OneTimeTokenService missing godoc
//
//go:generate mockery --name=OneTimeTokenService --output=automock --outpkg=automock --case=underscore --disable-version-string
Expand Down Expand Up @@ -240,6 +254,7 @@ type Resolver struct {
oAuth20Svc OAuth20Service
sysAuthSvc SystemAuthService
bndlSvc BundleService
opSvc OperationService

integrationDependencySvc IntegrationDependencyService
integrationDependencyConv IntegrationDependencyConverter
Expand All @@ -258,6 +273,7 @@ type Resolver struct {
sysAuthConv SystemAuthConverter
eventingSvc EventingService
bndlConv BundleConverter
opConv OperationConverter

selfRegisterDistinguishLabelKey string
tokenPrefix string
Expand Down Expand Up @@ -286,6 +302,8 @@ func NewResolver(transact persistence.Transactioner,
eventDefinitionConverter EventDefinitionConverter,
appTemplateSvc ApplicationTemplateService,
appTemplateConverter ApplicationTemplateConverter,
operationService OperationService,
operationConverter OperationConverter,
selfRegisterDistinguishLabelKey, tokenPrefix string) *Resolver {
return &Resolver{
transact: transact,
Expand All @@ -310,6 +328,8 @@ func NewResolver(transact persistence.Transactioner,
bndlConv: bndlConverter,
appTemplateSvc: appTemplateSvc,
appTemplateConverter: appTemplateConverter,
opSvc: operationService,
opConv: operationConverter,
selfRegisterDistinguishLabelKey: selfRegisterDistinguishLabelKey,
tokenPrefix: tokenPrefix,
}
Expand Down Expand Up @@ -859,6 +879,37 @@ func (r *Resolver) EventingConfiguration(ctx context.Context, obj *graphql.Appli
return eventing.ApplicationEventingConfigurationToGraphQL(eventingCfg), nil
}

// Operations retrieves all ORD operations associated with given application
func (r *Resolver) Operations(ctx context.Context, obj *graphql.Application) ([]*graphql.Operation, error) {
if obj == nil {
return nil, apperrors.NewInternalError("Application cannot be empty")
}

tx, err := r.transact.Begin()
if err != nil {
return nil, errors.Wrap(err, "while opening the transaction")
}
defer r.transact.RollbackUnlessCommitted(ctx, tx)

ctx = persistence.SaveToContext(ctx, tx)

appTemplateID := ""
if obj.ApplicationTemplateID != nil {
appTemplateID = *obj.ApplicationTemplateID
}

op, err := r.opSvc.GetByDataAndType(ctx, data.NewOrdOperationData(obj.ID, appTemplateID), model.OperationTypeOrdAggregation)
if err != nil && !apperrors.IsNotFoundError(err) {
return nil, errors.Wrap(err, "while getting operation")
}

if err = tx.Commit(); err != nil {
return nil, errors.Wrap(err, "while committing the transaction")
}

return r.opConv.MultipleToGraphQL([]*model.Operation{op})
}

// Bundles missing godoc
func (r *Resolver) Bundles(ctx context.Context, obj *graphql.Application, first *int, after *graphql.PageCursor) (*graphql.BundlePage, error) {
param := dataloader.ParamBundle{ID: obj.ID, Ctx: ctx, First: first, After: after}
Expand Down
Loading

0 comments on commit 0dd0d9f

Please sign in to comment.