[BUG] - Startup script updates do not omit empty values
optik-aper opened this issue · 1 comments
optik-aper commented
Describe the bug
Updates use the same struct as create and therefore do not allow nil values to be passed in or omitted when the JSON body is marshalled for the request.
To Reproduce
Steps to reproduce the behavior:
- Create a script
- Modify all but one value in the script
scriptID := "b44d064c-e437-4360-adf7-570501c2577e"
req := &govultr.StartupScriptReq{
Name: "new name2",
Script: "ZWNobyAnaGVsbG8gd29ybGQnCg==",
}
if err := client.StartupScript.Update(ctx, scriptID, req); err != nil {
fmt.Println(err)
panic(err.Error())
}
- Note how
Type
is wiped out after this update since it is not provided
{
"id": "b44d064c-e437-4360-adf7-570501c2577e",
"date_created": "2024-01-25T23:08:23+00:00",
"date_modified": "2024-01-25T23:20:37+00:00",
"name": "new name2",
"type": "",
"script": "ZWNobyAnaGVsbG8gd29ybGQnCg=="
}
Expected behavior
Partial updates should be supported per the API documentation
optik-aper commented
Fixed in #299