Skip to content

Commit

Permalink
Merge pull request #184 from kingsoftcloud/trunk
Browse files Browse the repository at this point in the history
Trunk
  • Loading branch information
notone0010 authored Dec 14, 2023
2 parents edd0637 + 412c532 commit 61bbcb6
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 1 deletion.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 1.12.1 (Dec 14, 2023)

IMPROVEMENTS:

- `ksyun_healthcheck` 新增`health_check_connect_port`健康检查端口
- `ksyun_alb_listener` 新增`config_content` 个性化配置

## 1.12.0 (Dec 7, 2023)

FEATURES:
Expand Down
9 changes: 8 additions & 1 deletion ksyun/resource_ksyun_alb_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,14 @@ func resourceKsyunAlbListener() *schema.Resource {
},
},

// TODO: 个性化配置
"config_content": {
Type: schema.TypeMap,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
Description: "The custom configure for listener. [The details](https://docs.ksyun.com/documents/42615?type=3).",
},

"alb_listener_id": {
Type: schema.TypeString,
Expand Down
7 changes: 7 additions & 0 deletions ksyun/resource_ksyun_healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ func resourceKsyunHealthCheck() *schema.Resource {
Default: "start",
Description: "Status maintained by health examination.Valid Values:'start', 'stop'.",
},

"health_check_connect_port": {
Type: schema.TypeInt,
Optional: true,
Description: "The port of connecting for health check.",
},

"healthy_threshold": {
Type: schema.TypeInt,
Optional: true,
Expand Down
52 changes: 52 additions & 0 deletions ksyun/service_ksyun_alb_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ func (s *AlbListenerService) createListenerCall(d *schema.ResourceData, r *schem
"default_forward_rule": {
Type: TransformListUnique,
},
"config_content": {
Ignore: true,
},
}
req, err := SdkRequestAutoMapping(d, r, false, transform, nil, SdkReqParameter{
onlyTransform: false,
Expand All @@ -54,6 +57,18 @@ func (s *AlbListenerService) createListenerCall(d *schema.ResourceData, r *schem
req["SessionState"] = "stop"
}

// deal with custom configure
if v, ok := d.GetOk("config_content"); ok {
vals := v.(map[string]interface{})
var content string
for key, property := range vals {
kv := strings.Join([]string{key, property.(string)}, " ")

content += kv + ";"
}
req["ConfigContent"] = content
}

callback = ApiCall{
param: &req,
action: "CreateAlbListener",
Expand Down Expand Up @@ -145,6 +160,27 @@ func (s *AlbListenerService) ReadAndSetListener(d *schema.ResourceData, r *schem
if err != nil {
return err
}

// extract out of config content
if vs, ok := data["ConfigContent"]; ok {
content := vs.(string)
kvs := strings.Split(content, ";")

m := make(map[string]interface{})

for _, kv := range kvs {
kv = strings.TrimSpace(kv)
kvSlice := strings.Split(kv, " ")
if len(kvSlice) < 2 {
continue
}
m[kvSlice[0]] = kvSlice[1]
}
_ = d.Set("config_content", m)

delete(data, "ConfigContent")
}

extra := map[string]SdkResponseMapping{
"Session": {
Field: "session",
Expand Down Expand Up @@ -210,6 +246,9 @@ func (s *AlbListenerService) modifyListenerCall(d *schema.ResourceData, r *schem
"session": {
Type: TransformListUnique,
},
"config_content": {
Ignore: true,
},
}
req, err := SdkRequestAutoMapping(d, r, true, transform, nil, SdkReqParameter{
onlyTransform: false,
Expand Down Expand Up @@ -240,6 +279,19 @@ func (s *AlbListenerService) modifyListenerCall(d *schema.ResourceData, r *schem
}
}

// deal with custom configure
if d.HasChange("config_content") {
v := d.Get("config_content")
vals := v.(map[string]interface{})
var content string
for key, property := range vals {
kv := strings.Join([]string{key, property.(string)}, " ")

content += kv + ";"
}
req["ConfigContent"] = content
}

if len(req) > 0 {
req["AlbListenerId"] = d.Id()
callback = ApiCall{
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/alb_backend_server_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ The following arguments are supported:

The `health_check` object supports the following:

* `health_check_connect_port` - (Optional) The port of connecting for health check.
* `health_check_state` - (Optional) Status maintained by health examination.Valid Values:'start', 'stop'.
* `healthy_threshold` - (Optional) Health threshold.Valid Values:1-10. Default is 5.
* `host_name` - (Optional) hostname of the health check.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/alb_listener.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ The following arguments are supported:
* `alb_listener_name` - (Optional) The name of the listener.
* `alb_listener_state` - (Optional) The state of listener.Valid Values:'start', 'stop'.
* `certificate_id` - (Optional) The ID of certificate.
* `config_content` - (Optional) The custom configure for listener. [The details](https://docs.ksyun.com/documents/42615?type=3).
* `default_forward_rule` - (Optional) The default forward rule group.
* `enable_http2` - (Optional) whether enable to HTTP2.
* `http_protocol` - (Optional) Backend Protocol, valid values:'HTTP1.0','HTTP1.1'.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/healthcheck.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ resource "ksyun_healthcheck" "default" {
The following arguments are supported:

* `listener_id` - (Required, ForceNew) The id of the listener.
* `health_check_connect_port` - (Optional) The port of connecting for health check.
* `health_check_state` - (Optional) Status maintained by health examination.Valid Values:'start', 'stop'.
* `healthy_threshold` - (Optional) Health threshold.Valid Values:1-10. Default is 5.
* `host_name` - (Optional) The service host name of the health check, which is available only for the HTTP or HTTPS health check.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/lb_backend_server_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ The following arguments are supported:

The `health_check` object supports the following:

* `health_check_connect_port` - (Optional) The port of connecting for health check.
* `health_check_state` - (Optional) Status maintained by health examination.Valid Values:'start', 'stop'.
* `healthy_threshold` - (Optional) Health threshold.Valid Values:1-10. Default is 5.
* `host_name` - (Optional) hostname of the health check.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/lb_listener.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ The following arguments are supported:

The `health_check` object supports the following:

* `health_check_connect_port` - (Optional) The port of connecting for health check.
* `health_check_state` - (Optional) Status maintained by health examination.Valid Values:'start', 'stop'.
* `healthy_threshold` - (Optional) Health threshold.Valid Values:1-10. Default is 5.
* `host_name` - (Optional) The service host name of the health check, which is available only for the HTTP or HTTPS health check.
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/lb_rule.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ The following arguments are supported:

The `health_check` object supports the following:

* `health_check_connect_port` - (Optional) The port of connecting for health check.
* `health_check_state` - (Optional) Status maintained by health examination.Valid Values:'start', 'stop'.
* `healthy_threshold` - (Optional) Health threshold.Valid Values:1-10. Default is 5.
* `host_name` - (Optional) The service host name of the health check, which is available only for the HTTP or HTTPS health check.
Expand Down

0 comments on commit 61bbcb6

Please sign in to comment.