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 - safe checks and test cases #1232

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
10 changes: 8 additions & 2 deletions internal/provider/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,17 @@ func (p *AWSTrialInputProvider) region() string {
if p.ProvisioningParameters.PlatformRegion != "" {
abstractRegion, found := p.PlatformRegionMapping[p.ProvisioningParameters.PlatformRegion]
if found {
return *toAWSSpecific[abstractRegion]
awsSpecific, ok := toAWSSpecific[abstractRegion]
if ok {
return *awsSpecific
}
}
}
if p.ProvisioningParameters.Parameters.Region != nil && *p.ProvisioningParameters.Parameters.Region != "" {
return *toAWSSpecific[*p.ProvisioningParameters.Parameters.Region]
awsSpecific, ok := toAWSSpecific[*p.ProvisioningParameters.Parameters.Region]
if ok {
return *awsSpecific
}
}
return DefaultAWSTrialRegion
}
Expand Down
35 changes: 16 additions & 19 deletions internal/provider/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import (
"github.com/stretchr/testify/assert"
)

var AWSTrialPlafomRegionMapping = map[string]string{"cf-eu10": "europe", "cf-us10": "us", "cf-ap21": "asia"}
var TestTrialPlatformRegionMapping = map[string]string{"cf-eu10": "europe", "cf-us10": "us", "cf-ap21": "asia"}

func TestAWSDefaults(t *testing.T) {

// given
aws := AWSInputProvider{
provider := AWSInputProvider{
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eu-central-1")},
Parameters: internal.ProvisioningParametersDTO{Region: nil},
PlatformRegion: "cf-eu11",
},
}

// when
values := aws.Provide()
values := provider.Provide()

// then

Expand All @@ -43,20 +43,18 @@ func TestAWSDefaults(t *testing.T) {
func TestAWSSpecific(t *testing.T) {

// given
aws := AWSInputProvider{
provider := AWSInputProvider{
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
MachineType: ptr.String("m6i.xlarge"),
Region: ptr.String("ap-southeast-1"),
Region: ptr.String("ap-southeast-1"),
},
PlatformRegion: "cf-eu11",
PlatformProvider: "ap-southeast-1",
PlatformRegion: "cf-eu11",
},
}

// when
values := aws.Provide()
values := provider.Provide()

// then

Expand All @@ -78,16 +76,16 @@ func TestAWSSpecific(t *testing.T) {
func TestAWSTrialDefaults(t *testing.T) {

// given
aws := AWSTrialInputProvider{
PlatformRegionMapping: AWSTrialPlafomRegionMapping,
provider := AWSTrialInputProvider{
PlatformRegionMapping: TestTrialPlatformRegionMapping,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eu-central-1")},
Parameters: internal.ProvisioningParametersDTO{Region: nil},
PlatformRegion: "cf-eu11",
},
}

// when
values := aws.Provide()
values := provider.Provide()

// then

Expand All @@ -108,19 +106,18 @@ func TestAWSTrialDefaults(t *testing.T) {
func TestAWSTrialSpecific(t *testing.T) {

// given
aws := AWSTrialInputProvider{
PlatformRegionMapping: AWSTrialPlafomRegionMapping,
provider := AWSTrialInputProvider{
PlatformRegionMapping: TestTrialPlatformRegionMapping,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{
MachineType: ptr.String("m6i.xlarge"),
Region: ptr.String("eu-central-1"),
Region: ptr.String("eu-central-1"),
},
PlatformRegion: "cf-ap21",
},
}

// when
values := aws.Provide()
values := provider.Provide()

// then

Expand Down
12 changes: 6 additions & 6 deletions internal/provider/azure_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ var AzureTrialPlatformRegionMapping = map[string]string{"cf-eu11": "europe", "cf
func TestAzureDefaults(t *testing.T) {

// given
aws := AzureInputProvider{
azure := AzureInputProvider{
MultiZone: true,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eastus")},
Expand All @@ -21,7 +21,7 @@ func TestAzureDefaults(t *testing.T) {
}

// when
values := aws.Provide()
values := azure.Provide()

// then

Expand All @@ -42,7 +42,7 @@ func TestAzureDefaults(t *testing.T) {
func TestAzureTrialDefaults(t *testing.T) {

// given
aws := AzureTrialInputProvider{
azure := AzureTrialInputProvider{
PlatformRegionMapping: AzureTrialPlatformRegionMapping,
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eastus")},
Expand All @@ -51,7 +51,7 @@ func TestAzureTrialDefaults(t *testing.T) {
}

// when
values := aws.Provide()
values := azure.Provide()

// then

Expand All @@ -72,15 +72,15 @@ func TestAzureTrialDefaults(t *testing.T) {
func TestAzureLiteDefaults(t *testing.T) {

// given
aws := AzureLiteInputProvider{
azure := AzureLiteInputProvider{
ProvisioningParameters: internal.ProvisioningParameters{
Parameters: internal.ProvisioningParametersDTO{Region: ptr.String("eastus")},
PlatformRegion: "cf-eu11",
},
}

// when
values := aws.Provide()
values := azure.Provide()

// then

Expand Down
10 changes: 8 additions & 2 deletions internal/provider/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,18 @@ func (p *GCPTrialInputProvider) region() string {
if p.ProvisioningParameters.PlatformRegion != "" {
abstractRegion, found := p.PlatformRegionMapping[p.ProvisioningParameters.PlatformRegion]
if found {
return *toGCPSpecific[abstractRegion]
gpcSpecific, ok := toGCPSpecific[abstractRegion]
if ok {
return *gpcSpecific
}
}
}

if p.ProvisioningParameters.Parameters.Region != nil && *p.ProvisioningParameters.Parameters.Region != "" {
return *toGCPSpecific[*p.ProvisioningParameters.Parameters.Region]
gpcSpecific, ok := toGCPSpecific[*p.ProvisioningParameters.Parameters.Region]
if ok {
return *gpcSpecific
}
}

return DefaultGCPRegion
Expand Down
Loading
Loading