Skip to content

Commit

Permalink
Merge pull request #82 from alakae/alain/lb-stubs
Browse files Browse the repository at this point in the history
Support nil Listeners on Pool
  • Loading branch information
alakae authored Oct 24, 2023
2 parents d37ee23 + b68b391 commit 7f1a5ac
Show file tree
Hide file tree
Showing 233 changed files with 18,872 additions and 4,005 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ go mod vendor

Use the following commands to switch to a local version of the go-sdk and back:
```sh
go mod edit -replace "github.com/cloudscale-ch/cloudscale-go-sdk/v3=../cloudscale-go-sdk/"
go mod edit -replace "github.com/cloudscale-ch/cloudscale-go-sdk/v4=../cloudscale-go-sdk/"
go mod vendor
git commit -m "drop: Use local version of cloudscale-go-sdk"
```
```sh
go mod edit -dropreplace "github.com/cloudscale-ch/cloudscale-go-sdk/v3"
go mod edit -dropreplace "github.com/cloudscale-ch/cloudscale-go-sdk/v4"
go mod vendor
```

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/config.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package cloudscale

import (
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/logging"
"golang.org/x/oauth2"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_custom_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_floating_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_floating_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"context"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"context"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_load_balancer_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"context"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_load_balancer_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"context"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"context"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_load_balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"regexp"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_objects_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_objects_user_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_server_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_server_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_subnet.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_subnet_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/datasource_cloudscale_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
)
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"context"
"strconv"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/resource_cloudscale_custom_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"math"
"time"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/resource_cloudscale_custom_image_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"strings"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/resource_cloudscale_floating_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"log"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

Expand Down
2 changes: 1 addition & 1 deletion cloudscale/resource_cloudscale_floating_ip_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"regexp"
"testing"

"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
2 changes: 1 addition & 1 deletion cloudscale/resource_cloudscale_load_balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
23 changes: 16 additions & 7 deletions cloudscale/resource_cloudscale_load_balancer_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cloudscale
import (
"context"
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"log"
)
Expand Down Expand Up @@ -43,8 +43,8 @@ func getLoadBalancerListenerSchema(t SchemaType) map[string]*schema.Schema {
},
"pool_uuid": {
Type: schema.TypeString,
Required: t.isResource(),
Optional: t.isDataSource(),
Optional: true,
Computed: true,
ForceNew: true,
},
"pool_name": {
Expand Down Expand Up @@ -102,11 +102,14 @@ func resourceCloudscaleLoadBalancerListenerCreate(d *schema.ResourceData, meta a

opts := &cloudscale.LoadBalancerListenerRequest{
Name: d.Get("name").(string),
Pool: d.Get("pool_uuid").(string),
Protocol: d.Get("protocol").(string),
ProtocolPort: d.Get("protocol_port").(int),
}

if attr, ok := d.GetOk("pool_uuid"); ok {
opts.Pool = attr.(string)
}

if attr, ok := d.GetOk("timeout_client_data_ms"); ok {
opts.TimeoutClientDataMS = attr.(int)
}
Expand Down Expand Up @@ -148,9 +151,15 @@ func gatherLoadBalancerListenerResourceData(loadbalancerlistener *cloudscale.Loa
m["id"] = loadbalancerlistener.UUID
m["href"] = loadbalancerlistener.HREF
m["name"] = loadbalancerlistener.Name
m["pool_uuid"] = loadbalancerlistener.Pool.UUID
m["pool_name"] = loadbalancerlistener.Pool.Name
m["pool_href"] = loadbalancerlistener.Pool.HREF
if loadbalancerlistener.Pool != nil {
m["pool_uuid"] = loadbalancerlistener.Pool.UUID
m["pool_name"] = loadbalancerlistener.Pool.Name
m["pool_href"] = loadbalancerlistener.Pool.HREF
} else {
m["pool_uuid"] = nil
m["pool_name"] = nil
m["pool_href"] = nil
}
m["protocol"] = loadbalancerlistener.Protocol
m["protocol_port"] = loadbalancerlistener.ProtocolPort
m["timeout_client_data_ms"] = loadbalancerlistener.TimeoutClientDataMS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package cloudscale

import (
"fmt"
"github.com/cloudscale-ch/cloudscale-go-sdk/v3"
"github.com/cloudscale-ch/cloudscale-go-sdk/v4"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"
Expand Down
Loading

0 comments on commit 7f1a5ac

Please sign in to comment.