Skip to content

Commit

Permalink
KIM Integration - more concise step implementation (#1218)
Browse files Browse the repository at this point in the history
more concise implementation, less shadowing
  • Loading branch information
jaroslaw-pieszka authored Sep 30, 2024
1 parent d6be8e3 commit fab6514
Showing 1 changed file with 26 additions and 47 deletions.
73 changes: 26 additions & 47 deletions internal/process/provisioning/create_runtime_resource_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,59 +201,38 @@ func (s *CreateRuntimeResourceStep) createShootProvider(operation *internal.Oper
maxSurge := intstr.FromInt32(int32(DefaultIfParamNotSet(values.ZonesCount, operation.ProvisioningParameters.Parameters.MaxSurge)))
maxUnavailable := intstr.FromInt32(int32(DefaultIfParamNotSet(0, operation.ProvisioningParameters.Parameters.MaxUnavailable)))

max := int32(DefaultIfParamNotSet(values.DefaultAutoScalerMax, operation.ProvisioningParameters.Parameters.AutoScalerMax))
min := int32(DefaultIfParamNotSet(values.DefaultAutoScalerMin, operation.ProvisioningParameters.Parameters.AutoScalerMin))

if values.ProviderType == "openstack" {
return imv1.Provider{
Type: values.ProviderType,
Workers: []gardener.Worker{
{
Name: "cpu-worker-0",
Machine: gardener.Machine{
Type: DefaultIfParamNotSet(values.DefaultMachineType, operation.ProvisioningParameters.Parameters.MachineType),
Image: &gardener.ShootMachineImage{
Name: s.config.MachineImage,
Version: &s.config.MachineImageVersion,
},
scalerMax := int32(DefaultIfParamNotSet(values.DefaultAutoScalerMax, operation.ProvisioningParameters.Parameters.AutoScalerMax))
scalerMin := int32(DefaultIfParamNotSet(values.DefaultAutoScalerMin, operation.ProvisioningParameters.Parameters.AutoScalerMin))

provider := imv1.Provider{
Type: values.ProviderType,
Workers: []gardener.Worker{
{
Name: "cpu-worker-0",
Machine: gardener.Machine{
Type: DefaultIfParamNotSet(values.DefaultMachineType, operation.ProvisioningParameters.Parameters.MachineType),
Image: &gardener.ShootMachineImage{
Name: s.config.MachineImage,
Version: &s.config.MachineImageVersion,
},
Maximum: max,
Minimum: min,
MaxSurge: &maxSurge,
MaxUnavailable: &maxUnavailable,
Zones: values.Zones,
},
Maximum: scalerMax,
Minimum: scalerMin,
MaxSurge: &maxSurge,
MaxUnavailable: &maxUnavailable,
Zones: values.Zones,
},
}, nil
},
}

} else {
if values.ProviderType != "openstack" {
volumeSize := strconv.Itoa(DefaultIfParamNotSet(values.VolumeSizeGb, operation.ProvisioningParameters.Parameters.VolumeSizeGb))

return imv1.Provider{
Type: values.ProviderType,
Workers: []gardener.Worker{
{
Name: "cpu-worker-0",
Machine: gardener.Machine{
Type: DefaultIfParamNotSet(values.DefaultMachineType, operation.ProvisioningParameters.Parameters.MachineType),
Image: &gardener.ShootMachineImage{
Name: s.config.MachineImage,
Version: &s.config.MachineImageVersion,
},
},
Maximum: max,
Minimum: min,
MaxSurge: &maxSurge,
MaxUnavailable: &maxUnavailable,
Zones: values.Zones,
Volume: &gardener.Volume{
Type: ptr.String(values.DiskType),
VolumeSize: fmt.Sprintf("%sGi", volumeSize),
},
},
},
}, nil
provider.Workers[0].Volume = &gardener.Volume{
Type: ptr.String(values.DiskType),
VolumeSize: fmt.Sprintf("%sGi", volumeSize),
}
}
return provider, nil
}

func (s *CreateRuntimeResourceStep) createHighAvailabilityConfiguration() *gardener.HighAvailability {
Expand Down

0 comments on commit fab6514

Please sign in to comment.