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

Commit

Permalink
Remove implicit label def creation (#2095)
Browse files Browse the repository at this point in the history
* remove implicit label def creation

* bump version

* adjust e2e test for ld

* add e2e test for self register

* do not add default scenario to subaccounts

* add subaccount check in runtime e2e test

* add parent relation
  • Loading branch information
ataleksandrov authored Nov 1, 2021
1 parent 3f70163 commit 8459a61
Show file tree
Hide file tree
Showing 23 changed files with 543 additions and 964 deletions.
5 changes: 3 additions & 2 deletions chart/compass/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ global:
- name: TestProviderSubaccount
id: f8075207-1478-4a80-bd26-24a4785a2bfd
type: subaccount
parent: 5577cf46-4f78-45fa-b55f-a42a3bdba868

images:
containerRegistry:
Expand All @@ -78,7 +79,7 @@ global:
version: "PR-2082"
director:
dir:
version: "PR-2091"
version: "PR-2095"
gateway:
dir:
version: "PR-2077"
Expand Down Expand Up @@ -107,7 +108,7 @@ global:
version: "PR-46"
e2e_tests:
dir:
version: "PR-2091"
version: "PR-2095"
isLocalEnv: false
oauth2:
host: oauth2
Expand Down
7 changes: 3 additions & 4 deletions components/director/cmd/director/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ func getRuntimeMappingHandlerFunc(ctx context.Context, transact persistence.Tran
labelDefConverter := labeldef.NewConverter()
labelDefRepo := labeldef.NewRepository(labelDefConverter)
scenarioAssignmentRepo := scenarioassignment.NewRepository(assignmentConv)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, uidSvc, defaultScenarioEnabled)
tenantRepo := tenant.NewRepository(tenant.NewConverter())
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, tenantRepo, uidSvc, defaultScenarioEnabled)
labelSvc := label.NewLabelService(labelRepo, labelDefRepo, uidSvc)
runtimeConv := runtime.NewConverter()
runtimeRepo := runtime.NewRepository(runtimeConv)
Expand All @@ -452,8 +453,6 @@ func getRuntimeMappingHandlerFunc(ctx context.Context, transact persistence.Tran

runtimeSvc := runtime.NewService(runtimeRepo, labelRepo, scenariosSvc, labelSvc, uidSvc, scenarioAssignmentEngine, protectedLabelPattern)

tenantConv := tenant.NewConverter()
tenantRepo := tenant.NewRepository(tenantConv)
tenantSvc := tenant.NewService(tenantRepo, uidSvc)

reqDataParser := oathkeeper.NewReqDataParser()
Expand Down Expand Up @@ -581,7 +580,7 @@ func tokenService(cfg config, cfgProvider *configprovider.Provider, httpClient,
labelDefRepo := labeldef.NewRepository(labelDefConverter)
labelUpsertSvc := label.NewLabelService(labelRepo, labelDefRepo, uidSvc)
scenarioAssignmentRepo := scenarioassignment.NewRepository(assignmentConv)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, uidSvc, cfg.Features.DefaultScenarioEnabled)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, tenantRepo, uidSvc, cfg.Features.DefaultScenarioEnabled)
bundleRepo := bundle.NewRepository(packageConverter)
apiRepo := api.NewRepository(apiConverter)
docRepo := document.NewRepository(docConverter)
Expand Down
5 changes: 4 additions & 1 deletion components/director/cmd/ordaggregator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"net/http"
"time"

"github.com/kyma-incubator/compass/components/director/internal/domain/tenant"

"github.com/kyma-incubator/compass/components/director/internal/domain/scenarioassignment"

