// Get a "Specs" object that can create an SSHClient (and retrieve useful nested fields)
Get a "Specs" object that can create an SSHClient (and retrieve useful nested fields)
// Get a " Specs " object that can create an SSHClient ( and retrieve useful nested fields )
func New(cluster *clusterv1.Cluster, machines []*clusterv1.Machine) *Specs {
	master := machine.FirstMaster(machines)
	if master == nil {
		log.Fatal("No master provided in manifest.")
	}
	codec, err := baremetalspecv1.NewCodec()
	if err != nil {
		log.Fatal("Failed to create codec: ", err)
	}
	clusterSpec, err := codec.ClusterProviderFromProviderSpec(cluster.Spec.ProviderSpec)
	if err != nil {
		log.Fatal("Failed to parse cluster manifest: ", err)
	}
	masterSpec, err := codec.MachineProviderFromProviderSpec(master.Spec.ProviderSpec)
	if err != nil {
		log.Fatal("Failed to parse master: ", err)
	}
	masterCount := 0
	for _, m := range machines {
		if m.Labels["set"] == "master" {
			masterCount++
		}
	}
	return &Specs{
		cluster:     cluster,
		ClusterSpec: clusterSpec,
		MasterSpec:  masterSpec,
		machineCount: len(machines),
		masterCount:  masterCount,
	}
}
func New ( cluster * clusterv1 . Cluster , machines [ ] * clusterv1 . Machine ) * Specs { master := machine . FirstMaster ( machines ) if master == nil { log . Fatal ( " " ) } codec , err := baremetalspecv1 . NewCodec ( ) if err != nil { log . Fatal ( " " , err ) } clusterSpec , err := codec . ClusterProviderFromProviderSpec ( cluster . Spec . ProviderSpec ) if err != nil { log . Fatal ( " " , err ) } masterSpec , err := codec . MachineProviderFromProviderSpec ( master . Spec . ProviderSpec ) if err != nil { log . Fatal ( " " , err ) } masterCount := 0 for _ , m := range machines { if m . Labels [ " " ] == " " { masterCount ++ } } return & Specs { cluster : cluster , ClusterSpec : clusterSpec , MasterSpec : masterSpec , machineCount : len ( machines ) , masterCount : masterCount , } }
Get a "Specs" object that can create an SSHClient (and retrieve useful nested fields)
Get a " Specs " object that can create an SSHClient ( and retrieve useful nested fields )