Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GKE Multicloud #10754

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .changelog/5522.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
```release-note:new-resource
google_container_azure_client
```
```release-note:new-resource
google_container_azure_cluster
```
```release-note:new-resource
google_container_azure_node_pool
```
```release-note:new-resource
google_container_aws_cluster
```
```release-note:new-resource
google_container_aws_node_pool
```
```release-note:new-datasource
google_container_aws_versions
```
```release-note:new-datasource
google_container_azure_versions
```
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module github.com/hashicorp/terraform-provider-google
require (
cloud.google.com/go/bigtable v1.10.1
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211215020606-79616333f950
github.com/apparentlymart/go-cidr v1.1.0
github.com/client9/misspell v0.3.4
github.com/davecgh/go-spew v1.1.1
Expand Down
18 changes: 18 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1457,3 +1457,21 @@ rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8
rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636 h1:91BjCMjMOZc+qBIkXxj2RU0dznJx/ySUL1HBJ5i+YRs=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211214175538-23aaa3b3a636/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211215020606-79616333f950 h1:pJAaEIUF6dSY6hRyiHpSlSHgvyaCv478IUVZR6t2OIU=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211215020606-79616333f950/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
8 changes: 7 additions & 1 deletion google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,8 @@ type Config struct {
CloudResourceManagerBasePath string
EventarcBasePath string
GkeHubBasePath string
ContainerAzureBasePath string
ContainerAwsBasePath string
OrgPolicyBasePath string
RecaptchaEnterpriseBasePath string
// CloudBuild WorkerPool uses a different endpoint (v1beta1) than any other CloudBuild resources
Expand Down Expand Up @@ -328,7 +330,9 @@ const ResourceManagerV2BasePathKey = "ResourceManagerV2"
const ServiceNetworkingBasePathKey = "ServiceNetworking"
const StorageTransferBasePathKey = "StorageTransfer"
const BigtableAdminBasePathKey = "BigtableAdmin"
const GkeHubFeatureBasePathKey = "GkeHubFeatureBasePathKey"
const GkeHubFeatureBasePathKey = "GkeHubFeature"
const ContainerAwsBasePathKey = "ContainerAws"
const ContainerAzureBasePathKey = "ContainerAzure"

// Generated product base paths
var DefaultBasePaths = map[string]string{
Expand Down Expand Up @@ -408,6 +412,8 @@ var DefaultBasePaths = map[string]string{
StorageTransferBasePathKey: "https://storagetransfer.googleapis.com/v1/",
BigtableAdminBasePathKey: "https://bigtableadmin.googleapis.com/v2/",
GkeHubFeatureBasePathKey: "https://gkehub.googleapis.com/v1beta/",
ContainerAwsBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/",
ContainerAzureBasePathKey: "https://{{location}}-gkemulticloud.googleapis.com/v1/",
}

var DefaultClientScopes = []string{
Expand Down
78 changes: 78 additions & 0 deletions google/data_source_google_container_aws_versions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package google

import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGoogleContainerAwsVersions() *schema.Resource {
return &schema.Resource{
Read: dataSourceGoogleContainerAwsVersionsRead,
Schema: map[string]*schema.Schema{
"project": {
Type: schema.TypeString,
Optional: true,
},
"location": {
Type: schema.TypeString,
Optional: true,
},
"valid_versions": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"supported_regions": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}

func dataSourceGoogleContainerAwsVersionsRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
userAgent, err := generateUserAgentString(d, config.userAgent)
if err != nil {
return err
}

project, err := getProject(d, config)
if err != nil {
return err
}

location, err := getLocation(d, config)
if err != nil {
return err
}
if len(location) == 0 {
return fmt.Errorf("Cannot determine location: set location in this data source or at provider-level")
}

url, err := replaceVars(d, config, "{{ContainerAwsBasePath}}projects/{{project}}/locations/{{location}}/awsServerConfig")
if err != nil {
return err
}
res, err := sendRequest(config, "GET", project, url, userAgent, nil)
if err != nil {
return err
}
if err := d.Set("supported_regions", res["supportedAwsRegions"]); err != nil {
return err
}
var validVersions []string
for _, v := range res["validVersions"].([]interface{}) {
vm := v.(map[string]interface{})
validVersions = append(validVersions, vm["version"].(string))
}
if err := d.Set("valid_versions", validVersions); err != nil {
return err
}

d.SetId(time.Now().UTC().String())
return nil
}
78 changes: 78 additions & 0 deletions google/data_source_google_container_azure_versions.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package google

import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
)

func dataSourceGoogleContainerAzureVersions() *schema.Resource {
return &schema.Resource{
Read: dataSourceGoogleContainerAzureVersionsRead,
Schema: map[string]*schema.Schema{
"project": {
Type: schema.TypeString,
Optional: true,
},
"location": {
Type: schema.TypeString,
Optional: true,
},
"valid_versions": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
"supported_regions": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{Type: schema.TypeString},
},
},
}
}

func dataSourceGoogleContainerAzureVersionsRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)
userAgent, err := generateUserAgentString(d, config.userAgent)
if err != nil {
return err
}

project, err := getProject(d, config)
if err != nil {
return err
}

location, err := getLocation(d, config)
if err != nil {
return err
}
if len(location) == 0 {
return fmt.Errorf("Cannot determine location: set location in this data source or at provider-level")
}

url, err := replaceVars(d, config, "{{ContainerAzureBasePath}}projects/{{project}}/locations/{{location}}/azureServerConfig")
if err != nil {
return err
}
res, err := sendRequest(config, "GET", project, url, userAgent, nil)
if err != nil {
return err
}
if err := d.Set("supported_regions", res["supportedAzureRegions"]); err != nil {
return err
}
var validVersions []string
for _, v := range res["validVersions"].([]interface{}) {
vm := v.(map[string]interface{})
validVersions = append(validVersions, vm["version"].(string))
}
if err := d.Set("valid_versions", validVersions); err != nil {
return err
}

d.SetId(time.Now().UTC().String())
return nil
}
11 changes: 11 additions & 0 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,8 @@ func Provider() *schema.Provider {
OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
PrivatecaCertificateTemplateEndpointEntryKey: PrivatecaCertificateTemplateCustomEndpointEntry,
RecaptchaEnterpriseEndpointEntryKey: RecaptchaEnterpriseEndpointEntry,
ContainerAwsCustomEndpointEntryKey: ContainerAwsCustomEndpointEntry,
ContainerAzureCustomEndpointEntryKey: ContainerAzureCustomEndpointEntry,

CloudBuildWorkerPoolEndpointEntryKey: CloudBuildWorkerPoolEndpointEntry,
},
Expand Down Expand Up @@ -745,6 +747,8 @@ func Provider() *schema.Provider {
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
"google_compute_zones": dataSourceGoogleComputeZones(),
"google_container_azure_versions": dataSourceGoogleContainerAzureVersions(),
"google_container_aws_versions": dataSourceGoogleContainerAwsVersions(),
"google_container_cluster": dataSourceGoogleContainerCluster(),
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
"google_container_registry_image": dataSourceGoogleContainerImage(),
Expand Down Expand Up @@ -1212,6 +1216,11 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_os_config_os_policy_assignment": resourceOSConfigOSPolicyAssignment(),
"google_privateca_certificate_template": resourcePrivatecaCertificateTemplate(),
"google_recaptcha_enterprise_key": resourceRecaptchaEnterpriseKey(),
"google_container_aws_cluster": resourceContainerAwsCluster(),
"google_container_aws_node_pool": resourceContainerAwsNodePool(),
"google_container_azure_client": resourceContainerAzureClient(),
"google_container_azure_cluster": resourceContainerAzureCluster(),
"google_container_azure_node_pool": resourceContainerAzureNodePool(),
},
// ------------------------------------
map[string]*schema.Resource{
Expand Down Expand Up @@ -1446,6 +1455,8 @@ func providerConfigure(ctx context.Context, d *schema.ResourceData, p *schema.Pr
config.GkeHubBasePath = d.Get(GkeHubFeatureCustomEndpointEntryKey).(string)
config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
config.PrivatecaBasePath = d.Get(PrivatecaCertificateTemplateEndpointEntryKey).(string)
config.ContainerAwsBasePath = d.Get(ContainerAwsCustomEndpointEntryKey).(string)
config.ContainerAzureBasePath = d.Get(ContainerAzureCustomEndpointEntryKey).(string)
config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)

stopCtx, ok := schema.StopContext(ctx)
Expand Down
48 changes: 48 additions & 0 deletions google/provider_dcl_client_creation.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import (
cloudbuild "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudbuild"
cloudresourcemanager "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/cloudresourcemanager"
compute "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/compute"
containeraws "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/containeraws"
containerazure "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/containerazure"
dataproc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/dataproc"
eventarc "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/eventarc"
orgpolicy "github.com/GoogleCloudPlatform/declarative-resource-client-library/services/google/orgpolicy"
Expand Down Expand Up @@ -123,6 +125,52 @@ func NewDCLComputeClient(config *Config, userAgent, billingProject string, timeo
return compute.NewClient(dclConfig)
}

func NewDCLContainerAwsClient(config *Config, userAgent, billingProject string, timeout time.Duration) *containeraws.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
dcl.WithUserAgent(userAgent),
dcl.WithLogger(dclLogger{}),
dcl.WithBasePath(config.ContainerAwsBasePath),
}

if timeout != 0 {
configOptions = append(configOptions, dcl.WithTimeout(timeout))
}

if config.UserProjectOverride {
configOptions = append(configOptions, dcl.WithUserProjectOverride())
if billingProject != "" {
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
}
}

dclConfig := dcl.NewConfig(configOptions...)
return containeraws.NewClient(dclConfig)
}

func NewDCLContainerAzureClient(config *Config, userAgent, billingProject string, timeout time.Duration) *containerazure.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
dcl.WithUserAgent(userAgent),
dcl.WithLogger(dclLogger{}),
dcl.WithBasePath(config.ContainerAzureBasePath),
}

