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

Commit c65b658

Browse files
vaywIvan Kirillov
andauthored
add weight param to cdn rule resource (#125)
Co-authored-by: Ivan Kirillov <[email protected]>
1 parent bba0e8f commit c65b658

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

gcore/resource_gcore_cdn_rule.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ func resourceCDNRule() *schema.Resource {
4747
Optional: true,
4848
Description: "This option defines the protocol that will be used by CDN servers to request content from an origin source. If not specified, it will be inherit from resource. Possible values are: HTTPS, HTTP, MATCH.",
4949
},
50+
"weight": {
51+
Type: schema.TypeInt,
52+
Optional: true,
53+
Description: "Rule weight that determines rule execution order: from the smallest (0) to the highest.",
54+
},
5055
"options": optionsSchema,
5156
},
5257
CreateContext: resourceCDNRuleCreate,
@@ -66,6 +71,7 @@ func resourceCDNRuleCreate(ctx context.Context, d *schema.ResourceData, m interf
6671
req.Name = d.Get("name").(string)
6772
req.Rule = d.Get("rule").(string)
6873
req.RuleType = d.Get("rule_type").(int)
74+
req.Weight = d.Get("weight").(int)
6975

7076
if d.Get("origin_group") != nil && d.Get("origin_group").(int) > 0 {
7177
req.OriginGroup = pointer.ToInt(d.Get("origin_group").(int))
@@ -114,6 +120,7 @@ func resourceCDNRuleRead(ctx context.Context, d *schema.ResourceData, m interfac
114120
d.Set("rule_type", result.Type)
115121
d.Set("origin_group", result.OriginGroup)
116122
d.Set("origin_protocol", result.OriginProtocol)
123+
d.Set("weight", result.Weight)
117124
if err := d.Set("options", optionsToList(result.Options)); err != nil {
118125
return diag.FromErr(err)
119126
}
@@ -137,6 +144,7 @@ func resourceCDNRuleUpdate(ctx context.Context, d *schema.ResourceData, m interf
137144
req.Name = d.Get("name").(string)
138145
req.Rule = d.Get("rule").(string)
139146
req.RuleType = d.Get("rule_type").(int)
147+
req.Weight = d.Get("weight").(int)
140148

141149
if d.Get("origin_group") != nil && d.Get("origin_group").(int) > 0 {
142150
req.OriginGroup = pointer.ToInt(d.Get("origin_group").(int))

0 commit comments

Comments
 (0)