diff --git a/.github/workflows/acctest.yml b/.github/workflows/acctest.yml index 1d6aded..a8f568b 100644 --- a/.github/workflows/acctest.yml +++ b/.github/workflows/acctest.yml @@ -47,8 +47,8 @@ jobs: - stable terraform: # including a few versions here just in case - - '0.12.25' - - '0.12.24' + - '0.12.26' + - '0.13.0-beta2' steps: - name: Set up Go 1.13 diff --git a/go.mod b/go.mod index 0db28d7..ba6230d 100644 --- a/go.mod +++ b/go.mod @@ -1,16 +1,14 @@ module github.com/paultyng/terraform-provider-unifi -go 1.12 +go 1.14 // replace github.com/paultyng/go-unifi => ../go-unifi require ( - github.com/aws/aws-sdk-go v1.25.3 // indirect github.com/go-test/deep v1.0.4 // indirect github.com/hashicorp/go-hclog v0.10.1 // indirect - github.com/hashicorp/hcl/v2 v2.2.0 // indirect github.com/hashicorp/terraform-json v0.5.0 // indirect - github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.1.0.20200513175959-048e70e44356 + github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.2 github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d // indirect github.com/mattn/go-isatty v0.0.11 // indirect github.com/paultyng/go-unifi v1.3.0 diff --git a/go.sum b/go.sum index 72ca619..b80908e 100644 --- a/go.sum +++ b/go.sum @@ -81,14 +81,16 @@ github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUK github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs= github.com/hashicorp/go-getter v1.4.0 h1:ENHNi8494porjD0ZhIrjlAHnveSFhY7hvOJrV/fsKkw= github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= +github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02 h1:l1KB3bHVdvegcIf5upQ5mjcHjs2qsWnKh4Yr9xgIuu8= +github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.10.1 h1:uyt/l0dWjJ879yiAu+T7FG3/6QX+zwm4bQ8P7XsYt3o= github.com/hashicorp/go-hclog v0.10.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-plugin v1.2.0 h1:CUfYokW0EJNDcGecVrHZK//Cp1GFlHwoqtcUIEiU6BY= -github.com/hashicorp/go-plugin v1.2.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= +github.com/hashicorp/go-plugin v1.3.0 h1:4d/wJojzvHV1I4i/rrjVaeuyxWrLzDE1mDCyDy8fXS8= +github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= @@ -99,19 +101,18 @@ github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09 github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+dAcgU= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= -github.com/hashicorp/hcl/v2 v2.2.0 h1:ZQ1eNLggMfTyFBhV8swxT081mlaRjr4EG85NEjjLB84= -github.com/hashicorp/hcl/v2 v2.2.0/go.mod h1:MD4q2LOluJ5pRwTVkCXmJOY7ODWDXVXGVB8LY0t7wig= +github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= +github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/terraform-json v0.4.0 h1:KNh29iNxozP5adfUFBJ4/fWd0Cu3taGgjHB38JYqOF4= github.com/hashicorp/terraform-json v0.4.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU= github.com/hashicorp/terraform-json v0.5.0 h1:7TV3/F3y7QVSuN4r9BEXqnWqrAyeOtON8f0wvREtyzs= github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.1.0.20200513175959-048e70e44356 h1:sVX14BRZf6dFYzUzi8zl2Lx1SPo1Eoq/HXrG6+7oyqo= -github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.1.0.20200513175959-048e70e44356/go.mod h1:UJ9o0QBh28qqmV3eLZJfjPXJXjo5IRpD1lMM2QDf0yQ= -github.com/hashicorp/terraform-plugin-test v1.3.0 h1:hU5LoxrOn9qvOo+LTKN6mSav2J+dAMprbdxJPEQvp4U= -github.com/hashicorp/terraform-plugin-test v1.3.0/go.mod h1:QIJHYz8j+xJtdtLrFTlzQVC0ocr3rf/OjIpgZLK56Hs= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.2 h1:HHppQ5ly03DFdZpuxiO2qHEbZ8uJHcZiRp37O9OfnCc= +github.com/hashicorp/terraform-plugin-sdk/v2 v2.0.0-rc.2/go.mod h1:EmGbJlJ/WPDVvHZKZKSPb6jBiQ5ZFuLksxBXweufgjk= +github.com/hashicorp/terraform-plugin-test v1.4.0 h1:9/eoY48ZGgcjkSkxIvUD7MGopFYeSv/2wmS09wSZg2I= +github.com/hashicorp/terraform-plugin-test v1.4.0/go.mod h1:QIJHYz8j+xJtdtLrFTlzQVC0ocr3rf/OjIpgZLK56Hs= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d h1:W+SIwDdl3+jXWeidYySAgzytE3piq6GumXeBjFBG67c= @@ -182,8 +183,7 @@ github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6Ac github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI= github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= -github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= -github.com/zclconf/go-cty v1.1.1/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= +github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.1 h1:vGMsygfmeCl4Xb6OA5U5XVAaQZ69FvoG7X2jUtQujb8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.4.0 h1:+q+tmgyUB94HIdH/uVTIi/+kt3pt4sHwEZAcTyLoGsQ= diff --git a/internal/provider/data_user_group_test.go b/internal/provider/data_user_group_test.go index f9a3df4..d33c1a6 100644 --- a/internal/provider/data_user_group_test.go +++ b/internal/provider/data_user_group_test.go @@ -8,7 +8,8 @@ import ( func TestAccDataUserGroup_default(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/data_wlan_group_test.go b/internal/provider/data_wlan_group_test.go index 962ddc7..ca95828 100644 --- a/internal/provider/data_wlan_group_test.go +++ b/internal/provider/data_wlan_group_test.go @@ -8,7 +8,8 @@ import ( func TestAccDataWLANGroup_default(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/provider.go b/internal/provider/provider.go index e426721..0f66295 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -21,7 +21,7 @@ func init() { } } -func Provider() *schema.Provider { +func New() *schema.Provider { p := &schema.Provider{ Schema: map[string]*schema.Schema{ "username": { diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index f469b83..48388fd 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -5,11 +5,17 @@ import ( "os" "testing" - "github.com/hashicorp/terraform-plugin-sdk/v2/acctest" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" "github.com/paultyng/go-unifi/unifi" ) +var providerFactories = map[string]func() (*schema.Provider, error){ + "unifi": func() (*schema.Provider, error) { + return New(), nil + }, +} + var testClient *unifi.Client func TestMain(m *testing.M) { @@ -31,7 +37,6 @@ func TestMain(m *testing.M) { panic(err) } - acctest.UseBinaryDriver("unifi", Provider) resource.TestMain(m) } diff --git a/internal/provider/resource_firewall_group_test.go b/internal/provider/resource_firewall_group_test.go index 79ca52a..1e7c3f9 100644 --- a/internal/provider/resource_firewall_group_test.go +++ b/internal/provider/resource_firewall_group_test.go @@ -10,7 +10,8 @@ import ( func TestAccFirewallGroup_port_group(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { @@ -30,7 +31,8 @@ func TestAccFirewallGroup_port_group(t *testing.T) { func TestAccFirewallGroup_address_group(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/resource_firewall_rule_test.go b/internal/provider/resource_firewall_rule_test.go index 77266e1..dbf4323 100644 --- a/internal/provider/resource_firewall_rule_test.go +++ b/internal/provider/resource_firewall_rule_test.go @@ -8,7 +8,8 @@ import ( func TestAccFirewallRule_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/resource_network_test.go b/internal/provider/resource_network_test.go index a6f3248..dfaf982 100644 --- a/internal/provider/resource_network_test.go +++ b/internal/provider/resource_network_test.go @@ -10,7 +10,8 @@ import ( func TestAccNetwork_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { @@ -38,7 +39,8 @@ func TestAccNetwork_basic(t *testing.T) { func TestAccNetwork_weird_cidr(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { @@ -54,7 +56,8 @@ func TestAccNetwork_weird_cidr(t *testing.T) { func TestAccNetwork_dhcp_dns(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/resource_port_forward_test.go b/internal/provider/resource_port_forward_test.go index 591a4c3..6b851cf 100644 --- a/internal/provider/resource_port_forward_test.go +++ b/internal/provider/resource_port_forward_test.go @@ -9,7 +9,8 @@ import ( func TestAccPortForward_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/resource_user_group_test.go b/internal/provider/resource_user_group_test.go index 51ada0a..968fbb9 100644 --- a/internal/provider/resource_user_group_test.go +++ b/internal/provider/resource_user_group_test.go @@ -8,7 +8,8 @@ import ( func TestAccUserGroup_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { diff --git a/internal/provider/resource_user_test.go b/internal/provider/resource_user_test.go index 8af6bef..57c5142 100644 --- a/internal/provider/resource_user_test.go +++ b/internal/provider/resource_user_test.go @@ -19,7 +19,8 @@ func userImportStep(name string) resource.TestStep { func TestAccUser_basic(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { @@ -51,7 +52,8 @@ func TestAccUser_basic(t *testing.T) { func TestAccUser_fixed_ip(t *testing.T) { vlanID := 301 resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { @@ -87,7 +89,8 @@ func TestAccUser_fixed_ip(t *testing.T) { func TestAccUser_blocking(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { preCheck(t) }, + PreCheck: func() { preCheck(t) }, + ProviderFactories: providerFactories, // TODO: CheckDestroy: , Steps: []resource.TestStep{ { @@ -134,6 +137,7 @@ func TestAccUser_existing_mac_allow(t *testing.T) { t.Fatal(err) } }, + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: CheckDestroy: , @@ -168,6 +172,7 @@ func TestAccUser_existing_mac_deny(t *testing.T) { t.Fatal(err) } }, + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: CheckDestroy: , diff --git a/internal/provider/resource_wlan_test.go b/internal/provider/resource_wlan_test.go index 8c9e2d7..ab3a897 100644 --- a/internal/provider/resource_wlan_test.go +++ b/internal/provider/resource_wlan_test.go @@ -9,6 +9,8 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" ) +// TODO: test changing security, see https://github.com/paultyng/terraform-provider-unifi/issues/32 + // there is a max of 4 SSID's at once, and if you are running this on a // controller with existing SSID's, you may want to limit the concurrency. var wlanConcurrency chan struct{} @@ -40,7 +42,8 @@ func wlanPreCheck(t *testing.T) func() { func TestAccWLAN_wpapsk(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: wlanPreCheck(t), + PreCheck: wlanPreCheck(t), + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: actual CheckDestroy @@ -61,7 +64,8 @@ func TestAccWLAN_wpapsk(t *testing.T) { func TestAccWLAN_open(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: wlanPreCheck(t), + PreCheck: wlanPreCheck(t), + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: actual CheckDestroy @@ -96,7 +100,8 @@ func TestAccWLAN_open(t *testing.T) { func TestAccWLAN_change_security(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: wlanPreCheck(t), + PreCheck: wlanPreCheck(t), + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: actual CheckDestroy @@ -130,7 +135,8 @@ func TestAccWLAN_change_security(t *testing.T) { func TestAccWLAN_schedule(t *testing.T) { resource.ParallelTest(t, resource.TestCase{ - PreCheck: wlanPreCheck(t), + PreCheck: wlanPreCheck(t), + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: actual CheckDestroy @@ -155,7 +161,8 @@ func TestAccWLAN_wpaeap(t *testing.T) { } resource.ParallelTest(t, resource.TestCase{ - PreCheck: wlanPreCheck(t), + PreCheck: wlanPreCheck(t), + ProviderFactories: providerFactories, CheckDestroy: func(*terraform.State) error { // TODO: actual CheckDestroy diff --git a/main.go b/main.go index e0995e8..c35d8b7 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,6 @@ import ( func main() { plugin.Serve(&plugin.ServeOpts{ - ProviderFunc: provider.Provider, + ProviderFunc: provider.New, }) }