Skip to content

Commit

Permalink
refactor: modify logic to comply with vetting
Browse files Browse the repository at this point in the history
Signed-off-by: Mike Nguyen <hey@mike.ee>
  • Loading branch information
mikeee committed Feb 20, 2025
1 parent 744508d commit ec9a874
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions pkg/standalone/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,20 +229,27 @@ func (config *RunConfig) Validate() error {
config.MaxConcurrency = -1
}

if q, err := resource.ParseQuantity(config.MaxRequestBodySize); err != nil {
qBody, err := resource.ParseQuantity(config.MaxRequestBodySize)
if err != nil {
return fmt.Errorf("invalid max request body size: %w", err)
} else if q.Value() < 0 {
}

if qBody.Value() < 0 {
config.MaxRequestBodySize = "-1"
} else {
config.MaxRequestBodySize = q.String()
config.MaxRequestBodySize = qBody.String()
}

if q, err := resource.ParseQuantity(config.HTTPReadBufferSize); err != nil {
qBuffer, err := resource.ParseQuantity(config.HTTPReadBufferSize)

Check failure on line 244 in pkg/standalone/run.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

File is not `gofumpt`-ed (gofumpt)
if err != nil {
return fmt.Errorf("invalid http read buffer size: %w", err)
} else if q.Value() < 0 {
}

if qBuffer.Value() < 0 {
config.HTTPReadBufferSize = "-1"
} else {
config.HTTPReadBufferSize = q.String()
config.HTTPReadBufferSize = qBuffer.String()
}

err = config.validatePlacementHostAddr()
Expand Down Expand Up @@ -277,20 +284,27 @@ func (config *RunConfig) ValidateK8s() error {
config.MaxConcurrency = -1
}

if q, err := resource.ParseQuantity(config.MaxRequestBodySize); err != nil {
qBody, err := resource.ParseQuantity(config.MaxRequestBodySize)
if err != nil {
return fmt.Errorf("invalid max request body size: %w", err)
} else if q.Value() <= 0 {
}

if qBody.Value() < 0 {
config.MaxRequestBodySize = "-1"
} else {
config.MaxRequestBodySize = q.String()
config.MaxRequestBodySize = qBody.String()
}

if q, err := resource.ParseQuantity(config.HTTPReadBufferSize); err != nil {
qBuffer, err := resource.ParseQuantity(config.HTTPReadBufferSize)

Check failure on line 299 in pkg/standalone/run.go

View workflow job for this annotation

GitHub Actions / Build linux_amd64 binaries

File is not `gofumpt`-ed (gofumpt)
if err != nil {
return fmt.Errorf("invalid http read buffer size: %w", err)
} else if q.Value() <= 0 {
}

if qBuffer.Value() < 0 {
config.HTTPReadBufferSize = "-1"
} else {
config.HTTPReadBufferSize = q.String()
config.HTTPReadBufferSize = qBuffer.String()
}

return nil
Expand Down

0 comments on commit ec9a874

Please sign in to comment.