Skip to content

Commit 82772b1

Browse files
move validateHttpHeaders definition into cloud scheduler (#4022) (#2525)
Signed-off-by: Modular Magician <[email protected]>
1 parent 6331e2f commit 82772b1

File tree

3 files changed

+22
-18
lines changed

3 files changed

+22
-18
lines changed

.changelog/4022.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:none
2+
3+
```

google-beta/resource_cloud_scheduler_job.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ func authHeaderDiffSuppress(k, old, new string, d *schema.ResourceData) bool {
7676
return false
7777
}
7878

79+
func validateHttpHeaders() schema.SchemaValidateFunc {
80+
return func(i interface{}, k string) (s []string, es []error) {
81+
headers := i.(map[string]interface{})
82+
if _, ok := headers["Content-Length"]; ok {
83+
es = append(es, fmt.Errorf("Cannot set the Content-Length header on %s", k))
84+
return
85+
}
86+
r := regexp.MustCompile(`(X-Google-|X-AppEngine-).*`)
87+
for key := range headers {
88+
if r.MatchString(key) {
89+
es = append(es, fmt.Errorf("Cannot set the %s header on %s", key, k))
90+
return
91+
}
92+
}
93+
94+
return
95+
}
96+
}
97+
7998
func resourceCloudSchedulerJob() *schema.Resource {
8099
return &schema.Resource{
81100
Create: resourceCloudSchedulerJobCreate,

google-beta/resource_tpu_node.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -72,24 +72,6 @@ func tpuNodeCustomizeDiff(_ context.Context, diff *schema.ResourceDiff, meta int
7272
}
7373
return nil
7474
}
75-
func validateHttpHeaders() schema.SchemaValidateFunc {
76-
return func(i interface{}, k string) (s []string, es []error) {
77-
headers := i.(map[string]interface{})
78-
if _, ok := headers["Content-Length"]; ok {
79-
es = append(es, fmt.Errorf("Cannot set the Content-Length header on %s", k))
80-
return
81-
}
82-
r := regexp.MustCompile(`(X-Google-|X-AppEngine-).*`)
83-
for key := range headers {
84-
if r.MatchString(key) {
85-
es = append(es, fmt.Errorf("Cannot set the %s header on %s", key, k))
86-
return
87-
}
88-
}
89-
90-
return
91-
}
92-
}
9375

9476
func resourceTPUNode() *schema.Resource {
9577
return &schema.Resource{

0 commit comments

Comments
 (0)