Skip to content

Commit 2bf8eed

Browse files
Adding new Lustre Resource (#13181) (#9601)
[upstream:90ac94c0f810d38e929eb2eef14e60515c456977] Signed-off-by: Modular Magician <[email protected]>
1 parent a3986dd commit 2bf8eed

14 files changed

+1424
-2
lines changed

.changelog/13181.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_lustre_instance`
3+
```

google-beta/fwmodels/provider_model.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ type ProviderModel struct {
125125
KMSCustomEndpoint types.String `tfsdk:"kms_custom_endpoint"`
126126
LoggingCustomEndpoint types.String `tfsdk:"logging_custom_endpoint"`
127127
LookerCustomEndpoint types.String `tfsdk:"looker_custom_endpoint"`
128+
LustreCustomEndpoint types.String `tfsdk:"lustre_custom_endpoint"`
128129
ManagedKafkaCustomEndpoint types.String `tfsdk:"managed_kafka_custom_endpoint"`
129130
MemcacheCustomEndpoint types.String `tfsdk:"memcache_custom_endpoint"`
130131
MemorystoreCustomEndpoint types.String `tfsdk:"memorystore_custom_endpoint"`

google-beta/fwprovider/framework_provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,12 @@ func (p *FrameworkProvider) Schema(_ context.Context, _ provider.SchemaRequest,
731731
transport_tpg.CustomEndpointValidator(),
732732
},
733733
},
734+
"lustre_custom_endpoint": &schema.StringAttribute{
735+
Optional: true,
736+
Validators: []validator.String{
737+
transport_tpg.CustomEndpointValidator(),
738+
},
739+
},
734740
"managed_kafka_custom_endpoint": &schema.StringAttribute{
735741
Optional: true,
736742
Validators: []validator.String{

google-beta/provider/provider.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,11 @@ func Provider() *schema.Provider {
623623
Optional: true,
624624
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
625625
},
626+
"lustre_custom_endpoint": {
627+
Type: schema.TypeString,
628+
Optional: true,
629+
ValidateFunc: transport_tpg.ValidateCustomEndpoint,
630+
},
626631
"managed_kafka_custom_endpoint": {
627632
Type: schema.TypeString,
628633
Optional: true,
@@ -1200,6 +1205,7 @@ func ProviderConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
12001205
config.KMSBasePath = d.Get("kms_custom_endpoint").(string)
12011206
config.LoggingBasePath = d.Get("logging_custom_endpoint").(string)
12021207
config.LookerBasePath = d.Get("looker_custom_endpoint").(string)
1208+
config.LustreBasePath = d.Get("lustre_custom_endpoint").(string)
12031209
config.ManagedKafkaBasePath = d.Get("managed_kafka_custom_endpoint").(string)
12041210
config.MemcacheBasePath = d.Get("memcache_custom_endpoint").(string)
12051211
config.MemorystoreBasePath = d.Get("memorystore_custom_endpoint").(string)

google-beta/provider/provider_mmv1_resources.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ import (
9999
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/kms"
100100
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/logging"
101101
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/looker"
102+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/lustre"
102103
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/managedkafka"
103104
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/memcache"
104105
"github.com/hashicorp/terraform-provider-google-beta/google-beta/services/memorystore"
@@ -547,9 +548,9 @@ var handwrittenIAMDatasources = map[string]*schema.Resource{
547548
}
548549

549550
// Resources
550-
// Generated resources: 626
551+
// Generated resources: 627
551552
// Generated IAM resources: 306
552-
// Total generated resources: 932
553+
// Total generated resources: 933
553554
var generatedResources = map[string]*schema.Resource{
554555
"google_folder_access_approval_settings": accessapproval.ResourceAccessApprovalFolderSettings(),
555556
"google_organization_access_approval_settings": accessapproval.ResourceAccessApprovalOrganizationSettings(),
@@ -1196,6 +1197,7 @@ var generatedResources = map[string]*schema.Resource{
11961197
"google_logging_metric": logging.ResourceLoggingMetric(),
11971198
"google_logging_organization_settings": logging.ResourceLoggingOrganizationSettings(),
11981199
"google_looker_instance": looker.ResourceLookerInstance(),
1200+
"google_lustre_instance": lustre.ResourceLustreInstance(),
11991201
"google_managed_kafka_cluster": managedkafka.ResourceManagedKafkaCluster(),
12001202
"google_managed_kafka_connect_cluster": managedkafka.ResourceManagedKafkaConnectCluster(),
12011203
"google_managed_kafka_connector": managedkafka.ResourceManagedKafkaConnector(),
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
// Copyright (c) HashiCorp, Inc.
2+
// SPDX-License-Identifier: MPL-2.0
3+
4+
// ----------------------------------------------------------------------------
5+
//
6+
// *** AUTO GENERATED CODE *** Type: MMv1 ***
7+
//
8+
// ----------------------------------------------------------------------------
9+
//
10+
// This file is automatically generated by Magic Modules and manual
11+
// changes will be clobbered when the file is regenerated.
12+
//
13+
// Please read more about how to change this file in
14+
// .github/CONTRIBUTING.md.
15+
//
16+
// ----------------------------------------------------------------------------
17+
18+
package lustre
19+
20+
import (
21+
"encoding/json"
22+
"errors"
23+
"fmt"
24+
"time"
25+
26+
"github.com/hashicorp/terraform-provider-google-beta/google-beta/tpgresource"
27+
transport_tpg "github.com/hashicorp/terraform-provider-google-beta/google-beta/transport"
28+
)
29+
30+
type LustreOperationWaiter struct {
31+
Config *transport_tpg.Config
32+
UserAgent string
33+
Project string
34+
tpgresource.CommonOperationWaiter
35+
}
36+
37+
func (w *LustreOperationWaiter) QueryOp() (interface{}, error) {
38+
if w == nil {
39+
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
40+
}
41+
// Returns the proper get.
42+
url := fmt.Sprintf("%s%s", w.Config.LustreBasePath, w.CommonOperationWaiter.Op.Name)
43+
44+
return transport_tpg.SendRequest(transport_tpg.SendRequestOptions{
45+
Config: w.Config,
46+
Method: "GET",
47+
Project: w.Project,
48+
RawURL: url,
49+
UserAgent: w.UserAgent,
50+
})
51+
}
52+
53+
func createLustreWaiter(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string) (*LustreOperationWaiter, error) {
54+
w := &LustreOperationWaiter{
55+
Config: config,
56+
UserAgent: userAgent,
57+
Project: project,
58+
}
59+
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
60+
return nil, err
61+
}
62+
return w, nil
63+
}
64+
65+
// nolint: deadcode,unused
66+
func LustreOperationWaitTimeWithResponse(config *transport_tpg.Config, op map[string]interface{}, response *map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
67+
w, err := createLustreWaiter(config, op, project, activity, userAgent)
68+
if err != nil {
69+
return err
70+
}
71+
if err := tpgresource.OperationWait(w, activity, timeout, config.PollInterval); err != nil {
72+
return err
73+
}
74+
rawResponse := []byte(w.CommonOperationWaiter.Op.Response)
75+
if len(rawResponse) == 0 {
76+
return errors.New("`resource` not set in operation response")
77+
}
78+
return json.Unmarshal(rawResponse, response)
79+
}
80+
81+
func LustreOperationWaitTime(config *transport_tpg.Config, op map[string]interface{}, project, activity, userAgent string, timeout time.Duration) error {
82+
if val, ok := op["name"]; !ok || val == "" {
83+
// This was a synchronous call - there is no operation to wait for.
84+
return nil
85+
}
86+
w, err := createLustreWaiter(config, op, project, activity, userAgent)
87+
if err != nil {
88+
// If w is nil, the op was synchronous.
89+
return err
90+
}
91+
return tpgresource.OperationWait(w, activity, timeout, config.PollInterval)
92+
}

0 commit comments

Comments
 (0)