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

Commit eea43f0

Browse files
vvelikodnyVitaly Velikodny
andauthored
fix override origin proto, update docs (#81)
* fix override origin protocol for rule create/update * * fix override origin protocol for rule create/update * update docs * * update docs * * update docs Co-authored-by: Vitaly Velikodny <[email protected]>
1 parent 6ffd17c commit eea43f0

File tree

9 files changed

+103
-70
lines changed

9 files changed

+103
-70
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ resource "gcore_lbmember" "lbm2" {
254254
- **gcore_cdn_api** (String) CDN API
255255
- **gcore_client_id** (String) Client id
256256
- **gcore_dns_api** (String) DNS API
257-
- **gcore_platform** (String) Platform ulr is used for generate jwt
257+
- **gcore_platform** (String) Platform URL is used for generate JWT
258258
- **gcore_storage_api** (String) Storage API
259259
- **ignore_creds_auth_error** (Boolean) Should be set to true when you are gonna to use storage resource with permanent API-token only.
260260
- **password** (String)

docs/resources/gcore_cdn_resource.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ Optional:
9494
- **edge_cache_settings** (Block List, Max: 1) The cache expiration time for CDN servers. (see [below for nested schema](#nestedblock--options--edge_cache_settings))
9595
- **gzip_on** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--gzip_on))
9696
- **host_header** (Block List, Max: 1) Specify the Host header that CDN servers use when request content from an origin server. Your server must be able to process requests with the chosen header. If the option is in NULL state Host Header value is taken from the CNAME field. (see [below for nested schema](#nestedblock--options--host_header))
97+
- **ignore_query_string** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--ignore_query_string))
98+
- **query_params_blacklist** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--query_params_blacklist))
99+
- **query_params_whitelist** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--query_params_whitelist))
97100
- **redirect_http_to_https** (Block List, Max: 1) Sets redirect from HTTP protocol to HTTPS for all resource requests. (see [below for nested schema](#nestedblock--options--redirect_http_to_https))
98101
- **rewrite** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--rewrite))
99102
- **sni** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--sni))
@@ -155,6 +158,42 @@ Optional:
155158
- **enabled** (Boolean)
156159

157160

161+
<a id="nestedblock--options--ignore_query_string"></a>
162+
### Nested Schema for `options.ignore_query_string`
163+
164+
Required:
165+
166+
- **value** (Boolean)
167+
168+
Optional:
169+
170+
- **enabled** (Boolean)
171+
172+
173+
<a id="nestedblock--options--query_params_blacklist"></a>
174+
### Nested Schema for `options.query_params_blacklist`
175+
176+
Required:
177+
178+
- **value** (Set of String)
179+
180+
Optional:
181+
182+
- **enabled** (Boolean)
183+
184+
185+
<a id="nestedblock--options--query_params_whitelist"></a>
186+
### Nested Schema for `options.query_params_whitelist`
187+
188+
Required:
189+
190+
- **value** (Set of String)
191+
192+
Optional:
193+
194+
- **enabled** (Boolean)
195+
196+
158197
<a id="nestedblock--options--redirect_http_to_https"></a>
159198
### Nested Schema for `options.redirect_http_to_https`
160199

