Skip to content

fix(iaas): send snapshot policy ttl as string - #110

Open
janhaitjema wants to merge 1 commit into
thalassa-cloud:mainfrom
janhaitjema:feature/snapshot-policy-ttl-string
Open

fix(iaas): send snapshot policy ttl as string#110
janhaitjema wants to merge 1 commit into
thalassa-cloud:mainfrom
janhaitjema:feature/snapshot-policy-ttl-string

Conversation

@janhaitjema

Copy link
Copy Markdown

Ttl is a time.Duration on the create and update requests, which encoding/json serialises as nanoseconds. The API expects a duration string, so every create and update fails with:

json: cannot unmarshal number into Go struct field .ttl of type string

Adds MarshalJSON to both request types emitting "168h0m0s". The field stays a time.Duration, so callers need no change. Reads are untouched: the API returns a number there and consumers already call Ttl.String().

Verified by building the Terraform provider against this branch and creating a policy against the live API. Same config fails on v0.35.3.

`Ttl` is a `time.Duration` on the create and update requests, which
`encoding/json` serialises as nanoseconds. The API expects a duration string,
so every create and update fails with:

    json: cannot unmarshal number into Go struct field .ttl of type string

Adds `MarshalJSON` to both request types emitting `"168h0m0s"`. The field stays
a `time.Duration`, so callers need no change. Reads are untouched: the API
returns a number there and consumers already call `Ttl.String()`.

Verified by building the Terraform provider against this branch and creating a
policy against the live API. Same config fails on v0.35.3.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant