Add locations

This commit is contained in:
stSolo
2022-07-07 18:46:39 +03:00
parent e4be812c68
commit 48cada2cf3
77 changed files with 520 additions and 44 deletions

View File

@@ -25,6 +25,8 @@ import (
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/bservice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/disks"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/extnet"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/kvmvm"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/locations"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/rg"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/vgpu"
@@ -37,9 +39,9 @@ import (
func NewDataSourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_account": account.DataSourceAccount(),
"decort_resgroup": rg.DataSourceResgroup(),
// "decort_kvmvm": dataSourceCompute(),
"decort_account": account.DataSourceAccount(),
"decort_resgroup": rg.DataSourceResgroup(),
"decort_kvmvm": kvmvm.DataSourceCompute(),
"decort_image": image.DataSourceImage(),
"decort_disk": disks.DataSourceDisk(),
"decort_vins": vins.DataSourceVins(),
@@ -81,6 +83,8 @@ func NewDataSourcesMap() map[string]*schema.Resource {
"decort_extnet": extnet.DataSourceExtnet(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_vins_list": vins.DataSourceVinsList(),
"decort_locations_list": locations.DataSourceLocationsList(),
"decort_location_url": locations.DataSourceLocationUrl(),
// "decort_pfw": dataSourcePfw(),
}

View File

@@ -21,7 +21,6 @@ package provider
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
@@ -29,6 +28,7 @@ import (
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/location"
"github.com/rudecs/terraform-provider-decort/internal/statefuncs"
)
func Provider() *schema.Provider {
@@ -37,7 +37,7 @@ func Provider() *schema.Provider {
"authenticator": {
Type: schema.TypeString,
Required: true,
StateFunc: StateFuncToLower,
StateFunc: statefuncs.StateFuncToLower,
ValidateFunc: validation.StringInSlice([]string{"oauth2", "legacy", "jwt"}, true), // ignore case while validating
Description: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'oauth2', 'legacy' or 'jwt'.",
},
@@ -45,7 +45,7 @@ func Provider() *schema.Provider {
"oauth2_url": {
Type: schema.TypeString,
Optional: true,
StateFunc: StateFuncToLower,
StateFunc: statefuncs.StateFuncToLower,
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
Description: "OAuth2 application URL in 'oauth2' authentication mode.",
},
@@ -54,7 +54,7 @@ func Provider() *schema.Provider {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: StateFuncToLower,
StateFunc: statefuncs.StateFuncToLower,
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
},
@@ -109,14 +109,6 @@ func Provider() *schema.Provider {
}
}
func StateFuncToLower(argval interface{}) string {
return strings.ToLower(argval.(string))
}
func StateFuncToUpper(argval interface{}) string {
return strings.ToUpper(argval.(string))
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
decsController, err := controller.ControllerConfigure(d)
if err != nil {