1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-07 03:47:13 +01:00
Files
installer/pkg/types/machinepools.go
W. Trevor King 1e129fe32b pkg/asset/installconfig/platform: Drop *PlatformType for types.{platform}.Name
The old *PlatformType are from cccbb37a (Generate installation assets
via a dependency graph, 2018-08-10, #120), but since 476be073
(pkg/asset: use vendored cluster-api instead of go templates,
2018-10-30, #573), we've had variables for the name strings in the
more central pkg/types.  With this commit, we drop the more peripheral
forms.  I've also pushed the types.PlatformName{Platform} variables
down into types.{platform}.Name at Ahbinav's suggestion [1].

I've added a unit test to enforce sorting in PlatformNames, because
the order is required by sort.SearchStrings in queryUserForPlatform.

[1]: https://github.com/openshift/installer/pull/659#discussion_r232849156
2018-11-13 10:36:34 -08:00

53 lines
1.4 KiB
Go

package types
import (
"github.com/openshift/installer/pkg/types/aws"
"github.com/openshift/installer/pkg/types/libvirt"
"github.com/openshift/installer/pkg/types/openstack"
)
// MachinePool is a pool of machines to be installed.
type MachinePool struct {
// Name is the name of the machine pool.
Name string `json:"name"`
// Replicas is the count of machines for this machine pool.
// Default is 1.
Replicas *int64 `json:"replicas"`
// Platform is configuration for machine pool specific to the platfrom.
Platform MachinePoolPlatform `json:"platform"`
}
// MachinePoolPlatform is the platform-specific configuration for a machine
// pool. Only one of the platforms should be set.
type MachinePoolPlatform struct {
// AWS is the configuration used when installing on AWS.
AWS *aws.MachinePool `json:"aws,omitempty"`
// Libvirt is the configuration used when installing on libvirt.
Libvirt *libvirt.MachinePool `json:"libvirt,omitempty"`
// OpenStack is the configuration used when installing on OpenStack.
OpenStack *openstack.MachinePool `json:"openstack,omitempty"`
}
// Name returns a string representation of the platform (e.g. "aws" if
// AWS is non-nil). It returns an empty string if no platform is
// configured.
func (p *MachinePoolPlatform) Name() string {
if p == nil {
return ""
}
if p.AWS != nil {
return aws.Name
}
if p.Libvirt != nil {
return libvirt.Name
}
if p.OpenStack != nil {
return openstack.Name
}
return ""
}