Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit ff3ded1

Browse files
author
Vitaly Velikodny
committed
fix origin protocol for rule create/update
1 parent d612780 commit ff3ded1

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

gcore/resource_gcore_cdn_rule.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ func resourceCDNRule() *schema.Resource {
3636
Required: true,
3737
Description: "Type of rule. The rule is applied if the requested URI matches the rule pattern. It has two possible values: Type 0 — RegEx. Must start with '^/' or '/'. Type 1 — RegEx. Legacy type. Note that for this rule type we automatically add / to each rule pattern before your regular expression. Please use Type 0.",
3838
},
39+
"origin_protocol": {
40+
Type: schema.TypeString,
41+
Optional: true,
42+
Computed: true,
43+
Description: "This option defines the protocol that will be used by CDN servers to request content from an origin source. If not specified, we will use HTTP to connect to an origin server. Possible values are: HTTPS, HTTP, MATCH.",
44+
},
3945
"options": optionsSchema,
4046
},
4147
CreateContext: resourceCDNRuleCreate,
@@ -55,6 +61,7 @@ func resourceCDNRuleCreate(ctx context.Context, d *schema.ResourceData, m interf
5561
req.Name = d.Get("name").(string)
5662
req.Rule = d.Get("rule").(string)
5763
req.RuleType = d.Get("rule_type").(int)
64+
req.OverrideOriginProtocol = d.Get("origin_protocol").(string)
5865

5966
resourceID := d.Get("resource_id").(int)
6067

@@ -93,6 +100,7 @@ func resourceCDNRuleRead(ctx context.Context, d *schema.ResourceData, m interfac
93100
d.Set("name", result.Name)
94101
d.Set("rule", result.Pattern)
95102
d.Set("rule_type", result.Type)
103+
d.Set("origin_protocol", result.OriginProtocol)
96104
if err := d.Set("options", optionsToList(result.Options)); err != nil {
97105
return diag.FromErr(err)
98106
}
@@ -116,6 +124,8 @@ func resourceCDNRuleUpdate(ctx context.Context, d *schema.ResourceData, m interf
116124
req.Name = d.Get("name").(string)
117125
req.Rule = d.Get("rule").(string)
118126
req.RuleType = d.Get("rule_type").(int)
127+
req.OverrideOriginProtocol = d.Get("origin_protocol").(string)
128+
119129
req.Options = listToOptions(d.Get("options").([]interface{}))
120130

121131
resourceID := d.Get("resource_id").(int)

0 commit comments

Comments
 (0)