Skip to content
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

[DDO-2308] Don't recursively parse query parameters #62

Merged
merged 2 commits into from
Sep 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/controllers/v2controllers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For naming, for a model type called `v2models.X`, the three types would be `X`,
#### Do use:
- `json` controls the field name when parsing to/from json (always add)
- `form` controls the field name when parsing from query parameters (always add)
- Struct types can't ever be parsed from query parameters, so `form:"-"` should be used [to skip them during parsing](https://github.com/gin-gonic/gin/pull/1733)
- `swaggertype` can override the type of the field documented on Swagger, useful for anything recursive (only add when Swaggo is parsing the type incorrectly)
- `enums` controls possible values for the field as documented on Swagger (add when reasonable)
- `default` controls (add when reasonable):
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/v2controllers/app_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type AppVersion struct {
ReadableBaseType
ChartInfo Chart `json:"chartInfo" form:"chartInfo"`
ChartInfo Chart `json:"chartInfo" form:"-"`
CreatableAppVersion
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

type ChartDeployRecord struct {
ReadableBaseType
ChartReleaseInfo ChartRelease `json:"chartReleaseInfo" form:"chartReleaseInfo"`
ChartReleaseInfo ChartRelease `json:"chartReleaseInfo" form:"-"`
CreatableChartDeployRecord
}

Expand Down
6 changes: 3 additions & 3 deletions internal/controllers/v2controllers/chart_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (

type ChartRelease struct {
ReadableBaseType
ChartInfo Chart `json:"chartInfo" form:"chartInfo"`
ClusterInfo *Cluster `json:"clusterInfo,omitempty" form:"clusterInfo"`
EnvironmentInfo *Environment `json:"environmentInfo,omitempty" form:"environmentInfo"`
ChartInfo Chart `json:"chartInfo" form:"-"`
ClusterInfo *Cluster `json:"clusterInfo,omitempty" form:"-"`
EnvironmentInfo *Environment `json:"environmentInfo,omitempty" form:"-"`
DestinationType string `json:"destinationType" form:"destinationType" enum:"environment,cluster"` // Calculated field
CreatableChartRelease
}
Expand Down
2 changes: 1 addition & 1 deletion internal/controllers/v2controllers/chart_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type ChartVersion struct {
ReadableBaseType
ChartInfo Chart `json:"chartInfo" form:"chartInfo"`
ChartInfo Chart `json:"chartInfo" form:"-"`
CreatableChartVersion
}

Expand Down
4 changes: 2 additions & 2 deletions internal/controllers/v2controllers/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (

type Environment struct {
ReadableBaseType
TemplateEnvironmentInfo *Environment `json:"templateEnvironmentInfo,omitempty" swaggertype:"object" form:"templateEnvironmentInfo"` // Single-layer recursive; provides info of the template environment if this environment has one
DefaultClusterInfo *Cluster `json:"defaultClusterInfo,omitempty" form:"defaultClusterInfo"`
TemplateEnvironmentInfo *Environment `json:"templateEnvironmentInfo,omitempty" swaggertype:"object" form:"-"` // Single-layer recursive; provides info of the template environment if this environment has one
DefaultClusterInfo *Cluster `json:"defaultClusterInfo,omitempty" form:"-"`
ValuesName string `json:"valuesName" form:"valuesName"`
CreatableEnvironment
}
Expand Down