Skip to content
This repository was archived by the owner on Jun 27, 2021. It is now read-only.

Commit 13f8aa2

Browse files
authored
0.1.27 (#96)
* v0.1.25 * Release v0.1.25 Signed-off-by: Chase Sillevis <chase@sillevis.net> * https://www.terraform.io/docs/extend/plugin-sdk.html * Release v0.1.26 Signed-off-by: Chase Sillevis <chase@sillevis.net> * update config test * 0.1.27
1 parent 7f2f067 commit 13f8aa2

20 files changed

+58
-206
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ GOVERSION := 1.12
1919
PROJECT := github.com/DeviaVir/terraform-provider-gsuite
2020
OWNER := $(notdir $(patsubst %/,%,$(dir $(PROJECT))))
2121
NAME := $(notdir $(PROJECT))
22-
VERSION := 0.1.25
22+
VERSION := 0.1.27
2323
EXTERNAL_TOOLS = \
2424
github.com/golang/dep/cmd/dep
2525

go.mod

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,17 @@ require (
77
github.com/aws/aws-sdk-go v1.24.3 // indirect
88
github.com/go-test/deep v1.0.4 // indirect
99
github.com/google/go-cmp v0.3.1 // indirect
10-
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
11-
github.com/hashicorp/go-hclog v0.9.2 // indirect
12-
github.com/hashicorp/go-plugin v1.0.1 // indirect
13-
github.com/hashicorp/go-version v1.2.0 // indirect
1410
github.com/hashicorp/hcl v1.0.0 // indirect
1511
github.com/hashicorp/hcl2 v0.0.0-20190909202536-66c59f909e25 // indirect
1612
github.com/hashicorp/hil v0.0.0-20190212132231-97b3a9cdfa93 // indirect
17-
github.com/hashicorp/terraform v0.12.9
13+
github.com/hashicorp/terraform-plugin-sdk v1.0.0
1814
github.com/hashicorp/yamux v0.0.0-20190923154419-df201c70410d // indirect
1915
github.com/mattn/go-colorable v0.1.2 // indirect
2016
github.com/mattn/go-isatty v0.0.9 // indirect
21-
github.com/mitchellh/reflectwalk v1.0.1 // indirect
2217
github.com/pkg/errors v0.8.1
23-
github.com/spf13/afero v1.2.2 // indirect
2418
github.com/stretchr/testify v1.4.0 // indirect
2519
github.com/ulikunitz/xz v0.5.6 // indirect
2620
github.com/vmihailenco/msgpack v4.0.4+incompatible // indirect
27-
github.com/zclconf/go-cty v1.1.0 // indirect
2821
go.opencensus.io v0.22.1 // indirect
2922
golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392 // indirect
3023
golang.org/x/exp v0.0.0-20190919035709-81c71964d733 // indirect

go.sum

Lines changed: 11 additions & 162 deletions
Large diffs are not rendered by default.

gsuite/config.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ import (
99
"runtime"
1010
"strings"
1111

12-
"github.com/hashicorp/terraform/helper/logging"
13-
"github.com/hashicorp/terraform/helper/pathorcontents"
14-
"github.com/hashicorp/terraform/terraform"
12+
"github.com/hashicorp/terraform-plugin-sdk/helper/logging"
13+
"github.com/hashicorp/terraform-plugin-sdk/helper/pathorcontents"
1514
"github.com/pkg/errors"
1615
"golang.org/x/oauth2/google"
1716
"golang.org/x/oauth2/jwt"
@@ -44,7 +43,7 @@ type Config struct {
4443

4544
// loadAndValidate loads the application default credentials from the
4645
// environment and creates a client for communicating with Google APIs.
47-
func (c *Config) loadAndValidate() error {
46+
func (c *Config) loadAndValidate(terraformVersion string) error {
4847
log.Println("[INFO] Building gsuite client config structure")
4948
var account accountFile
5049

@@ -98,7 +97,7 @@ func (c *Config) loadAndValidate() error {
9897
// just a nice thing to do.
9998
client.Transport = logging.NewTransport("Google", client.Transport)
10099
userAgent := fmt.Sprintf("(%s %s) Terraform/%s",
101-
runtime.GOOS, runtime.GOARCH, terraform.VersionString())
100+
runtime.GOOS, runtime.GOARCH, terraformVersion)
102101

103102
// Create the directory service.
104103
directorySvc, err := directory.New(client)

gsuite/config_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ func TestConfigLoadAndValidate_accountFilePath(t *testing.T) {
1313
ImpersonatedUserEmail: "xxx@xxx.xom",
1414
}
1515

16-
err := config.loadAndValidate()
16+
err := config.loadAndValidate("0.12")
1717
if err != nil {
1818
t.Fatalf("error: %v", err)
1919
}
@@ -29,7 +29,7 @@ func TestConfigLoadAndValidate_accountFileJSON(t *testing.T) {
2929
ImpersonatedUserEmail: "xxx@xxx.xom",
3030
}
3131

32-
err = config.loadAndValidate()
32+
err = config.loadAndValidate("0.12")
3333
if err != nil {
3434
t.Fatalf("error: %v", err)
3535
}
@@ -40,7 +40,7 @@ func TestConfigLoadAndValidate_accountFileJSONInvalid(t *testing.T) {
4040
Credentials: "{this is not json}",
4141
}
4242

43-
if config.loadAndValidate() == nil {
43+
if config.loadAndValidate("0.12") == nil {
4444
t.Fatalf("expected error, but got nil")
4545
}
4646
}
@@ -52,7 +52,7 @@ func TestConfigLoadAndValidate_noImpersonatedEmail(t *testing.T) {
5252
ImpersonatedUserEmail: "",
5353
}
5454

55-
err := config.loadAndValidate()
55+
err := config.loadAndValidate("0.12")
5656
if err == nil {
5757
t.Fatalf("error: %v", err)
5858
}
@@ -65,7 +65,7 @@ func TestConfigLoadAndValidate_noImpersonatedEmail(t *testing.T) {
6565
Credentials: testFakeCredentialsPath,
6666
}
6767

68-
err = config.loadAndValidate()
68+
err = config.loadAndValidate("0.12")
6969
if err == nil {
7070
t.Fatalf("error: %v", err)
7171
}

gsuite/data_group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package gsuite
33
import (
44
"fmt"
55

6-
"github.com/hashicorp/terraform/helper/schema"
6+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
77
directory "google.golang.org/api/admin/directory/v1"
88
)
99

gsuite/data_group_settings.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package gsuite
33
import (
44
"fmt"
55

6-
"github.com/hashicorp/terraform/helper/schema"
6+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
77
)
88

99
func dataGroupSettings() *schema.Resource {

gsuite/data_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import (
44
"fmt"
55
"strings"
66

7-
"github.com/hashicorp/terraform/helper/schema"
7+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
88
directory "google.golang.org/api/admin/directory/v1"
99
)
1010

gsuite/data_user_attributes.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"fmt"
66
"strconv"
77

8-
"github.com/hashicorp/terraform/helper/hashcode"
9-
"github.com/hashicorp/terraform/helper/schema"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/hashcode"
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
1010
)
1111

1212
// userAttrMappings is a mapping of top level keys in a gsuite_user_attributes

gsuite/provider.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66
"log"
77
"os"
88

9-
"github.com/hashicorp/terraform/helper/schema"
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
1010
"github.com/pkg/errors"
1111
)
1212

1313
// Provider returns the actual provider instance.
1414
func Provider() *schema.Provider {
15-
return &schema.Provider{
15+
p := &schema.Provider{
1616
Schema: map[string]*schema.Schema{
1717
"credentials": {
1818
Type: schema.TypeString,
@@ -54,8 +54,19 @@ func Provider() *schema.Provider {
5454
"gsuite_user": resourceUser(),
5555
"gsuite_user_schema": resourceUserSchema(),
5656
},
57-
ConfigureFunc: providerConfigure,
5857
}
58+
59+
p.ConfigureFunc = func(d *schema.ResourceData) (interface{}, error) {
60+
terraformVersion := p.TerraformVersion
61+
if terraformVersion == "" {
62+
// Terraform 0.12 introduced this field to the protocol
63+
// We can therefore assume that if it's missing it's 0.10 or 0.11
64+
terraformVersion = "0.11+compatible"
65+
}
66+
return providerConfigure(d, terraformVersion)
67+
}
68+
69+
return p
5970
}
6071

6172
func oauthScopesFromConfigOrDefault(oauthScopesSet *schema.Set) []string {
@@ -67,7 +78,7 @@ func oauthScopesFromConfigOrDefault(oauthScopesSet *schema.Set) []string {
6778
return oauthScopes
6879
}
6980

70-
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
81+
func providerConfigure(d *schema.ResourceData, terraformVersion string) (interface{}, error) {
7182
var impersonatedUserEmail string
7283
var customerID string
7384

@@ -100,7 +111,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
100111
CustomerId: customerID,
101112
}
102113

103-
if err := config.loadAndValidate(); err != nil {
114+
if err := config.loadAndValidate(terraformVersion); err != nil {
104115
return nil, errors.Wrap(err, "failed to load config")
105116
}
106117

gsuite/provider_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import (
44
"io/ioutil"
55
"testing"
66

7-
"github.com/hashicorp/terraform/helper/schema"
8-
"github.com/hashicorp/terraform/terraform"
7+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
8+
"github.com/hashicorp/terraform-plugin-sdk/terraform"
99
)
1010

1111
var testAccProviders map[string]terraform.ResourceProvider

gsuite/resource_domain.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"strings"
77

8-
"github.com/hashicorp/terraform/helper/schema"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
99
directory "google.golang.org/api/admin/directory/v1"
1010
)
1111

gsuite/resource_group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"strings"
77

8-
"github.com/hashicorp/terraform/helper/schema"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
99
directory "google.golang.org/api/admin/directory/v1"
1010
)
1111

gsuite/resource_group_member.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"strings"
77

8-
"github.com/hashicorp/terraform/helper/schema"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
99
directory "google.golang.org/api/admin/directory/v1"
1010
)
1111

gsuite/resource_group_members.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"strings"
77

8-
"github.com/hashicorp/terraform/helper/schema"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
99
directory "google.golang.org/api/admin/directory/v1"
1010
"google.golang.org/api/googleapi"
1111
)

gsuite/resource_group_settings.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"log"
66
"strings"
77

8-
"github.com/hashicorp/terraform/helper/schema"
9-
"github.com/hashicorp/terraform/helper/validation"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
1010

1111
groupSettings "google.golang.org/api/groupssettings/v1"
1212
)

gsuite/resource_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"sort"
88
"strings"
99

10-
"github.com/hashicorp/terraform/helper/schema"
10+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
1111
"github.com/pkg/errors"
1212
directory "google.golang.org/api/admin/directory/v1"
1313
"google.golang.org/api/googleapi"

gsuite/resource_user_schema.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import (
55
"log"
66
"strconv"
77

8-
"github.com/hashicorp/terraform/helper/schema"
9-
"github.com/hashicorp/terraform/helper/validation"
8+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
9+
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
1010
directory "google.golang.org/api/admin/directory/v1"
1111
)
1212

gsuite/utils.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ import (
88
"strings"
99
"time"
1010

11-
"github.com/hashicorp/terraform/helper/resource"
12-
"github.com/hashicorp/terraform/helper/schema"
11+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
12+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
1313
"google.golang.org/api/googleapi"
1414
)
1515

main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package main
22

33
import (
44
"github.com/DeviaVir/terraform-provider-gsuite/gsuite"
5-
"github.com/hashicorp/terraform/plugin"
6-
"github.com/hashicorp/terraform/terraform"
5+
"github.com/hashicorp/terraform-plugin-sdk/plugin"
6+
"github.com/hashicorp/terraform-plugin-sdk/terraform"
77
)
88

99
func main() {

0 commit comments

Comments
 (0)