Skip to content

Commit aaa108d

Browse files
Network Connectivity Hub (#5574) (#10812)
Signed-off-by: Modular Magician <[email protected]>
1 parent 9eef5a4 commit aaa108d

10 files changed

+742
-0
lines changed

.changelog/5574.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-resource
2+
`google_network_connectivity_hub`
3+
```

google/config.go

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ type Config struct {
249249
GkeHubBasePath string
250250
ContainerAzureBasePath string
251251
ContainerAwsBasePath string
252+
NetworkConnectivityBasePath string
252253
OrgPolicyBasePath string
253254
RecaptchaEnterpriseBasePath string
254255
// CloudBuild WorkerPool uses a different endpoint (v1beta1) than any other CloudBuild resources

google/provider.go

+3
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ func Provider() *schema.Provider {
688688
CloudResourceManagerEndpointEntryKey: CloudResourceManagerEndpointEntry,
689689
EventarcEndpointEntryKey: EventarcEndpointEntry,
690690
GkeHubFeatureCustomEndpointEntryKey: GkeHubFeatureCustomEndpointEntry,
691+
NetworkConnectivityEndpointEntryKey: NetworkConnectivityEndpointEntry,
691692
OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
692693
PrivatecaCertificateTemplateEndpointEntryKey: PrivatecaCertificateTemplateCustomEndpointEntry,
693694
RecaptchaEnterpriseEndpointEntryKey: RecaptchaEnterpriseEndpointEntry,
@@ -1212,6 +1213,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
12121213
"google_compute_firewall_policy_rule": resourceComputeFirewallPolicyRule(),
12131214
"google_dataproc_workflow_template": resourceDataprocWorkflowTemplate(),
12141215
"google_eventarc_trigger": resourceEventarcTrigger(),
1216+
"google_network_connectivity_hub": resourceNetworkConnectivityHub(),
12151217
"google_org_policy_policy": resourceOrgPolicyPolicy(),
12161218
"google_os_config_os_policy_assignment": resourceOSConfigOSPolicyAssignment(),
12171219
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
@@ -1453,6 +1455,7 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
14531455
config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string)
14541456
config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
14551457
config.GkeHubBasePath = d.Get(GkeHubFeatureCustomEndpointEntryKey).(string)
1458+
config.NetworkConnectivityBasePath = d.Get(NetworkConnectivityEndpointEntryKey).(string)
14561459
config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
14571460
config.PrivatecaBasePath = d.Get(PrivatecaCertificateTemplateEndpointEntryKey).(string)
14581461
config.ContainerAwsBasePath = d.Get(ContainerAwsCustomEndpointEntryKey).(string)

google/provider_dcl_client_creation.go

+24
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
containerazure "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/containerazure"
2828
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc"
2929
eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc"
30+
networkconnectivity "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/networkconnectivity"
3031
orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy"
3132
osconfig "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/osconfig"
3233
privateca "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/privateca"
@@ -217,6 +218,29 @@ func NewDCLEventarcClient(config *Config, userAgent, billingProject string, time
217218
return eventarc.NewClient(dclConfig)
218219
}
219220

221+
func NewDCLNetworkConnectivityClient(config *Config, userAgent, billingProject string, timeout time.Duration) *networkconnectivity.Client {
222+
configOptions := []dcl.ConfigOption{
223+
dcl.WithHTTPClient(config.client),
224+
dcl.WithUserAgent(userAgent),
225+
dcl.WithLogger(dclLogger{}),
226+
dcl.WithBasePath(config.NetworkConnectivityBasePath),
227+
}
228+
229+
if timeout != 0 {
230+
configOptions = append(configOptions, dcl.WithTimeout(timeout))
231+
}
232+
233+
if config.UserProjectOverride {
234+
configOptions = append(configOptions, dcl.WithUserProjectOverride())
235+
if billingProject != "" {
236+
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
237+
}
238+
}
239+
240+
dclConfig := dcl.NewConfig(configOptions...)
241+
return networkconnectivity.NewClient(dclConfig)
242+
}
243+
220244
func NewDCLOrgPolicyClient(config *Config, userAgent, billingProject string, timeout time.Duration) *orgpolicy.Client {
221245
configOptions := []dcl.ConfigOption{
222246
dcl.WithHTTPClient(config.client),

google/provider_dcl_endpoints.go

+12
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,15 @@ var EventarcEndpointEntry = &schema.Schema{
8585
}, ""),
8686
}
8787

88+
var NetworkConnectivityEndpointEntryKey = "network_connectivity_custom_endpoint"
89+
var NetworkConnectivityEndpointEntry = &schema.Schema{
90+
Type: schema.TypeString,
91+
Optional: true,
92+
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
93+
"GOOGLE_NETWORK_CONNECTIVITY_CUSTOM_ENDPOINT",
94+
}, ""),
95+
}
96+
8897
var OrgPolicyEndpointEntryKey = "org_policy_custom_endpoint"
8998
var OrgPolicyEndpointEntry = &schema.Schema{
9099
Type: schema.TypeString,
@@ -129,6 +138,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
129138
//ContainerAwsBasePath string
130139
//ContainerAzureBasePath string
131140
//EventarcBasePath string
141+
//NetworkConnectivityBasePath string
132142
//OrgPolicyBasePath string
133143
//OSConfigBasePath string
134144
//PrivatecaBasePath string
@@ -142,6 +152,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
142152
// ContainerAwsEndpointEntryKey: ContainerAwsEndpointEntry,
143153
// ContainerAzureEndpointEntryKey: ContainerAzureEndpointEntry,
144154
// EventarcEndpointEntryKey: EventarcEndpointEntry,
155+
// NetworkConnectivityEndpointEntryKey: NetworkConnectivityEndpointEntry,
145156
// OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
146157
// OSConfigEndpointEntryKey: OSConfigEndpointEntry,
147158
// PrivatecaEndpointEntryKey: PrivatecaEndpointEntry,
@@ -155,6 +166,7 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
155166
// config.ContainerAwsBasePath = d.Get(ContainerAwsEndpointEntryKey).(string)
156167
// config.ContainerAzureBasePath = d.Get(ContainerAzureEndpointEntryKey).(string)
157168
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
169+
// config.NetworkConnectivityBasePath = d.Get(NetworkConnectivityEndpointEntryKey).(string)
158170
// config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
159171
// config.OSConfigBasePath = d.Get(OSConfigEndpointEntryKey).(string)
160172
// config.PrivatecaBasePath = d.Get(PrivatecaEndpointEntryKey).(string)

0 commit comments

Comments
 (0)