if timeout != 0 {
configOptions = append(configOptions, dcl.WithTimeout(timeout))
}

if config.UserProjectOverride {
configOptions = append(configOptions, dcl.WithUserProjectOverride())
if billingProject != "" {
configOptions = append(configOptions, dcl.WithBillingProject(billingProject))
}
}

dclConfig := dcl.NewConfig(configOptions...)
return containerazure.NewClient(dclConfig)
}

func NewDCLDataprocClient(config *Config, userAgent, billingProject string, timeout time.Duration) *dataproc.Client {
configOptions := []dcl.ConfigOption{
dcl.WithHTTPClient(config.client),
Expand Down
24 changes: 24 additions & 0 deletions google/provider_dcl_endpoints.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,24 @@ var ComputeEndpointEntry = &schema.Schema{
}, ""),
}

var ContainerAwsEndpointEntryKey = "container_aws_custom_endpoint"
var ContainerAwsEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CONTAINER_AWS_CUSTOM_ENDPOINT",
}, ""),
}

var ContainerAzureEndpointEntryKey = "container_azure_custom_endpoint"
var ContainerAzureEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_CONTAINER_AZURE_CUSTOM_ENDPOINT",
}, ""),
}

var EventarcEndpointEntryKey = "eventarc_custom_endpoint"
var EventarcEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Expand Down Expand Up @@ -108,6 +126,8 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
//CloudBuildWorkerPoolBasePath string
//CloudResourceManagerBasePath string
//ComputeBasePath string
//ContainerAwsBasePath string
//ContainerAzureBasePath string
//EventarcBasePath string
//OrgPolicyBasePath string
//OSConfigBasePath string
Expand All @@ -119,6 +139,8 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
// CloudBuildWorkerPoolEndpointEntryKey: CloudBuildWorkerPoolEndpointEntry,
// CloudResourceManagerEndpointEntryKey: CloudResourceManagerEndpointEntry,
// ComputeEndpointEntryKey: ComputeEndpointEntry,
// ContainerAwsEndpointEntryKey: ContainerAwsEndpointEntry,
// ContainerAzureEndpointEntryKey: ContainerAzureEndpointEntry,
// EventarcEndpointEntryKey: EventarcEndpointEntry,
// OrgPolicyEndpointEntryKey: OrgPolicyEndpointEntry,
// OSConfigEndpointEntryKey: OSConfigEndpointEntry,
Expand All @@ -130,6 +152,8 @@ var RecaptchaEnterpriseEndpointEntry = &schema.Schema{
// config.CloudBuildWorkerPoolBasePath = d.Get(CloudBuildWorkerPoolEndpointEntryKey).(string)
// config.CloudResourceManagerBasePath = d.Get(CloudResourceManagerEndpointEntryKey).(string)
// config.ComputeBasePath = d.Get(ComputeEndpointEntryKey).(string)
// config.ContainerAwsBasePath = d.Get(ContainerAwsEndpointEntryKey).(string)
// config.ContainerAzureBasePath = d.Get(ContainerAzureEndpointEntryKey).(string)
// config.EventarcBasePath = d.Get(EventarcEndpointEntryKey).(string)
// config.OrgPolicyBasePath = d.Get(OrgPolicyEndpointEntryKey).(string)
// config.OSConfigBasePath = d.Get(OSConfigEndpointEntryKey).(string)
Expand Down
Loading