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

Commit

Permalink
* add 'tls_versions' option (#94)
Browse files Browse the repository at this point in the history
* update docs for 'tls_versions'
* describe dev process in README

Co-authored-by: Vitaly Velikodny <[email protected]>
  • Loading branch information
vvelikodny and Vitaly Velikodny authored Apr 28, 2022
1 parent be203d0 commit 35884cf
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 810 deletions.
1 change: 1 addition & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ default: build
build: fmtcheck
mkdir -p $(PLUGIN_PATH)
go build -o $(PLUGIN_PATH)/$(BINARY_NAME)_v$(VERSION)
go build -o bin/$(BINARY_NAME)

test: fmtcheck
go test -i $(TEST) || exit 1
Expand Down
37 changes: 37 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,43 @@ $ cd $GOPATH/src/github.com/terraform-providers/terraform-provider-gcorelabs
$ make build
```

### Override Terraform provider

To override terraform provider for development goals you do next steps:

create Terraform configuration file
```shell
$ touch ~/.terraformrc
```

point provider to development path
```shell
provider_installation {

dev_overrides {
"local.gcorelabs.com/repo/gcore" = "/<dev-path>/terraform-provider-gcorelabs/bin"
}

# For all other providers, install them directly from their origin provider
# registries as normal. If you omit this, Terraform will _only_ use
# the dev_overrides block, and so no other providers will be available.
direct {}
}
```

add `local.gcorelabs.com/repo/gcore` to .tf configuration file
```shell
terraform {
required_version = ">= 0.13.0"

required_providers {
gcore = {
source = "local.gcorelabs.com/repo/gcore"
}
}
}
```

Using the provider
------------------
To use the provider, prepare configuration files based on examples
Expand Down
20 changes: 20 additions & 0 deletions docs/resources/gcore_cdn_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ resource "gcore_cdn_resource" "cdn_example_com" {
jpg_quality = 55
png_quality = 66
}
tls_versions {
enabled = true
value = [
"TLSv1.2",
]
}
}
}
```
Expand Down Expand Up @@ -95,6 +102,7 @@ Optional:
- `sni` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--sni))
- `static_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_headers))
- `static_request_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_request_headers))
- `tls_versions` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--tls_versions))
- `webp` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--webp))
- `websockets` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--websockets))

Expand Down Expand Up @@ -249,6 +257,18 @@ Optional:
- `enabled` (Boolean)


<a id="nestedblock--options--tls_versions"></a>
### Nested Schema for `options.tls_versions`

Required:

- `value` (Set of String)

Optional:

- `enabled` (Boolean)


<a id="nestedblock--options--webp"></a>
### Nested Schema for `options.webp`

Expand Down
13 changes: 13 additions & 0 deletions docs/resources/gcore_cdn_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Optional:
- `sni` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--sni))
- `static_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_headers))
- `static_request_headers` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--static_request_headers))
- `tls_versions` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--tls_versions))
- `webp` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--webp))
- `websockets` (Block List, Max: 1) (see [below for nested schema](#nestedblock--options--websockets))

Expand Down Expand Up @@ -284,6 +285,18 @@ Optional:
- `enabled` (Boolean)


<a id="nestedblock--options--tls_versions"></a>
### Nested Schema for `options.tls_versions`

Required:

- `value` (Set of String)

Optional:

- `enabled` (Boolean)


<a id="nestedblock--options--webp"></a>
### Nested Schema for `options.webp`

Expand Down
7 changes: 7 additions & 0 deletions examples/resources/gcore_cdn_resource/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,12 @@ resource "gcore_cdn_resource" "cdn_example_com" {
jpg_quality = 55
png_quality = 66
}

tls_versions {
enabled = true
value = [
"TLSv1.2",
]
}
}
}
36 changes: 36 additions & 0 deletions gcore/resource_gcore_cdn_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,26 @@ var (
},
},
},
"tls_versions": {
Type: schema.TypeList,
MaxItems: 1,
Optional: true,
Description: "",
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"enabled": {
Type: schema.TypeBool,
Optional: true,
Default: true,
},
"value": {
Type: schema.TypeSet,
Elem: &schema.Schema{Type: schema.TypeString},
Required: true,
},
},
},
},
},
},
}
Expand Down Expand Up @@ -733,6 +753,18 @@ func listToOptions(l []interface{}) *gcdn.Options {
Value: opt["value"].(bool),
}
}
if opt, ok := getOptByName(fields, "tls_versions"); ok {
enabled := true
if _, ok := opt["enabled"]; ok {
enabled = opt["enabled"].(bool)
}
opts.TLSVersions = &gcdn.TLSVersions{
Enabled: enabled,
}
for _, v := range opt["value"].(*schema.Set).List() {
opts.TLSVersions.Value = append(opts.TLSVersions.Value, v.(string))
}
}
return &opts
}

Expand Down Expand Up @@ -820,6 +852,10 @@ func optionsToList(options *gcdn.Options) []interface{} {
m := structToMap(options.WebSockets)
result["websockets"] = []interface{}{m}
}
if options.TLSVersions != nil {
m := structToMap(options.TLSVersions)
result["tls_versions"] = []interface{}{m}
}
return []interface{}{result}
}

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/AlekSi/pointer v1.2.0
github.com/G-Core/gcore-dns-sdk-go v0.2.1
github.com/G-Core/gcore-storage-sdk-go v0.1.2
github.com/G-Core/gcorelabscdn-go v0.1.19
github.com/G-Core/gcorelabscdn-go v0.1.20
github.com/G-Core/gcorelabscloud-go v0.4.51
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.10.1
Expand Down
Loading

0 comments on commit 35884cf

Please sign in to comment.