Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KIM Integration - Purpose default configurable per landscape #1234

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (s *CreateRuntimeResourceStep) Run(operation internal.Operation, log logrus
func (s *CreateRuntimeResourceStep) updateRuntimeResourceObject(runtime *imv1.Runtime, operation internal.Operation, runtimeName, kymaName, kymaNamespace string) error {

// get plan specific values (like zones, default machine type etc.
values, err := provider.GenerateValues(&operation, s.config.MultiZoneCluster, s.config.DefaultTrialProvider, s.useSmallerMachineTypes, s.trialPlatformRegionMapping)
values, err := provider.GenerateValues(&operation, s.config.MultiZoneCluster, s.config.DefaultTrialProvider, s.useSmallerMachineTypes, s.trialPlatformRegionMapping, s.config.DefaultGardenerShootPurpose)
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"strings"
"testing"

"github.com/kyma-project/kyma-environment-broker/internal/provider"

"github.com/pivotal-cf/brokerapi/v8/domain"

"github.com/kyma-project/kyma-environment-broker/internal/networking"
Expand Down Expand Up @@ -222,7 +224,7 @@ func TestCreateRuntimeResourceStep_Defaults_AWS_SingleZone_EnforceSeed_ActualCre
assertInsertions(t, memoryStorage, instance, operation)

kimConfig := fixKimConfig("aws", false)
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone"}
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone", DefaultGardenerShootPurpose: provider.PurposeProduction}

cli := getClientForTests(t)
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)
Expand Down Expand Up @@ -272,7 +274,7 @@ func TestCreateRuntimeResourceStep_Defaults_AWS_SingleZone_DisableEnterpriseFilt
assertInsertions(t, memoryStorage, instance, operation)

kimConfig := fixKimConfig("aws", false)
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone"}
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone", DefaultGardenerShootPurpose: provider.PurposeProduction}

cli := getClientForTests(t)
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)
Expand Down Expand Up @@ -322,7 +324,7 @@ func TestCreateRuntimeResourceStep_Defaults_AWS_SingleZone_DefaultAdmin_ActualCr
assertInsertions(t, memoryStorage, instance, operation)

kimConfig := fixKimConfig("aws", false)
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone"}
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone", DefaultGardenerShootPurpose: provider.PurposeProduction}

cli := getClientForTests(t)
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)
Expand Down Expand Up @@ -371,7 +373,7 @@ func TestCreateRuntimeResourceStep_Defaults_AWS_SingleZone_DryRun_ActualCreation

kimConfig := fixKimConfig("aws", false)
kimConfig.ViewOnly = true
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone"}
inputConfig := input.Config{MultiZoneCluster: false, ControlPlaneFailureTolerance: "zone", DefaultGardenerShootPurpose: provider.PurposeProduction}

cli := getClientForTests(t)
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)
Expand Down Expand Up @@ -427,7 +429,7 @@ func TestCreateRuntimeResourceStep_Defaults_AWS_MultiZoneWithNetworking_ActualCr
kimConfig := fixKimConfig("aws", false)

cli := getClientForTests(t)
inputConfig := input.Config{MultiZoneCluster: true}
inputConfig := input.Config{MultiZoneCluster: true, DefaultGardenerShootPurpose: provider.PurposeProduction}
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)

// when
Expand Down Expand Up @@ -479,7 +481,7 @@ func TestCreateRuntimeResourceStep_Defaults_AWS_MultiZone_ActualCreation(t *test
kimConfig := fixKimConfig("aws", false)

cli := getClientForTests(t)
inputConfig := input.Config{MultiZoneCluster: true}
inputConfig := input.Config{MultiZoneCluster: true, DefaultGardenerShootPurpose: provider.PurposeProduction}
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)

// when
Expand Down Expand Up @@ -524,7 +526,7 @@ func TestCreateRuntimeResourceStep_Defaults_Preview_SingleZone_ActualCreation(t
kimConfig := fixKimConfig("preview", false)

cli := getClientForTests(t)
inputConfig := input.Config{MultiZoneCluster: false}
inputConfig := input.Config{MultiZoneCluster: false, DefaultGardenerShootPurpose: provider.PurposeProduction}
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)

