0

I am using the below code snippet to list machinesets but unable to get back any machinesets on the cluster:

cfg, err := config.GetConfig()
    if err != nil {
        log.Fatal(err)
    }

    opts := manager.Options{Scheme: scheme.Scheme}

    mgr, err := manager.New(cfg, opts)
    if err != nil {
        klog.Fatal(err)
    }
    //Get client from manager
    r = mgr.GetClient()
    msList := &machinev1.MachineSetList{}
    r.List(context.TODO(), msList, client.InNamespace(namespace_to_list))

    klog.Infof("len, %d", len(msList.Items))

Any help is much appreciated, thanks

asm
  • 13
  • 5
  • Are you receiving an error, or an empty response, or something else? Can you successfully list machinesets from the command line (using `kubectl` or `oc`)? – larsks May 06 '22 at 01:00
  • @larsks yes I can list from the command line. I do not get any error, length of machineset is zero in the above code snippet – asm May 06 '22 at 02:26
  • @asm for machinev1 which package have you used ? – Sam May 16 '22 at 00:08

0 Answers0