func()

in kinder/pkg/cluster/status/cluster.go [321:351]


func (c *Cluster) SelectNodes(nodeSelector string) (nodes NodeList, err error) {
	if strings.HasPrefix(nodeSelector, "@") {
		switch strings.ToLower(nodeSelector) {
		case "@all": // all the kubernetes nodes
			return c.K8sNodes(), nil
		case "@cp*": // all the control-plane nodes
			return c.ControlPlanes(), nil
		case "@cp1": // the bootstrap-control plane
			return toNodeList(c.BootstrapControlPlane()), nil
		case "@cpn":
			return c.SecondaryControlPlanes(), nil
		case "@w*":
			return c.Workers(), nil
		case "@lb":
			return toNodeList(c.ExternalLoadBalancer()), nil
		case "@etcd":
			return toNodeList(c.ExternalEtcd()), nil
		default:
			return nil, errors.Errorf("Invalid node selector %q. Use one of [@all, @cp*, @cp1, @cpn, @w*, @lb, @etcd]", nodeSelector)
		}
	}

	nodeName := fmt.Sprintf("%s-%s", c.name, nodeSelector)
	for _, n := range c.K8sNodes() {
		if strings.EqualFold(nodeName, n.Name()) {
			return toNodeList(n), nil
		}
	}

	return nil, nil
}