// when
Expand Down Expand Up @@ -570,7 +572,7 @@ func TestCreateRuntimeResourceStep_Defaults_Preview_SingleZone_ActualCreation_Wi
kimConfig := fixKimConfig("preview", false)

cli := getClientForTests(t)
inputConfig := input.Config{MultiZoneCluster: false}
inputConfig := input.Config{MultiZoneCluster: false, DefaultGardenerShootPurpose: provider.PurposeProduction}
step := NewCreateRuntimeResourceStep(memoryStorage.Operations(), memoryStorage.Instances(), cli, kimConfig, inputConfig, nil, false, defaultOIDSConfig)

// when
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

type (
AWSInputProvider struct {
Purpose string
MultiZone bool
ProvisioningParameters internal.ProvisioningParameters
}
Expand Down Expand Up @@ -36,7 +37,7 @@ func (p *AWSInputProvider) Provide() Values {
ProviderType: "aws",
DefaultMachineType: DefaultAWSMachineType,
Region: region,
Purpose: PurposeProduction,
Purpose: p.Purpose,
VolumeSizeGb: 80,
DiskType: "gp3",
}
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func TestAWSDefaults(t *testing.T) {

// given
provider := AWSInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: nil},
Expand Down Expand Up @@ -44,6 +45,7 @@ func TestAWSSpecific(t *testing.T) {

// given
provider := AWSInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
Expand Down
6 changes: 4 additions & 2 deletions internal/provider/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

type (
AzureInputProvider struct {
Purpose string
MultiZone bool
ProvisioningParameters internal.ProvisioningParameters
}
Expand All @@ -16,6 +17,7 @@ type (
ProvisioningParameters internal.ProvisioningParameters
}
AzureLiteInputProvider struct {
Purpose string
UseSmallerMachineTypes bool
ProvisioningParameters internal.ProvisioningParameters
}
Expand All @@ -40,7 +42,7 @@ func (p *AzureInputProvider) Provide() Values {
ProviderType: "azure",
DefaultMachineType: DefaultAzureMachineType,
Region: region,
Purpose: PurposeProduction,
Purpose: p.Purpose,
DiskType: "StandardSSD_LRS",
VolumeSizeGb: 80,
}
Expand Down Expand Up @@ -123,7 +125,7 @@ func (p *AzureLiteInputProvider) Provide() Values {
ProviderType: "azure",
DefaultMachineType: machineType,
Region: region,
Purpose: PurposeEvaluation,
Purpose: p.Purpose,
DiskType: "Standard_LRS",
VolumeSizeGb: 50,
}
Expand Down
4 changes: 4 additions & 0 deletions internal/provider/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ func TestAzureDefaults(t *testing.T) {

// given
azure := AzureInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eastus")},
Expand Down Expand Up @@ -73,6 +74,7 @@ func TestAzureLiteDefaults(t *testing.T) {

// given
azure := AzureLiteInputProvider{
Purpose: PurposeEvaluation,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eastus")},
PlatformRegion: "cf-eu11",
Expand Down Expand Up @@ -102,6 +104,7 @@ func TestAzureSpecific(t *testing.T) {

// given
azure := AzureInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
Expand Down Expand Up @@ -173,6 +176,7 @@ func TestAzureLiteSpecific(t *testing.T) {

// given
azure := AzureLiteInputProvider{
Purpose: PurposeEvaluation,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
MachineType: ptr.String("Standard_D48_v3"),
Expand Down
4 changes: 3 additions & 1 deletion internal/provider/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@ import (

type (
GCPInputProvider struct {
Purpose string
MultiZone bool
ProvisioningParameters internal.ProvisioningParameters
}

GCPTrialInputProvider struct {
Purpose string
PlatformRegionMapping map[string]string
ProvisioningParameters internal.ProvisioningParameters
}
Expand All @@ -29,7 +31,7 @@ func (p *GCPInputProvider) Provide() Values {
ProviderType: "gcp",
DefaultMachineType: DefaultGCPMachineType,
Region: region,
Purpose: PurposeProduction,
Purpose: p.Purpose,
VolumeSizeGb: 80,
DiskType: "pd-balanced",
}
Expand Down
2 changes: 2 additions & 0 deletions internal/provider/gcp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func TestGCPDefaults(t *testing.T) {

// given
provider := GCPInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: nil},
Expand Down Expand Up @@ -41,6 +42,7 @@ func TestGCPSpecific(t *testing.T) {

// given
provider := GCPInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
Expand Down
3 changes: 1 addition & 2 deletions internal/provider/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ type Values struct {
ProviderType string
DefaultMachineType string
Region string
Purpose string //TODO default per landscape in configuration
Purpose string
VolumeSizeGb int
DiskType string
// todo: add other plan specific values
}
7 changes: 7 additions & 0 deletions internal/provider/provider_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,37 @@ func GenerateValues(
defaultTrialProvider internal.CloudProvider,
useSmallerMachineTypes bool,
trialPlatformRegionMapping map[string]string,
defaultPurpose string,
) (Values, error) {
var p Provider
switch operation.ProvisioningParameters.PlanID {
case broker.AWSPlanID:
p = &AWSInputProvider{
Purpose: defaultPurpose,
MultiZone: multiZoneCluster,
ProvisioningParameters: operation.ProvisioningParameters,
}
case broker.PreviewPlanID:
p = &AWSInputProvider{
Purpose: defaultPurpose,
MultiZone: multiZoneCluster,
ProvisioningParameters: operation.ProvisioningParameters,
}
case broker.AzurePlanID:
p = &AzureInputProvider{
Purpose: defaultPurpose,
MultiZone: multiZoneCluster,
ProvisioningParameters: operation.ProvisioningParameters,
}
case broker.AzureLitePlanID:
p = &AzureLiteInputProvider{
Purpose: defaultPurpose,
UseSmallerMachineTypes: useSmallerMachineTypes,
ProvisioningParameters: operation.ProvisioningParameters,
}
case broker.GCPPlanID:
p = &GCPInputProvider{
Purpose: defaultPurpose,
MultiZone: multiZoneCluster,
ProvisioningParameters: operation.ProvisioningParameters,
}
Expand All @@ -62,6 +68,7 @@ func GenerateValues(
}
case broker.SapConvergedCloudPlanID:
p = &SapConvergedCloudInputProvider{
Purpose: defaultPurpose,
MultiZone: multiZoneCluster,
ProvisioningParameters: operation.ProvisioningParameters,
}
Expand Down
3 changes: 2 additions & 1 deletion internal/provider/sap-converged-cloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const (

type (
SapConvergedCloudInputProvider struct {
Purpose string
MultiZone bool
ProvisioningParameters internal.ProvisioningParameters
}
Expand All @@ -36,7 +37,7 @@ func (p *SapConvergedCloudInputProvider) Provide() Values {
ProviderType: "openstack",
DefaultMachineType: DefaultSapConvergedCloudMachineType,
Region: region,
Purpose: PurposeProduction,
Purpose: p.Purpose,
DiskType: "",
}
}
3 changes: 3 additions & 0 deletions internal/provider/sap-converged-cloud_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func TestSapConvergedCloudDefaults(t *testing.T) {

// given
sapCC := SapConvergedCloudInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: nil},
Expand Down Expand Up @@ -42,6 +43,7 @@ func TestSapConvergedCloudTwoZonesRegion(t *testing.T) {
// given
region := "eu-de-2"
sapCC := SapConvergedCloudInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String(region)},
Expand Down Expand Up @@ -73,6 +75,7 @@ func TestSapConvergedCloudSingleZoneRegion(t *testing.T) {
// given
region := "ap-jp-1"
sapCC := SapConvergedCloudInputProvider{
Purpose: PurposeProduction,
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String(region)},
Expand Down
Loading