Skip to content

Commit c321574

Browse files
committed
Rename Bastion.Instance to Bastion.Spec
Bastion.Spec is way more descriptive and it suggests it's an OpenStackMachineSpec.
1 parent ffa82b3 commit c321574

22 files changed

+121
-96
lines changed

api/v1alpha5/conversion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ func Convert_v1alpha5_PortOpts_To_v1beta1_PortOpts(in *PortOpts, out *infrav1.Po
448448
}
449449

450450
func Convert_v1alpha5_Instance_To_v1beta1_BastionStatus(in *Instance, out *infrav1.BastionStatus, _ conversion.Scope) error {
451-
// BastionStatus is the same as Instance with unused fields removed
451+
// BastionStatus is the same as Spec with unused fields removed
452452
out.ID = in.ID
453453
out.Name = in.Name
454454
out.SSHKeyName = in.SSHKeyName
@@ -460,7 +460,7 @@ func Convert_v1alpha5_Instance_To_v1beta1_BastionStatus(in *Instance, out *infra
460460
}
461461

462462
func Convert_v1beta1_BastionStatus_To_v1alpha5_Instance(in *infrav1.BastionStatus, out *Instance, _ conversion.Scope) error {
463-
// BastionStatus is the same as Instance with unused fields removed
463+
// BastionStatus is the same as Spec with unused fields removed
464464
out.ID = in.ID
465465
out.Name = in.Name
466466
out.SSHKeyName = in.SSHKeyName

api/v1alpha5/zz_generated.conversion.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha6/openstackcluster_conversion.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -413,8 +413,8 @@ func Convert_v1alpha6_OpenStackClusterStatus_To_v1beta1_OpenStackClusterStatus(i
413413

414414
func restorev1beta1Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
415415
if *previous != nil {
416-
if *dst != nil && (*previous).Instance != nil && (*dst).Instance != nil {
417-
restorev1beta1MachineSpec((*previous).Instance, (*dst).Instance)
416+
if *dst != nil && (*previous).Spec != nil && (*dst).Spec != nil {
417+
restorev1beta1MachineSpec((*previous).Spec, (*dst).Spec)
418418
}
419419

420420
optional.RestoreString(&(*previous).FloatingIP, &(*dst).FloatingIP)
@@ -423,7 +423,7 @@ func restorev1beta1Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
423423
}
424424

425425
func Convert_v1alpha6_Instance_To_v1beta1_BastionStatus(in *Instance, out *infrav1.BastionStatus, _ apiconversion.Scope) error {
426-
// BastionStatus is the same as Instance with unused fields removed
426+
// BastionStatus is the same as Spec with unused fields removed
427427
out.ID = in.ID
428428
out.Name = in.Name
429429
out.SSHKeyName = in.SSHKeyName
@@ -434,7 +434,7 @@ func Convert_v1alpha6_Instance_To_v1beta1_BastionStatus(in *Instance, out *infra
434434
}
435435

436436
func Convert_v1beta1_BastionStatus_To_v1alpha6_Instance(in *infrav1.BastionStatus, out *Instance, _ apiconversion.Scope) error {
437-
// BastionStatus is the same as Instance with unused fields removed
437+
// BastionStatus is the same as Spec with unused fields removed
438438
out.ID = in.ID
439439
out.Name = in.Name
440440
out.SSHKeyName = in.SSHKeyName
@@ -451,17 +451,17 @@ func Convert_v1alpha6_Bastion_To_v1beta1_Bastion(in *Bastion, out *infrav1.Basti
451451
}
452452

453453
if !reflect.ValueOf(in.Instance).IsZero() {
454-
out.Instance = &infrav1.OpenStackMachineSpec{}
454+
out.Spec = &infrav1.OpenStackMachineSpec{}
455455

456-
err = Convert_v1alpha6_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(&in.Instance, out.Instance, s)
456+
err = Convert_v1alpha6_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(&in.Instance, out.Spec, s)
457457
if err != nil {
458458
return err
459459
}
460460

461461
if in.Instance.ServerGroupID != "" {
462-
out.Instance.ServerGroup = &infrav1.ServerGroupFilter{ID: in.Instance.ServerGroupID}
462+
out.Spec.ServerGroup = &infrav1.ServerGroupFilter{ID: in.Instance.ServerGroupID}
463463
} else {
464-
out.Instance.ServerGroup = nil
464+
out.Spec.ServerGroup = nil
465465
}
466466

467467
err = optional.Convert_string_To_optional_String(&in.Instance.FloatingIP, &out.FloatingIP, s)
@@ -470,9 +470,9 @@ func Convert_v1alpha6_Bastion_To_v1beta1_Bastion(in *Bastion, out *infrav1.Basti
470470
}
471471
}
472472

473-
// nil the Instance if it's basically an empty object.
474-
if out.Instance != nil && reflect.ValueOf(*out.Instance).IsZero() {
475-
out.Instance = nil
473+
// nil the Spec if it's basically an empty object.
474+
if out.Spec != nil && reflect.ValueOf(*out.Spec).IsZero() {
475+
out.Spec = nil
476476
}
477477
return nil
478478
}
@@ -483,14 +483,14 @@ func Convert_v1beta1_Bastion_To_v1alpha6_Bastion(in *infrav1.Bastion, out *Basti
483483
return err
484484
}
485485

486-
if in.Instance != nil {
487-
err = Convert_v1beta1_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in.Instance, &out.Instance, s)
486+
if in.Spec != nil {
487+
err = Convert_v1beta1_OpenStackMachineSpec_To_v1alpha6_OpenStackMachineSpec(in.Spec, &out.Instance, s)
488488
if err != nil {
489489
return err
490490
}
491491

492-
if in.Instance.ServerGroup != nil && in.Instance.ServerGroup.ID != "" {
493-
out.Instance.ServerGroupID = in.Instance.ServerGroup.ID
492+
if in.Spec.ServerGroup != nil && in.Spec.ServerGroup.ID != "" {
493+
out.Instance.ServerGroupID = in.Spec.ServerGroup.ID
494494
}
495495
}
496496

api/v1alpha6/zz_generated.conversion.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha7/openstackcluster_conversion.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -376,8 +376,8 @@ func restorev1alpha7Bastion(previous **Bastion, dst **Bastion) {
376376

377377
func restorev1beta1Bastion(previous **infrav1.Bastion, dst **infrav1.Bastion) {
378378
if *previous != nil {
379-
if *dst != nil && (*previous).Instance != nil && (*dst).Instance != nil {
380-
restorev1beta1MachineSpec((*previous).Instance, (*dst).Instance)
379+
if *dst != nil && (*previous).Spec != nil && (*dst).Spec != nil {
380+
restorev1beta1MachineSpec((*previous).Spec, (*dst).Spec)
381381
}
382382

383383
optional.RestoreString(&(*previous).FloatingIP, &(*dst).FloatingIP)
@@ -392,17 +392,17 @@ func Convert_v1alpha7_Bastion_To_v1beta1_Bastion(in *Bastion, out *infrav1.Basti
392392
}
393393

394394
if !reflect.ValueOf(in.Instance).IsZero() {
395-
out.Instance = &infrav1.OpenStackMachineSpec{}
395+
out.Spec = &infrav1.OpenStackMachineSpec{}
396396

397-
err = Convert_v1alpha7_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(&in.Instance, out.Instance, s)
397+
err = Convert_v1alpha7_OpenStackMachineSpec_To_v1beta1_OpenStackMachineSpec(&in.Instance, out.Spec, s)
398398
if err != nil {
399399
return err
400400
}
401401

402402
if in.Instance.ServerGroupID != "" {
403-
out.Instance.ServerGroup = &infrav1.ServerGroupFilter{ID: in.Instance.ServerGroupID}
403+
out.Spec.ServerGroup = &infrav1.ServerGroupFilter{ID: in.Instance.ServerGroupID}
404404
} else {
405-
out.Instance.ServerGroup = nil
405+
out.Spec.ServerGroup = nil
406406
}
407407

408408
err = optional.Convert_string_To_optional_String(&in.Instance.FloatingIP, &out.FloatingIP, s)
@@ -411,9 +411,9 @@ func Convert_v1alpha7_Bastion_To_v1beta1_Bastion(in *Bastion, out *infrav1.Basti
411411
}
412412
}
413413

414-
// nil the Instance if it's basically an empty object.
415-
if out.Instance != nil && reflect.ValueOf(*out.Instance).IsZero() {
416-
out.Instance = nil
414+
// nil the Spec if it's basically an empty object.
415+
if out.Spec != nil && reflect.ValueOf(*out.Spec).IsZero() {
416+
out.Spec = nil
417417
}
418418
return nil
419419
}
@@ -424,14 +424,14 @@ func Convert_v1beta1_Bastion_To_v1alpha7_Bastion(in *infrav1.Bastion, out *Basti
424424
return err
425425
}
426426

427-
if in.Instance != nil {
428-
err = Convert_v1beta1_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in.Instance, &out.Instance, s)
427+
if in.Spec != nil {
428+
err = Convert_v1beta1_OpenStackMachineSpec_To_v1alpha7_OpenStackMachineSpec(in.Spec, &out.Instance, s)
429429
if err != nil {
430430
return err
431431
}
432432

433-
if in.Instance.ServerGroup != nil && in.Instance.ServerGroup.ID != "" {
434-
out.Instance.ServerGroupID = in.Instance.ServerGroup.ID
433+
if in.Spec.ServerGroup != nil && in.Spec.ServerGroup.ID != "" {
434+
out.Instance.ServerGroupID = in.Spec.ServerGroup.ID
435435
}
436436
}
437437

api/v1alpha7/zz_generated.conversion.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/types.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,17 +597,17 @@ var (
597597
)
598598

599599
// Bastion represents basic information about the bastion node. If you enable bastion, the spec has to be specified.
600-
// +kubebuilder:validation:XValidation:rule="!self.enabled || has(self.instance)",message="you need to specify the instance if bastion is enabled"
600+
// +kubebuilder:validation:XValidation:rule="!self.enabled || has(self.spec)",message="you need to specify the spec if bastion is enabled"
601601
type Bastion struct {
602602
// Enabled means that bastion is enabled. Defaults to false.
603603
// +kubebuilder:validation:Required
604604
// +kubebuilder:default:=false
605605
Enabled bool `json:"enabled"`
606606

607-
// Instance for the bastion itself
608-
Instance *OpenStackMachineSpec `json:"instance,omitempty"`
607+
// Spec for the bastion itself
608+
Spec *OpenStackMachineSpec `json:"spec,omitempty"`
609609

610-
// AvailabilityZone is the failure domain that will be used to create the Bastion Instance.
610+
// AvailabilityZone is the failure domain that will be used to create the Bastion Spec.
611611
//+optional
612612
AvailabilityZone optional.String `json:"availabilityZone,omitempty"`
613613

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclusters.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4918,7 +4918,7 @@ spec:
49184918
properties:
49194919
availabilityZone:
49204920
description: AvailabilityZone is the failure domain that will
4921-
be used to create the Bastion Instance.
4921+
be used to create the Bastion Spec.
49224922
type: string
49234923
enabled:
49244924
default: false
@@ -4932,8 +4932,8 @@ spec:
49324932
exist, CAPO will try to create it, but by default only OpenStack administrators have privileges to do so.
49334933
format: ipv4
49344934
type: string
4935-
instance:
4936-
description: Instance for the bastion itself
4935+
spec:
4936+
description: Spec for the bastion itself
49374937
properties:
49384938
additionalBlockDevices:
49394939
description: AdditionalBlockDevices is a list of specifications
@@ -5583,8 +5583,8 @@ spec:
55835583
- enabled
55845584
type: object
55855585
x-kubernetes-validations:
5586-
- message: you need to specify the instance if bastion is enabled
5587-
rule: '!self.enabled || has(self.instance)'
5586+
- message: you need to specify the spec if bastion is enabled
5587+
rule: '!self.enabled || has(self.spec)'
55885588
controlPlaneAvailabilityZones:
55895589
description: |-
55905590
ControlPlaneAvailabilityZones is the set of availability zones which

config/crd/bases/infrastructure.cluster.x-k8s.io_openstackclustertemplates.yaml

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2342,7 +2342,7 @@ spec:
23422342
properties:
23432343
availabilityZone:
23442344
description: AvailabilityZone is the failure domain that
2345-
will be used to create the Bastion Instance.
2345+
will be used to create the Bastion Spec.
23462346
type: string
23472347
enabled:
23482348
default: false
@@ -2356,8 +2356,8 @@ spec:
23562356
exist, CAPO will try to create it, but by default only OpenStack administrators have privileges to do so.
23572357
format: ipv4
23582358
type: string
2359-
instance:
2360-
description: Instance for the bastion itself
2359+
spec:
2360+
description: Spec for the bastion itself
23612361
properties:
23622362
additionalBlockDevices:
23632363
description: AdditionalBlockDevices is a list of specifications
@@ -3017,9 +3017,8 @@ spec:
30173017
- enabled
30183018
type: object
30193019
x-kubernetes-validations:
3020-
- message: you need to specify the instance if bastion is
3021-
enabled
3022-
rule: '!self.enabled || has(self.instance)'
3020+
- message: you need to specify the spec if bastion is enabled
3021+
rule: '!self.enabled || has(self.spec)'
30233022
controlPlaneAvailabilityZones:
30243023
description: |-
30253024
ControlPlaneAvailabilityZones is the set of availability zones which

controllers/openstackcluster_controller.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ func resolveBastionResources(scope *scope.WithLogger, openStackCluster *infrav1.
222222
if openStackCluster.Status.Bastion == nil {
223223
openStackCluster.Status.Bastion = &infrav1.BastionStatus{}
224224
}
225-
if openStackCluster.Spec.Bastion.Instance == nil {
225+
if openStackCluster.Spec.Bastion.Spec == nil {
226226
return false, fmt.Errorf("bastion spec is nil when bastion is enabled, this shouldn't happen")
227227
}
228-
changed, err := compute.ResolveReferencedMachineResources(scope, openStackCluster, openStackCluster.Spec.Bastion.Instance, &openStackCluster.Status.Bastion.ReferencedResources)
228+
changed, err := compute.ResolveReferencedMachineResources(scope, openStackCluster, openStackCluster.Spec.Bastion.Spec, &openStackCluster.Status.Bastion.ReferencedResources)
229229
if err != nil {
230230
return false, err
231231
}
@@ -532,27 +532,27 @@ func bastionToInstanceSpec(openStackCluster *infrav1.OpenStackCluster, cluster *
532532
if openStackCluster.Spec.Bastion == nil {
533533
return nil, fmt.Errorf("bastion spec is nil")
534534
}
535-
if openStackCluster.Spec.Bastion.Instance == nil {
535+
if openStackCluster.Spec.Bastion.Spec == nil {
536536
// For the case when Bastion is deleted but we don't have spec, let's use an empty one.
537537
// v1beta1 API validations prevent this from happening in normal circumstances.
538-
openStackCluster.Spec.Bastion.Instance = &infrav1.OpenStackMachineSpec{}
538+
openStackCluster.Spec.Bastion.Spec = &infrav1.OpenStackMachineSpec{}
539539
}
540540

541541
if openStackCluster.Status.Bastion == nil {
542542
return nil, fmt.Errorf("bastion status is nil")
543543
}
544544
instanceSpec := &compute.InstanceSpec{
545545
Name: bastionName(cluster.Name),
546-
Flavor: openStackCluster.Spec.Bastion.Instance.Flavor,
547-
SSHKeyName: openStackCluster.Spec.Bastion.Instance.SSHKeyName,
546+
Flavor: openStackCluster.Spec.Bastion.Spec.Flavor,
547+
SSHKeyName: openStackCluster.Spec.Bastion.Spec.SSHKeyName,
548548
ImageID: openStackCluster.Status.Bastion.ReferencedResources.ImageID,
549-
RootVolume: openStackCluster.Spec.Bastion.Instance.RootVolume,
549+
RootVolume: openStackCluster.Spec.Bastion.Spec.RootVolume,
550550
}
551551
if openStackCluster.Spec.Bastion.AvailabilityZone != nil {
552552
instanceSpec.FailureDomain = *openStackCluster.Spec.Bastion.AvailabilityZone
553553
}
554554

555-
instanceSpec.SecurityGroups = openStackCluster.Spec.Bastion.Instance.SecurityGroups
555+
instanceSpec.SecurityGroups = openStackCluster.Spec.Bastion.Spec.SecurityGroups
556556
if openStackCluster.Spec.ManagedSecurityGroups != nil {
557557
if openStackCluster.Status.BastionSecurityGroup != nil {
558558
instanceSpec.SecurityGroups = append(instanceSpec.SecurityGroups, infrav1.SecurityGroupFilter{
@@ -562,7 +562,7 @@ func bastionToInstanceSpec(openStackCluster *infrav1.OpenStackCluster, cluster *
562562
}
563563
instanceSpec.SecurityGroups = getBastionSecurityGroups(openStackCluster)
564564

565-
instanceSpec.Ports = openStackCluster.Spec.Bastion.Instance.Ports
565+
instanceSpec.Ports = openStackCluster.Spec.Bastion.Spec.Ports
566566

567567
return instanceSpec, nil
568568
}
@@ -571,10 +571,10 @@ func bastionName(clusterName string) string {
571571
return fmt.Sprintf("%s-bastion", clusterName)
572572
}
573573

574-
// getBastionSecurityGroups returns a combination of openStackCluster.Spec.Bastion.Instance.SecurityGroups
574+
// getBastionSecurityGroups returns a combination of openStackCluster.Spec.Bastion.Spec.SecurityGroups
575575
// and the security group managed by the OpenStackCluster.
576576
func getBastionSecurityGroups(openStackCluster *infrav1.OpenStackCluster) []infrav1.SecurityGroupFilter {
577-
instanceSpecSecurityGroups := openStackCluster.Spec.Bastion.Instance.SecurityGroups
577+
instanceSpecSecurityGroups := openStackCluster.Spec.Bastion.Spec.SecurityGroups
578578

579579
if openStackCluster.Spec.ManagedSecurityGroups == nil {
580580
return instanceSpecSecurityGroups

0 commit comments

Comments
 (0)