"github.com/kyma-incubator/compass/components/director/internal/open_resource_discovery/accessstrategy"
Expand Down Expand Up @@ -135,7 +137,8 @@ func createORDAggregatorSvc(cfgProvider *configprovider.Provider, featuresConfig
labelSvc := label.NewLabelService(labelRepo, labelDefRepo, uidSvc)
assignmentConv := scenarioassignment.NewConverter()
scenarioAssignmentRepo := scenarioassignment.NewRepository(assignmentConv)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, uidSvc, featuresConfig.DefaultScenarioEnabled)
tenantRepo := tenant.NewRepository(tenant.NewConverter())
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, tenantRepo, uidSvc, featuresConfig.DefaultScenarioEnabled)
fetchRequestSvc := fetchrequest.NewService(fetchRequestRepo, httpClient, accessStrategyExecutorProvider)
specSvc := spec.NewService(specRepo, fetchRequestRepo, uidSvc, fetchRequestSvc)
bundleReferenceSvc := bundlereferences.NewService(bundleReferenceRepo, uidSvc)
Expand Down
2 changes: 1 addition & 1 deletion components/director/cmd/systemfetcher/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func createSystemFetcher(cfg config, cfgProvider *configprovider.Provider, tx pe
labelSvc := label.NewLabelService(labelRepo, labelDefRepo, uidSvc)
assignmentConv := scenarioassignment.NewConverter()
scenarioAssignmentRepo := scenarioassignment.NewRepository(assignmentConv)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, uidSvc, cfg.Features.DefaultScenarioEnabled)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, tenantRepo, uidSvc, cfg.Features.DefaultScenarioEnabled)
fetchRequestSvc := fetchrequest.NewService(fetchRequestRepo, httpClient, accessstrategy.NewDefaultExecutorProvider())
specSvc := spec.NewService(specRepo, fetchRequestRepo, uidSvc, fetchRequestSvc)
bundleReferenceSvc := bundlereferences.NewService(bundleReferenceRepo, uidSvc)
Expand Down
2 changes: 1 addition & 1 deletion components/director/cmd/tenantfetcher-job/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func createTenantFetcherSvc(cfg config, transact persistence.Transactioner, kube
scenarioAssignEngine := scenarioassignment.NewEngine(labelService, labelRepository, scenarioAssignRepo)

scenarioAssignmentRepo := scenarioassignment.NewRepository(scenarioAssignConv)
labelDefService := labeldef.NewService(labelDefRepository, labelRepository, scenarioAssignmentRepo, uidSvc, cfg.Features.DefaultScenarioEnabled)
labelDefService := labeldef.NewService(labelDefRepository, labelRepository, scenarioAssignmentRepo, tenantStorageRepo, uidSvc, cfg.Features.DefaultScenarioEnabled)

runtimeConverter := runtime.NewConverter()
runtimeRepository := runtime.NewRepository(runtimeConverter)
Expand Down
2 changes: 1 addition & 1 deletion components/director/cmd/tenantfetcher-svc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func registerHandler(ctx context.Context, router *mux.Router, cfg tenantfetcher.
assignmentConv := scenarioassignment.NewConverter()
scenarioAssignmentRepo := scenarioassignment.NewRepository(assignmentConv)
scenarioAssignmentEngine := scenarioassignment.NewEngine(labelSvc, labelRepo, scenarioAssignmentRepo)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, uidSvc, cfg.DefaultScenarioEnabled)
scenariosSvc := labeldef.NewService(labelDefRepo, labelRepo, scenarioAssignmentRepo, tenantRepo, uidSvc, cfg.DefaultScenarioEnabled)
runtimeSvc := runtime.NewService(runtimeRepo, labelRepo, scenariosSvc, labelSvc, uidSvc, scenarioAssignmentEngine, cfg.ProtectedLabelPattern)

provisioner := tenantfetcher.NewTenantProvisioner(tenantSvc, cfg.TenantProvider)
Expand Down

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

10 changes: 2 additions & 8 deletions components/director/internal/domain/application/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type LabelUpsertService interface {
//go:generate mockery --name=ScenariosService --output=automock --outpkg=automock --case=underscore
type ScenariosService interface {
EnsureScenariosLabelDefinitionExists(ctx context.Context, tenant string) error
AddDefaultScenarioIfEnabled(ctx context.Context, labels *map[string]interface{})
AddDefaultScenarioIfEnabled(ctx context.Context, tenant string, labels *map[string]interface{})
}

// UIDService missing godoc
Expand Down Expand Up @@ -584,13 +584,7 @@ func (s *service) genericCreate(ctx context.Context, in model.ApplicationRegiste
return "", err
}

log.C(ctx).Debugf("Ensuring Scenarios label definition exists for Tenant %s", appTenant)
err = s.scenariosService.EnsureScenariosLabelDefinitionExists(ctx, appTenant)
if err != nil {
return "", err
}

s.scenariosService.AddDefaultScenarioIfEnabled(ctx, &in.Labels)
s.scenariosService.AddDefaultScenarioIfEnabled(ctx, appTenant, &in.Labels)

if in.Labels == nil {
in.Labels = map[string]interface{}{}
Expand Down
Loading

0 comments on commit 8459a61

Please sign in to comment.