mirror of https://github.com/kubernetes/kops.git
fix: don't use curly brackets for additional scoping
This commit is contained in:
parent
9f94c06e67
commit
0b9ab26862
|
|
@ -84,7 +84,6 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cloud config.
|
// Cloud config.
|
||||||
{
|
|
||||||
if cfg := b.Cluster.Spec.CloudConfig; cfg != nil {
|
if cfg := b.Cluster.Spec.CloudConfig; cfg != nil {
|
||||||
// Product.
|
// Product.
|
||||||
if cfg.SpotinstProduct != nil {
|
if cfg.SpotinstProduct != nil {
|
||||||
|
|
@ -96,10 +95,8 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
group.Orientation = cfg.SpotinstOrientation
|
group.Orientation = cfg.SpotinstOrientation
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Strategy.
|
// Strategy.
|
||||||
{
|
|
||||||
for k, v := range ig.ObjectMeta.Labels {
|
for k, v := range ig.ObjectMeta.Labels {
|
||||||
switch k {
|
switch k {
|
||||||
case InstanceGroupLabelOrientation:
|
case InstanceGroupLabelOrientation:
|
||||||
|
|
@ -123,19 +120,15 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Instance profile.
|
// Instance profile.
|
||||||
{
|
|
||||||
iprof, err := b.LinkToIAMInstanceProfile(ig)
|
iprof, err := b.LinkToIAMInstanceProfile(ig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
group.IAMInstanceProfile = iprof
|
group.IAMInstanceProfile = iprof
|
||||||
}
|
|
||||||
|
|
||||||
// Root volume.
|
// Root volume.
|
||||||
{
|
|
||||||
volumeSize := fi.Int32Value(ig.Spec.RootVolumeSize)
|
volumeSize := fi.Int32Value(ig.Spec.RootVolumeSize)
|
||||||
if volumeSize == 0 {
|
if volumeSize == 0 {
|
||||||
var err error
|
var err error
|
||||||
|
|
@ -153,17 +146,13 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
group.RootVolumeSize = fi.Int64(int64(volumeSize))
|
group.RootVolumeSize = fi.Int64(int64(volumeSize))
|
||||||
group.RootVolumeType = fi.String(volumeType)
|
group.RootVolumeType = fi.String(volumeType)
|
||||||
group.RootVolumeOptimization = ig.Spec.RootVolumeOptimization
|
group.RootVolumeOptimization = ig.Spec.RootVolumeOptimization
|
||||||
}
|
|
||||||
|
|
||||||
// Tenancy.
|
// Tenancy.
|
||||||
{
|
|
||||||
if ig.Spec.Tenancy != "" {
|
if ig.Spec.Tenancy != "" {
|
||||||
group.Tenancy = fi.String(ig.Spec.Tenancy)
|
group.Tenancy = fi.String(ig.Spec.Tenancy)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Risk.
|
// Risk.
|
||||||
{
|
|
||||||
var risk float64
|
var risk float64
|
||||||
switch ig.Spec.Role {
|
switch ig.Spec.Role {
|
||||||
case kops.InstanceGroupRoleMaster:
|
case kops.InstanceGroupRoleMaster:
|
||||||
|
|
@ -176,10 +165,8 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
return fmt.Errorf("spotinst: kops.Role not found %s", ig.Spec.Role)
|
return fmt.Errorf("spotinst: kops.Role not found %s", ig.Spec.Role)
|
||||||
}
|
}
|
||||||
group.Risk = &risk
|
group.Risk = &risk
|
||||||
}
|
|
||||||
|
|
||||||
// Security groups.
|
// Security groups.
|
||||||
{
|
|
||||||
for _, id := range ig.Spec.AdditionalSecurityGroups {
|
for _, id := range ig.Spec.AdditionalSecurityGroups {
|
||||||
sgTask := &awstasks.SecurityGroup{
|
sgTask := &awstasks.SecurityGroup{
|
||||||
Name: fi.String(id),
|
Name: fi.String(id),
|
||||||
|
|
@ -191,19 +178,15 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
}
|
}
|
||||||
group.SecurityGroups = append(group.SecurityGroups, sgTask)
|
group.SecurityGroups = append(group.SecurityGroups, sgTask)
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// SSH Key.
|
// SSH Key.
|
||||||
{
|
|
||||||
sshKey, err := b.LinkToSSHKey()
|
sshKey, err := b.LinkToSSHKey()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
group.SSHKey = sshKey
|
group.SSHKey = sshKey
|
||||||
}
|
|
||||||
|
|
||||||
// Load balancer.
|
// Load balancer.
|
||||||
{
|
|
||||||
var lb *awstasks.LoadBalancer
|
var lb *awstasks.LoadBalancer
|
||||||
switch ig.Spec.Role {
|
switch ig.Spec.Role {
|
||||||
case kops.InstanceGroupRoleMaster:
|
case kops.InstanceGroupRoleMaster:
|
||||||
|
|
@ -216,19 +199,15 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
if lb != nil {
|
if lb != nil {
|
||||||
group.LoadBalancer = lb
|
group.LoadBalancer = lb
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// User data.
|
// User data.
|
||||||
{
|
|
||||||
userData, err := b.BootstrapScript.ResourceNodeUp(ig, b.Cluster)
|
userData, err := b.BootstrapScript.ResourceNodeUp(ig, b.Cluster)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
group.UserData = userData
|
group.UserData = userData
|
||||||
}
|
|
||||||
|
|
||||||
// Public IP.
|
// Public IP.
|
||||||
{
|
|
||||||
subnetMap := make(map[string]*kops.ClusterSubnetSpec)
|
subnetMap := make(map[string]*kops.ClusterSubnetSpec)
|
||||||
for i := range b.Cluster.Spec.Subnets {
|
for i := range b.Cluster.Spec.Subnets {
|
||||||
subnet := &b.Cluster.Spec.Subnets[i]
|
subnet := &b.Cluster.Spec.Subnets[i]
|
||||||
|
|
@ -265,10 +244,8 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
return fmt.Errorf("spotinst: unknown subnet type %q", subnetType)
|
return fmt.Errorf("spotinst: unknown subnet type %q", subnetType)
|
||||||
}
|
}
|
||||||
group.AssociatePublicIP = &associatePublicIP
|
group.AssociatePublicIP = &associatePublicIP
|
||||||
}
|
|
||||||
|
|
||||||
// Subnets.
|
// Subnets.
|
||||||
{
|
|
||||||
subnets, err := b.GatherSubnets(ig)
|
subnets, err := b.GatherSubnets(ig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
@ -279,10 +256,8 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
for _, subnet := range subnets {
|
for _, subnet := range subnets {
|
||||||
group.Subnets = append(group.Subnets, b.LinkToSubnet(subnet))
|
group.Subnets = append(group.Subnets, b.LinkToSubnet(subnet))
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Capacity.
|
// Capacity.
|
||||||
{
|
|
||||||
minSize := int32(1)
|
minSize := int32(1)
|
||||||
if ig.Spec.MinSize != nil {
|
if ig.Spec.MinSize != nil {
|
||||||
minSize = fi.Int32Value(ig.Spec.MinSize)
|
minSize = fi.Int32Value(ig.Spec.MinSize)
|
||||||
|
|
@ -299,10 +274,8 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
|
|
||||||
group.MinSize = fi.Int64(int64(minSize))
|
group.MinSize = fi.Int64(int64(minSize))
|
||||||
group.MaxSize = fi.Int64(int64(maxSize))
|
group.MaxSize = fi.Int64(int64(maxSize))
|
||||||
}
|
|
||||||
|
|
||||||
// Tags.
|
// Tags.
|
||||||
{
|
|
||||||
tags, err := b.CloudTagsForInstanceGroup(ig)
|
tags, err := b.CloudTagsForInstanceGroup(ig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("spotinst: error building cloud tags: %v", err)
|
return fmt.Errorf("spotinst: error building cloud tags: %v", err)
|
||||||
|
|
@ -310,10 +283,8 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
tags[awsup.TagClusterName] = b.ClusterName()
|
tags[awsup.TagClusterName] = b.ClusterName()
|
||||||
tags["Name"] = b.AutoscalingGroupName(ig)
|
tags["Name"] = b.AutoscalingGroupName(ig)
|
||||||
group.Tags = tags
|
group.Tags = tags
|
||||||
}
|
|
||||||
|
|
||||||
// Auto Scaler.
|
// Auto Scaler.
|
||||||
{
|
|
||||||
if ig.Spec.Role != kops.InstanceGroupRoleBastion {
|
if ig.Spec.Role != kops.InstanceGroupRoleBastion {
|
||||||
group.ClusterIdentifier = fi.String(b.ClusterName())
|
group.ClusterIdentifier = fi.String(b.ClusterName())
|
||||||
|
|
||||||
|
|
@ -359,7 +330,6 @@ func (b *ElastigroupModelBuilder) Build(c *fi.ModelBuilderContext) error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
c.AddTask(group)
|
c.AddTask(group)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue