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

Commit 35884cf

Browse files
vvelikodnyVitaly Velikodny
andauthored
* add 'tls_versions' option (#94)
* update docs for 'tls_versions' * describe dev process in README Co-authored-by: Vitaly Velikodny <[email protected]>
1 parent be203d0 commit 35884cf

File tree

8 files changed

+117
-810
lines changed

8 files changed

+117
-810
lines changed

GNUmakefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ default: build
1616
build: fmtcheck
1717
mkdir -p $(PLUGIN_PATH)
1818
go build -o $(PLUGIN_PATH)/$(BINARY_NAME)_v$(VERSION)
19+
go build -o bin/$(BINARY_NAME)
1920

2021
test: fmtcheck
2122
go test -i $(TEST) || exit 1

README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,43 @@ $ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-gcorelabs
2424
$ make build
2525
```
2626

27+
### Override Terraform provider
28+
29+
To override terraform provider for development goals you do next steps:
30+
31+
create Terraform configuration file
32+
```shell
33+
$ touch ~/.terraformrc
34+
```
35+
36+
point provider to development path
37+
```shell
38+
provider_installation {
39+
40+
dev_overrides {
41+
"local.gcorelabs.com/repo/gcore" = "/<dev-path>/terraform-provider-gcorelabs/bin"
42+
}
43+
44+
# For all other providers, install them directly from their origin provider
45+
# registries as normal. If you omit this, Terraform will _only_ use
46+
# the dev_overrides block, and so no other providers will be available.
47+
direct {}
48+
}
49+
```
50+
51+
add `local.gcorelabs.com/repo/gcore` to .tf configuration file
52+
```shell
53+
terraform {
54+
required_version = ">= 0.13.0"
55+
56+
required_providers {
57+
gcore = {
58+
source = "local.gcorelabs.com/repo/gcore"
59+
}
60+
}
61+
}
62+
```
63+
2764
Using the provider
2865
------------------
2966
To use the provider, prepare configuration files based on examples

docs/resources/gcore_cdn_resource.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ resource "gcore_cdn_resource" "cdn_example_com" {
4949
jpg_quality = 55
5050
png_quality = 66
5151
}
52+
53+
tls_versions {
54+
enabled = true
55+
value = [
56+
"TLSv1.2",
57+
]
58+
}
5259
}
5360
}
5461
```
@@ -95,6 +102,7 @@ Optional:
95102
- `sni` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--sni))
96103
- `static_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_headers))
97104
- `static_request_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_request_headers))
105+
- `tls_versions` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--tls_versions))
98106
- `webp` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--webp))
99107
- `websockets` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--websockets))
100108

@@ -249,6 +257,18 @@ Optional:
249257
- `enabled` (Boolean)
250258

251259

260+
<a id="nestedblock--options--tls_versions"></a>
261+
### Nested Schema for `options.tls_versions`
262+
263+
Required:
264+
265+
- `value` (Set of String)
266+
267+
Optional:
268+
269+
- `enabled` (Boolean)
270+
271+
252272
<a id="nestedblock--options--webp"></a>
253273
### Nested Schema for `options.webp`
254274

docs/resources/gcore_cdn_rule.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ Optional:
130130
- `sni` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--sni))
131131
- `static_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_headers))
132132
- `static_request_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_request_headers))
133+
- `tls_versions` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--tls_versions))
133134
- `webp` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--webp))
134135
- `websockets` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--websockets))
135136

@@ -284,6 +285,18 @@ Optional:
284285
- `enabled` (Boolean)
285286

286287

288+
<a id="nestedblock--options--tls_versions"></a>
289+
### Nested Schema for `options.tls_versions`
290+
291+
Required:
292+
293+
- `value` (Set of String)
294+
295+
Optional:
296+
297+
- `enabled` (Boolean)
298+
299+
287300
<a id="nestedblock--options--webp"></a>
288301
### Nested Schema for `options.webp`
289302

examples/resources/gcore_cdn_resource/resource.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,12 @@ resource "gcore_cdn_resource" "cdn_example_com" {
3434
jpg_quality = 55
3535
png_quality = 66
3636
}
37+
38+
tls_versions {
39+
enabled = true
40+
value = [
41+
"TLSv1.2",
42+
]
43+
}
3744
}
3845
}

gcore/resource_gcore_cdn_resource.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,26 @@ var (
352352
},
353353
},
354354
},
355+
"tls_versions": {
356+
Type: schema.TypeList,
357+
MaxItems: 1,
358+
Optional: true,
359+
Description: "",
360+
Elem: &schema.Resource{
361+
Schema: map[string]*schema.Schema{
362+
"enabled": {
363+
Type: schema.TypeBool,
364+
Optional: true,
365+
Default: true,
366+
},
367+
"value": {
368+
Type: schema.TypeSet,
369+
Elem: &schema.Schema{Type: schema.TypeString},
370+
Required: true,
371+
},
372+
},
373+
},
374+
},
355375
},
356376
},
357377
}
@@ -733,6 +753,18 @@ func listToOptions(l []interface{}) *gcdn.Options {
733753
Value: opt["value"].(bool),
734754
}
735755
}
756+
if opt, ok := getOptByName(fields, "tls_versions"); ok {
757+
enabled := true
758+
if _, ok := opt["enabled"]; ok {
759+
enabled = opt["enabled"].(bool)
760+
}
761+
opts.TLSVersions = &gcdn.TLSVersions{
762+
Enabled: enabled,
763+
}
764+
for _, v := range opt["value"].(*schema.Set).List() {
765+
opts.TLSVersions.Value = append(opts.TLSVersions.Value, v.(string))
766+
}
767+
}
736768
return &opts
737769
}
738770

@@ -820,6 +852,10 @@ func optionsToList(options *gcdn.Options) []interface{} {
820852
m := structToMap(options.WebSockets)
821853
result["websockets"] = []interface{}{m}
822854
}
855+
if options.TLSVersions != nil {
856+
m := structToMap(options.TLSVersions)
857+
result["tls_versions"] = []interface{}{m}
858+
}
823859
return []interface{}{result}
824860
}
825861

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/AlekSi/pointer v1.2.0
77
github.com/G-Core/gcore-dns-sdk-go v0.2.1
88
github.com/G-Core/gcore-storage-sdk-go v0.1.2
9-
github.com/G-Core/gcorelabscdn-go v0.1.19
9+
github.com/G-Core/gcorelabscdn-go v0.1.20
1010
github.com/G-Core/gcorelabscloud-go v0.4.51
1111
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
1212
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1

0 commit comments

Comments
 (0)