-
Notifications
You must be signed in to change notification settings - Fork 0
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
Issue-702 Imrpovement of cloudProviderSettings
flow
#705
Conversation
apis/clusters/v1beta1/structs.go
Outdated
func (c *CloudProviderOptions) FromInstAPI(instaModel *models.CloudProviderSettings) { | ||
s := CloudProviderOpts{} | ||
*c = append(*c, &s) | ||
|
||
switch { | ||
case len(instaModel.AWSSettings) > 0: | ||
s.AWSSettings = &AWSSettings{ | ||
EncryptionKey: instaModel.AWSSettings[0].EBSEncryptionKey, | ||
CustomVirtualNetworkID: instaModel.AWSSettings[0].CustomVirtualNetworkID, | ||
BackupBucket: instaModel.AWSSettings[0].BackupBucket, | ||
} | ||
case len(instaModel.GCPSettings) > 0: | ||
s.GCPSettings = &GCPSettings{ | ||
CustomVirtualNetworkID: instaModel.GCPSettings[0].CustomVirtualNetworkID, | ||
DisableSnapshotAutoExpiry: instaModel.GCPSettings[0].DisableSnapshotAutoExpiry, | ||
} | ||
case len(instaModel.AzureSettings) > 0: | ||
s.AzureSettings = &AzureSettings{ | ||
ResourceGroup: instaModel.AzureSettings[0].ResourceGroup, | ||
CustomVirtualNetworkID: instaModel.AzureSettings[0].CustomVirtualNetworkID, | ||
StorageNetwork: instaModel.AzureSettings[0].StorageNetwork, | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here we will append only if s
is not nil:
func (c *CloudProviderOptions) FromInstAPI(instaModel *models.CloudProviderSettings) {
var s *CloudProviderOpts
switch {
case len(instaModel.AWSSettings) > 0:
s = &CloudProviderOpts{
AWSSettings: &AWSSettings{
EncryptionKey: instaModel.AWSSettings[0].EBSEncryptionKey,
CustomVirtualNetworkID: instaModel.AWSSettings[0].CustomVirtualNetworkID,
BackupBucket: instaModel.AWSSettings[0].BackupBucket,
},
}
case len(instaModel.GCPSettings) > 0:
s = &CloudProviderOpts{
GCPSettings: &GCPSettings{
CustomVirtualNetworkID: instaModel.GCPSettings[0].CustomVirtualNetworkID,
DisableSnapshotAutoExpiry: instaModel.GCPSettings[0].DisableSnapshotAutoExpiry,
},
}
case len(instaModel.AzureSettings) > 0:
s = &CloudProviderOpts{
AzureSettings: &AzureSettings{
ResourceGroup: instaModel.AzureSettings[0].ResourceGroup,
CustomVirtualNetworkID: instaModel.AzureSettings[0].CustomVirtualNetworkID,
StorageNetwork: instaModel.AzureSettings[0].StorageNetwork,
},
}
if s != nil {
*c = append(*c, s)
}
}
}
wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It makes sense. Done.
6be9ce3
to
026a348
Compare
Region string `json:"region"` | ||
// A logical name for the data centre within a cluster. | ||
// These names must be unique in the cluster. | ||
Name string `json:"name,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Makefile
Outdated
kubectl apply -f ~/creds_secret.yaml | ||
$(KUSTOMIZE) build config/default | kubectl apply -f - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls comment kustomization
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Network string `json:"network"` | ||
Tags map[string]string `json:"tags,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
doc this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
switch { | ||
case len(instaModel.AWSSettings) > 0: | ||
setting := instaModel.AWSSettings[0] | ||
s.AWSSettings = append(s.AWSSettings, &AWSSettings{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't use append
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
apis/clusters/v1beta1/validation.go
Outdated
return nil | ||
} | ||
|
||
func (s *GenericDataCentreSpec) cloudProviderSettingsPresented() bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hasCloudProviderSettings()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
apis/clusters/v1beta1/validation.go
Outdated
fieldSet := 0 | ||
|
||
if s.AWSSettings != nil { | ||
fieldSet++ | ||
} | ||
if s.AzureSettings != nil { | ||
fieldSet++ | ||
} | ||
if s.GCPSettings != nil { | ||
fieldSet++ | ||
} | ||
|
||
if fieldSet > 1 { | ||
return errors.New("only one of [awsSettings, gcpSettings, azureSettings] should be set") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if sum := len(s.AWSSettings) + len(s.AzureSettings) + len(s.GCPSettings); sum > 1 { return err }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
The PR provides devideds the whole
cloudProviderSettings
into different object for each cloud provider.Closes #702