canonical / gomaasclient

Go MAAS client
Apache License 2.0
19 stars 27 forks source link

Cannot unset min_hwe_kernel for a machine #80

Open gnuoy opened 2 months ago

gnuoy commented 2 months ago

Similar issue as issue #75 . Due to the omitempty directive when trying to unset min_hwe_kernel the option is dropped if the value is an empty string.

This fails:

       _, err = client.Machine.Update(systemID, &entity.MachineParams{
               MinHWEKernel: "",
       }, map[string]interface{}{})

Using the deprecated API client works:

    values := make(url.Values)
    values.Add("min_hwe_kernel", "")
    machine := new(entity.Machine)

    machineAPI := apiclient.GetSubObject("machines").GetSubObject(systemID)
    err := machineAPI.Put(values, func(data []byte) error {
        return json.Unmarshal(data, machine)
    })
    return err
troyanov commented 2 months ago

Hi @gnuoy Thank you for another bug report and for providing a temporary workaround.

I will try to go through it during next week.