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

chore: deprecate templatebody from http check #1587

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion api/v1/checks.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ type HTTPCheck struct {
Body string `yaml:"body,omitempty" json:"body,omitempty" template:"true"`
// Header fields to be used in the query
Headers []types.EnvVar `yaml:"headers,omitempty" json:"headers,omitempty"`
//Template the request body
// Template the request body.
// Deprecated: Body is always templated by default. Use template escaping if necessary.
TemplateBody bool `yaml:"templateBody,omitempty" json:"templateBody,omitempty"`
// EnvVars are the environment variables that are accesible to templated body
EnvVars []types.EnvVar `yaml:"env,omitempty" json:"env,omitempty"`
Expand Down
11 changes: 6 additions & 5 deletions checks/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,13 @@ func (c *HTTPChecker) Check(ctx *context.Context, extConfig external.Check) pkg.
return results.Failf("failed to template request url: %v", err)
}

body := check.Body
if check.TemplateBody {
body, err = template(ctx.WithCheck(check).WithEnvValues(templateEnv), v1.Template{Template: body})
if err != nil {
return results.Failf("failed to template request body: %v", err)
}
ctx.Tracef("TemplateBody is deprecated. The body is templated by default. Use templating escaping if necessary.")
}

body, err := template(ctx.WithCheck(check).WithEnvValues(templateEnv), v1.Template{Template: check.Body})
if err != nil {
return results.Failf("failed to template request body: %v", err)
}

request, err := c.generateHTTPRequest(ctx, check, connection)
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4130,7 +4130,7 @@ spec:
- value
type: object
templateBody:
description: Template the request body
description: 'Template the request body. Deprecated: Body is always templated by default. Use template escaping if necessary.'
type: boolean
test:
properties:
Expand Down
2 changes: 1 addition & 1 deletion config/deploy/manifests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4129,7 +4129,7 @@ spec:
- value
type: object
templateBody:
description: Template the request body
description: 'Template the request body. Deprecated: Body is always templated by default. Use template escaping if necessary.'
type: boolean
test:
properties:
Expand Down
Loading