-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move to handwritten samples, add data source for versions and permiss…
…ible regions.
- Loading branch information
1 parent
ea932c6
commit 2e552e9
Showing
51 changed files
with
1,068 additions
and
1,068 deletions.
There are no files selected for viewing
74 changes: 74 additions & 0 deletions
74
mmv1/third_party/terraform/data_sources/data_source_google_container_aws_versions.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
74 changes: 74 additions & 0 deletions
74
mmv1/third_party/terraform/data_sources/data_source_google_container_azure_versions.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
46 changes: 0 additions & 46 deletions
46
tpgtools/api/containeraws/samples/basic_aws_node_pool.yaml
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.