docs/resources/gcore_cdn_rule.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ resource "gcore_cdn_rule" "cdn_example_com_rule_2" {
6363
name = "All JS scripts"
6464
rule = "/folder/images/*.js"
6565
rule_type = 0
66+
origin_protocol = "HTTP"
6667
6768
options {
6869
redirect_http_to_https {
@@ -107,6 +108,7 @@ resource "gcore_cdn_resource" "cdn_example_com" {
107108

108109
- **id** (String) The ID of this resource.
109110
- **options** (Block List, Max: 1) Each option in CDN resource settings. Each option added to CDN resource settings should have the following mandatory request fields: enabled, value. (see [below for nested schema](#nestedblock--options))
111+
- **origin_protocol** (String) 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.
110112

111113
<a id="nestedblock--options"></a>
112114
### Nested Schema for `options`
@@ -118,6 +120,9 @@ Optional:
118120
- **edge_cache_settings** (Block List, Max: 1) The cache expiration time for CDN servers. (see [below for nested schema](#nestedblock--options--edge_cache_settings))
119121
- **gzip_on** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--gzip_on))
120122
- **host_header** (Block List, Max: 1) Specify the Host header that CDN servers use when request content from an origin server. Your server must be able to process requests with the chosen header. If the option is in NULL state Host Header value is taken from the CNAME field. (see [below for nested schema](#nestedblock--options--host_header))
123+
- **ignore_query_string** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--ignore_query_string))
124+
- **query_params_blacklist** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--query_params_blacklist))
125+
- **query_params_whitelist** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--query_params_whitelist))
121126
- **redirect_http_to_https** (Block List, Max: 1) Sets redirect from HTTP protocol to HTTPS for all resource requests. (see [below for nested schema](#nestedblock--options--redirect_http_to_https))
122127
- **rewrite** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--rewrite))
123128
- **sni** (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--sni))
@@ -179,6 +184,42 @@ Optional:
179184
- **enabled** (Boolean)
180185

181186

187+
<a id="nestedblock--options--ignore_query_string"></a>
188+
### Nested Schema for `options.ignore_query_string`
189+
190+
Required:
191+
192+
- **value** (Boolean)
193+
194+
Optional:
195+
196+
- **enabled** (Boolean)
197+
198+
199+
<a id="nestedblock--options--query_params_blacklist"></a>
200+
### Nested Schema for `options.query_params_blacklist`
201+
202+
Required:
203+
204+
- **value** (Set of String)
205+
206+
Optional:
207+
208+
- **enabled** (Boolean)
209+
210+
211+
<a id="nestedblock--options--query_params_whitelist"></a>
212+
### Nested Schema for `options.query_params_whitelist`
213+
214+
Required:
215+
216+
- **value** (Set of String)
217+
218+
Optional:
219+
220+
- **enabled** (Boolean)
221+
222+
182223
<a id="nestedblock--options--redirect_http_to_https"></a>
183224
### Nested Schema for `options.redirect_http_to_https`
184225

docs/resources/gcore_lblistener.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,6 @@ resource "gcore_loadbalancer" "lb" {
2525
region_id = 1
2626
name = "test"
2727
flavor = "lb1-1-2"
28-
listener {
29-
name = "test"
30-
protocol = "HTTP"
31-
protocol_port = 80
32-
}
3328
3429
listener {
3530
name = "test3"

examples/resources/gcore_cdn_rule/resource.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ resource "gcore_cdn_rule" "cdn_example_com_rule_2" {
4848
name = "All JS scripts"
4949
rule = "/folder/images/*.js"
5050
rule_type = 0
51+
origin_protocol = "HTTP"
5152

5253
options {
5354
redirect_http_to_https {

gcore/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ func Provider() *schema.Provider {
5656
"gcore_platform": {
5757
Type: schema.TypeString,
5858
Optional: true,
59-
Description: "Platform url is used for generate jwt",
59+
Description: "Platform URL is used for generate JWT",
6060
DefaultFunc: schema.EnvDefaultFunc("GCORE_PLATFORM", "https://api.gcdn.co"),
6161
},
6262
"gcore_api": {

gcore/resource_gcore_cdn_rule.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ func resourceCDNRule() *schema.Resource {
3737
Required: true,
3838
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.",
3939
},
40-
"override_origin_protocol": {
40+
"origin_protocol": {
4141
Type: schema.TypeString,
4242
Optional: 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.",
43+
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.",
4444
},
4545
"options": optionsSchema,
4646
},
@@ -62,8 +62,8 @@ func resourceCDNRuleCreate(ctx context.Context, d *schema.ResourceData, m interf
6262
req.Rule = d.Get("rule").(string)
6363
req.RuleType = d.Get("rule_type").(int)
6464

65-
if d.Get("override_origin_protocol") != nil && d.Get("override_origin_protocol") != "" {
66-
req.OverrideOriginProtocol = pointer.ToString(d.Get("override_origin_protocol").(string))
65+
if d.Get("origin_protocol") != nil && d.Get("origin_protocol") != "" {
66+
req.OverrideOriginProtocol = pointer.ToString(d.Get("origin_protocol").(string))
6767
}
6868

6969
resourceID := d.Get("resource_id").(int)
@@ -103,7 +103,7 @@ func resourceCDNRuleRead(ctx context.Context, d *schema.ResourceData, m interfac
103103
d.Set("name", result.Name)
104104
d.Set("rule", result.Pattern)
105105
d.Set("rule_type", result.Type)
106-
d.Set("override_origin_protocol", result.OverrideOriginProtocol)
106+
d.Set("origin_protocol", result.OriginProtocol)
107107
if err := d.Set("options", optionsToList(result.Options)); err != nil {
108108
return diag.FromErr(err)
109109
}
@@ -128,8 +128,8 @@ func resourceCDNRuleUpdate(ctx context.Context, d *schema.ResourceData, m interf
128128
req.Rule = d.Get("rule").(string)
129129
req.RuleType = d.Get("rule_type").(int)
130130

131-
if d.Get("override_origin_protocol") != nil && d.Get("override_origin_protocol") != "" {
132-
req.OverrideOriginProtocol = pointer.ToString(d.Get("override_origin_protocol").(string))
131+
if d.Get("origin_protocol") != nil && d.Get("origin_protocol") != "" {
132+
req.OverrideOriginProtocol = pointer.ToString(d.Get("origin_protocol").(string))
133133
}
134134

135135
req.Options = listToOptions(d.Get("options").([]interface{}))

go.mod

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ require (
1010
github.com/G-Core/gcorelabscloud-go v0.4.42
1111
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1212
github.com/hashicorp/terraform-exec v0.15.0 // indirect
13+
github.com/hashicorp/terraform-plugin-docs v0.5.1 // indirect
1314
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
1415
github.com/mattn/go-colorable v0.1.11 // indirect
1516
github.com/mitchellh/mapstructure v1.4.1

0 commit comments

Comments
 (0)