Skip to content

Commit

Permalink
Move to handwritten samples, add data source for versions and permiss…
Browse files Browse the repository at this point in the history
…ible regions.
  • Loading branch information
nat-henderson committed Dec 10, 2021
1 parent ea932c6 commit 2e552e9
Show file tree
Hide file tree
Showing 51 changed files with 1,068 additions and 1,068 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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
}
d.Set("supported_regions", res["supportedAwsRegions"])
var validVersions []string
for _, v := range res["validVersions"].([]interface{}) {
vm := v.(map[string]interface{})
validVersions = append(validVersions, vm["version"].(string))
}
d.Set("valid_versions", validVersions)

d.SetId(time.Now().UTC().String())
return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
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
}
d.Set("supported_regions", res["supportedAzureRegions"])
var validVersions []string
for _, v := range res["validVersions"].([]interface{}) {
vm := v.(map[string]interface{})
validVersions = append(validVersions, vm["version"].(string))
}
d.Set("valid_versions", validVersions)

d.SetId(time.Now().UTC().String())
return nil
}
2 changes: 1 addition & 1 deletion mmv1/third_party/terraform/go.mod.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/hashicorp/terraform-provider-google<%= "-" + version unless ve

require (
cloud.google.com/go/bigtable v1.10.1
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211203235203-8447c7fb5d37
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211209025336-809317629d25
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
2 changes: 2 additions & 0 deletions mmv1/third_party/terraform/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1455,3 +1455,5 @@ 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-20211209025336-809317629d25 h1:ZtvhfSquCMVsEbbHW2cCmnvmvmmBzo2z8xdqWgZu10k=
github.com/GoogleCloudPlatform/declarative-resource-client-library v0.0.0-20211209025336-809317629d25/go.mod h1:oEeBHikdF/NrnUy0ornVaY1OT+jGvTqm+LQS0+ZDKzU=
2 changes: 2 additions & 0 deletions mmv1/third_party/terraform/utils/provider.go.erb
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,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
65 changes: 0 additions & 65 deletions tpgtools/api/containeraws/samples/basic.cluster.json

This file was deleted.

48 changes: 0 additions & 48 deletions tpgtools/api/containeraws/samples/basic.node_pool.json

This file was deleted.

42 changes: 0 additions & 42 deletions tpgtools/api/containeraws/samples/basic_aws_cluster.yaml

This file was deleted.

46 changes: 0 additions & 46 deletions tpgtools/api/containeraws/samples/basic_aws_node_pool.yaml

This file was deleted.

Loading

0 comments on commit 2e552e9

Please sign in to comment.