Skip to content

move validateHttpHeaders definition into cloud scheduler #7384

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

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
3 changes: 3 additions & 0 deletions .changelog/4022.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:none

```
16 changes: 0 additions & 16 deletions .vscode/tasks.json

This file was deleted.

19 changes: 19 additions & 0 deletions google/resource_cloud_scheduler_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ func authHeaderDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
return false
}

func validateHttpHeaders() schema.SchemaValidateFunc {
return func(i interface{}, k string) (s []string, es []error) {
headers := i.(map[string]interface{})
if _, ok := headers["Content-Length"]; ok {
es = append(es, fmt.Errorf("Cannot set the Content-Length header on %s", k))
return
}
r := regexp.MustCompile(`(X-Google-|X-AppEngine-).*`)
for key := range headers {
if r.MatchString(key) {
es = append(es, fmt.Errorf("Cannot set the %s header on %s", key, k))
return
}
}

return
}
}

func resourceCloudSchedulerJob() *schema.Resource {
return &schema.Resource{
Create: resourceCloudSchedulerJobCreate,
Expand Down
18 changes: 0 additions & 18 deletions google/resource_tpu_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,24 +72,6 @@ func tpuNodeCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta int
}
return nil
}
func validateHttpHeaders() schema.SchemaValidateFunc {
return func(i interface{}, k string) (s []string, es []error) {
headers := i.(map[string]interface{})
if _, ok := headers["Content-Length"]; ok {
es = append(es, fmt.Errorf("Cannot set the Content-Length header on %s", k))
return
}
r := regexp.MustCompile(`(X-Google-|X-AppEngine-).*`)
for key := range headers {
if r.MatchString(key) {
es = append(es, fmt.Errorf("Cannot set the %s header on %s", key, k))
return
}
}

return
}
}

func resourceTPUNode() *schema.Resource {
return &schema.Resource{
Expand Down