Skip to content

Commit

Permalink
Merge pull request #90 from alibaba/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
demonwy authored Mar 3, 2017
2 parents 5855393 + fad8b98 commit 7db5521
Show file tree
Hide file tree
Showing 9 changed files with 452 additions and 93 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
## 1.0.4 (unreleased)

## 1.0.3 (March 4, 2017)

FEATURES:

* **New Resource:** `alicloud_db_instance` ([#85](https://github.com/alibaba/terraform-provider/pull/85))

IMPROVEMENTS:

* resource/alicloud_slb: support slb listener persistence_timeout and health check ([#86](https://github.com/alibaba/terraform-provider/pull/86))

## 1.0.2 (February 24, 2017)

IMPROVEMENTS:
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Aliyun (Alibaba Cloud) terraform provider
## Alicloud (Alibaba Cloud) terraform provider

This is the official repository for the Aliyun terraform provider.
This is the official repository for the Alicloud terraform provider.
Currently it supports terraform version ≥ v0.8.2.

If you are not planning to contribute to this repo, you can download the compiled binaries below and move
Expand Down Expand Up @@ -90,6 +90,7 @@ sudo -E "PATH=$PATH" make all
* Contributions are welcome and will be merged via PRs.

### Contributors
* demonwy([email protected])
* heww([email protected])
* ShuWei([email protected])
* WangYuelucky([email protected])
Expand Down
97 changes: 95 additions & 2 deletions alicloud/extension_slb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,41 @@ import (
)

type Listener struct {
slb.HTTPListenerType

InstancePort int
LoadBalancerPort int
Protocol string
//tcp & udp
PersistenceTimeout int

//https
SSLCertificateId string
Bandwidth int

//tcp
HealthCheckType slb.HealthCheckType

//api interface: http & https is HealthCheckTimeout, tcp & udp is HealthCheckConnectTimeout
HealthCheckConnectTimeout int
}

type ListenerErr struct {
ErrType string
Err error
}

func (e *ListenerErr) Error() string {
return e.ErrType + " " + e.Err.Error()

}

const (
HealthCheckErrType = "healthCheckErrType"
StickySessionErrType = "stickySessionErrType"
CookieTimeOutErrType = "cookieTimeoutErrType"
CookieErrType = "cookieErrType"
)

// Takes the result of flatmap.Expand for an array of listeners and
// returns ELB API compatible objects
func expandListeners(configured []interface{}) ([]*Listener, error) {
Expand All @@ -31,13 +59,78 @@ func expandListeners(configured []interface{}) ([]*Listener, error) {
InstancePort: ip,
LoadBalancerPort: lp,
Protocol: data["lb_protocol"].(string),
Bandwidth: data["bandwidth"].(int),
}

l.Bandwidth = data["bandwidth"].(int)

if v, ok := data["scheduler"]; ok {
l.Scheduler = slb.SchedulerType(v.(string))
}

if v, ok := data["ssl_certificate_id"]; ok {
l.SSLCertificateId = v.(string)
}

if v, ok := data["sticky_session"]; ok {
l.StickySession = slb.FlagType(v.(string))
}

if v, ok := data["sticky_session_type"]; ok {
l.StickySessionType = slb.StickySessionType(v.(string))
}

if v, ok := data["cookie_timeout"]; ok {
l.CookieTimeout = v.(int)
}

if v, ok := data["cookie"]; ok {
l.Cookie = v.(string)
}

if v, ok := data["persistence_timeout"]; ok {
l.PersistenceTimeout = v.(int)
}

if v, ok := data["health_check"]; ok {
l.HealthCheck = slb.FlagType(v.(string))
}

if v, ok := data["health_check_type"]; ok {
l.HealthCheckType = slb.HealthCheckType(v.(string))
}

if v, ok := data["health_check_domain"]; ok {
l.HealthCheckDomain = v.(string)
}

if v, ok := data["health_check_uri"]; ok {
l.HealthCheckURI = v.(string)
}

if v, ok := data["health_check_connect_port"]; ok {
l.HealthCheckConnectPort = v.(int)
}

if v, ok := data["healthy_threshold"]; ok {
l.HealthyThreshold = v.(int)
}

if v, ok := data["unhealthy_threshold"]; ok {
l.UnhealthyThreshold = v.(int)
}

if v, ok := data["health_check_timeout"]; ok {
l.HealthCheckTimeout = v.(int)
}

if v, ok := data["health_check_interval"]; ok {
l.HealthCheckInterval = v.(int)
}

if v, ok := data["health_check_http_code"]; ok {
l.HealthCheckHttpCode = slb.HealthCheckHttpCodeType(v.(string))
}

var valid bool
if l.SSLCertificateId != "" {
// validate the protocol is correct
Expand Down
Loading

0 comments on commit 7db5521

Please sign in to comment.