From a0c73108477cda709f873b9db2af91a6df0e1246 Mon Sep 17 00:00:00 2001 From: Fiona Waters Date: Wed, 18 Oct 2023 12:38:11 +0100 Subject: [PATCH] adding machine.go --- support/machine.go | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 support/machine.go diff --git a/support/machine.go b/support/machine.go new file mode 100644 index 0000000..26acb4b --- /dev/null +++ b/support/machine.go @@ -0,0 +1,32 @@ +package support + +import ( + "github.com/onsi/gomega" + + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + machinev1beta1 "github.com/openshift/api/machine/v1beta1" +) + +func GetMachineSets(t Test) ([]machinev1beta1.MachineSet, error) { + ms, err := t.Client().Machine().MachineV1beta1().MachineSets("openshift-machine-api").List(t.Ctx(), metav1.ListOptions{}) + t.Expect(err).NotTo(gomega.HaveOccurred()) + return ms.Items, err +} + +func Machines(t Test, machineSetName string) func(g gomega.Gomega) []machinev1beta1.Machine { + return func(g gomega.Gomega) []machinev1beta1.Machine { + machine, err := t.Client().Machine().MachineV1beta1().Machines("openshift-machine-api").List(t.Ctx(), metav1.ListOptions{LabelSelector: "machine.openshift.io/cluster-api-machineset=" + machineSetName}) + g.Expect(err).NotTo(gomega.HaveOccurred()) + return machine.Items + } +} + +func GetMachines(t Test, machineSetName string) []machinev1beta1.Machine { + t.T().Helper() + return Machines(t, machineSetName)(t) +} + +func MachineSetId(machineSet machinev1beta1.MachineSet) string { + return machineSet.Name +}