Skip to content

Commit d6a3783

Browse files
committed
Sync bitbucket and GitHub
1 parent c279253 commit d6a3783

File tree

4 files changed

+98
-1
lines changed

4 files changed

+98
-1
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 22.8.1
2+
BUG FIXES:
3+
* resource/storage_pool: Fix creation error with shared vpc. ([#69](https://github.com/NetApp/terraform-provider-netapp-gcp/issues/69))
4+
15
## 22.8.0
26
BUG FIXES:
37
* resource/volume: update the create and delete volume error message verification.

gcp/resource_netapp_gcp_storage_pool.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log"
66
"regexp"
7+
"strings"
78

89
"github.com/hashicorp/terraform/helper/schema"
910
"github.com/hashicorp/terraform/helper/validation"
@@ -116,6 +117,10 @@ func resourceGCPStoragePoolCreate(d *schema.ResourceData, meta interface{}) erro
116117
}
117118
}
118119

120+
if v, ok := d.GetOk("shared_vpc_project_number"); ok {
121+
pool.SharedVpcProjectNumber = v.(string)
122+
}
123+
119124
res, err := client.createStoragePool(&pool)
120125
if err != nil {
121126
log.Printf("Error creating storage pool: %#v", err)
@@ -139,6 +144,10 @@ func resourceGCPStoragePoolRead(d *schema.ResourceData, meta interface{}) error
139144
if err != nil {
140145
return err
141146
}
147+
if strings.ToLower(res.State) == "deleted" {
148+
d.SetId("")
149+
return nil
150+
}
142151
if res.PoolID != id {
143152
return fmt.Errorf("Expected storage pool with id: %v, Response contained storage pool with id: %v",
144153
d.Id(), res.PoolID)
@@ -161,6 +170,28 @@ func resourceGCPStoragePoolRead(d *schema.ResourceData, meta interface{}) error
161170
return fmt.Errorf("Error reading storage pool billing_label: %s", err)
162171
}
163172
}
173+
// res.Network either contains simple network name or
174+
// projects/${HOST_PROJECT_ID}/global/networks/${SHARED_VPC_NAME}, usually (but not exclusively) for shared VPC
175+
nws := strings.Split(res.Network, "/")
176+
var network string
177+
if len(nws) == 1 {
178+
// standalone project network
179+
network = nws[0]
180+
} else if len(nws) == 5 {
181+
// long network path
182+
network = nws[4]
183+
// if network path contains different projectId than our project, it is shared-VPC
184+
if nws[1] != client.Project {
185+
if err := d.Set("shared_vpc_project_number", nws[1]); err != nil {
186+
return fmt.Errorf("Error reading shared_vpc_project_number: %s", err)
187+
}
188+
}
189+
} else {
190+
return fmt.Errorf("Network path %s is invalid", res.Network)
191+
}
192+
if err := d.Set("network", network); err != nil {
193+
return fmt.Errorf("Error reading volume network: %s", err)
194+
}
164195

165196
return nil
166197
}

gcp/storage_pool.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ type storagePool struct {
2121
StorageClass string `json:"storageClass"`
2222
Jobs []job `json:"jobs"`
2323
BillingLabels []billingLabel `json:"billingLabels"`
24+
State string `json:"state"`
2425
SharedVpcProjectNumber string
2526
}
2627

go.mod

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,68 @@ require (
88
github.com/hashicorp/terraform v0.12.28
99
github.com/sirupsen/logrus v1.6.0
1010
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
11-
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
1211
google.golang.org/api v0.9.0
1312
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55
1413
)
14+
15+
require (
16+
github.com/agext/levenshtein v1.2.2 // indirect
17+
github.com/apparentlymart/go-cidr v1.0.1 // indirect
18+
github.com/apparentlymart/go-textseg v1.0.0 // indirect
19+
github.com/armon/go-radix v1.0.0 // indirect
20+
github.com/aws/aws-sdk-go v1.30.12 // indirect
21+
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d // indirect
22+
github.com/bgentry/speakeasy v0.1.0 // indirect
23+
github.com/blang/semver v3.5.1+incompatible // indirect
24+
github.com/bmatcuk/doublestar v1.1.5 // indirect
25+
github.com/davecgh/go-spew v1.1.1 // indirect
26+
github.com/fatih/color v1.7.0 // indirect
27+
github.com/golang/protobuf v1.3.4 // indirect
28+
github.com/google/go-cmp v0.3.1 // indirect
29+
github.com/google/uuid v1.1.1 // indirect
30+
github.com/googleapis/gax-go/v2 v2.0.5 // indirect
31+
github.com/hashicorp/errwrap v1.0.0 // indirect
32+
github.com/hashicorp/go-cleanhttp v0.5.1 // indirect
33+
github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02 // indirect
34+
github.com/hashicorp/go-hclog v0.0.0-20181001195459-61d530d6c27f // indirect
35+
github.com/hashicorp/go-multierror v1.0.0 // indirect
36+
github.com/hashicorp/go-plugin v1.3.0 // indirect
37+
github.com/hashicorp/go-retryablehttp v0.5.2 // indirect
38+
github.com/hashicorp/go-safetemp v1.0.0 // indirect
39+
github.com/hashicorp/go-uuid v1.0.1 // indirect
40+
github.com/hashicorp/go-version v1.2.0 // indirect
41+
github.com/hashicorp/golang-lru v0.5.1 // indirect
42+
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f // indirect
43+
github.com/hashicorp/hcl/v2 v2.3.0 // indirect
44+
github.com/hashicorp/hil v0.0.0-20190212112733-ab17b08d6590 // indirect
45+
github.com/hashicorp/terraform-config-inspect v0.0.0-20191212124732-c6ae6269b9d7 // indirect
46+
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 // indirect
47+
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb // indirect
48+
github.com/jmespath/go-jmespath v0.3.0 // indirect
49+
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
50+
github.com/mattn/go-colorable v0.1.1 // indirect
51+
github.com/mattn/go-isatty v0.0.5 // indirect
52+
github.com/mitchellh/cli v1.0.0 // indirect
53+
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
54+
github.com/mitchellh/copystructure v1.0.0 // indirect
55+
github.com/mitchellh/go-homedir v1.1.0 // indirect
56+
github.com/mitchellh/go-testing-interface v1.0.0 // indirect
57+
github.com/mitchellh/go-wordwrap v1.0.0 // indirect
58+
github.com/mitchellh/hashstructure v1.0.0 // indirect
59+
github.com/mitchellh/mapstructure v1.1.2 // indirect
60+
github.com/mitchellh/reflectwalk v1.0.0 // indirect
61+
github.com/oklog/run v1.0.0 // indirect
62+
github.com/posener/complete v1.2.1 // indirect
63+
github.com/spf13/afero v1.2.1 // indirect
64+
github.com/ulikunitz/xz v0.5.5 // indirect
65+
github.com/vmihailenco/msgpack v4.0.1+incompatible // indirect
66+
github.com/zclconf/go-cty v1.2.1 // indirect
67+
github.com/zclconf/go-cty-yaml v1.0.1 // indirect
68+
go.opencensus.io v0.22.0 // indirect
69+
golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37 // indirect
70+
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
71+
golang.org/x/sys v0.0.0-20220627191245-f75cf1eec38b // indirect
72+
golang.org/x/text v0.3.2 // indirect
73+
google.golang.org/appengine v1.6.1 // indirect
74+
google.golang.org/grpc v1.27.1 // indirect
75+
)

0 commit comments

Comments
 (0)