-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(deployments): align omitempty usage #357
Conversation
Aligns the omitempty usage with the expectations from the API. Required fields should not set omitempty. Optional fields should set omitempty, when we don't want to send empty values. We don't need omitempty on the object struct, just for structs used in API calls that get (un)marshalled. Closes https://linear.app/prefect/issue/PLA-919/manifest-path-causes-deployment-update-to-fail-prefect-server Closes #356
@@ -74,7 +74,7 @@ type DeploymentUpdate struct { | |||
EnforceParameterSchema bool `json:"enforce_parameter_schema,omitempty"` | |||
Entrypoint string `json:"entrypoint,omitempty"` | |||
JobVariables map[string]interface{} `json:"job_variables,omitempty"` | |||
ManifestPath string `json:"manifest_path"` | |||
ManifestPath string `json:"manifest_path,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix for #356 specifically.
@@ -50,10 +50,10 @@ type DeploymentCreate struct { | |||
Description string `json:"description,omitempty"` | |||
EnforceParameterSchema bool `json:"enforce_parameter_schema,omitempty"` | |||
Entrypoint string `json:"entrypoint,omitempty"` | |||
FlowID uuid.UUID `json:"flow_id"` | |||
FlowID uuid.UUID `json:"flow_id"` // required |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no required
option (that I'm aware of), so I added // required
here to signify that we're intentionally not specifying omitempty
. My thought process was this may help us in the future to determine whether the field was left off intentionally or not - open to opinions though
@@ -22,25 +22,25 @@ type Deployment struct { | |||
WorkspaceID uuid.UUID `json:"workspace_id"` | |||
|
|||
ConcurrencyLimit *int64 `json:"concurrency_limit"` | |||
ConcurrencyOptions *ConcurrencyOptions `json:"concurrency_options,omitempty"` | |||
Description string `json:"description,omitempty"` | |||
ConcurrencyOptions *ConcurrencyOptions `json:"concurrency_options"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIK, there's no need to specify omitempty
on the Deployment object itself because it's not used in any API requests and is therefore never (un)marshalled by the json
package.
Aligns the omitempty usage with the expectations from the API.
Required fields should not set omitempty.
Optional fields should set omitempty, when we don't want to send empty values.
We don't need omitempty on the object struct, just for structs used in API calls that get (un)marshalled.
Closes https://linear.app/prefect/issue/PLA-919/manifest-path-causes-deployment-update-to-fail-prefect-server
Closes #356