1.0.1
This commit is contained in:
@@ -15,8 +15,14 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/stack"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vfpool"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vins"
|
||||
cbaccount "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/account"
|
||||
cbAccount "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/account"
|
||||
cbAudit "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/audit"
|
||||
cbLb "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/lb"
|
||||
cbNode "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/node"
|
||||
cbRG "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/rg"
|
||||
cbStack "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/stack"
|
||||
cbVFpool "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/vfpool"
|
||||
cbVins "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/vins"
|
||||
)
|
||||
|
||||
func newDataSourcesMap() []func() datasource.DataSource {
|
||||
@@ -111,6 +117,9 @@ func newDataSourcesMap() []func() datasource.DataSource {
|
||||
vfpool.NewDataSourceVFPool,
|
||||
vfpool.NewDataSourceVFPoolList,
|
||||
|
||||
cbVFpool.NewDataSourceVFPool,
|
||||
cbVFpool.NewDataSourceVFPoolList,
|
||||
|
||||
vins.NewDataSourceVINS,
|
||||
vins.NewDataSourceVINSAudits,
|
||||
vins.NewDataSourceVINSExtNetList,
|
||||
@@ -121,11 +130,56 @@ func newDataSourcesMap() []func() datasource.DataSource {
|
||||
vins.NewDataSourceVINSStaticRoute,
|
||||
vins.NewDataSourceVINSStaticRouteList,
|
||||
|
||||
cbaccount.NewDataSourceAccount,
|
||||
cbaccount.NewDataSourceAccountList,
|
||||
cbaccount.NewDataSourceAccountVinsList,
|
||||
cbAccount.NewDataSourceAccount,
|
||||
cbAccount.NewDataSourceAccountList,
|
||||
cbAccount.NewDataSourceAccountVinsList,
|
||||
cbAccount.NewDataSourceAccountAuditsList,
|
||||
cbAccount.NewDataSourceAccountAvailableTemplatesListDataSource,
|
||||
cbAccount.NewDataSourceAccountComputesList,
|
||||
cbAccount.NewDataSourceAccountDisksList,
|
||||
cbAccount.NewDataSourceAccountFlipgroupsList,
|
||||
cbAccount.NewDataSourceAccountGetResourceConsumption,
|
||||
cbAccount.NewDataSourceAccountListDeleted,
|
||||
cbAccount.NewDataSourceAccountGetResourceConsumptionList,
|
||||
cbAccount.NewDataSourceAccountRGList,
|
||||
|
||||
cbAudit.NewDataSourceAudit,
|
||||
cbAudit.NewDataSourceAuditLinkedJobs,
|
||||
cbAudit.NewDataSourceAuditList,
|
||||
|
||||
cbNode.NewDataSourceNode,
|
||||
cbNode.NewDataSourceNodeList,
|
||||
|
||||
cbLb.NewDataSourceLB,
|
||||
cbLb.NewDataSourceLBList,
|
||||
cbLb.NewDataSourceLBListDeleted,
|
||||
|
||||
cbStack.NewDataSourceStack,
|
||||
cbStack.NewDataSourceStackList,
|
||||
|
||||
cbVins.NewDataSourceVINS,
|
||||
cbVins.NewDataSourceVINSAudits,
|
||||
cbVins.NewDataSourceVINSExtNetList,
|
||||
cbVins.NewDataSourceVINSIPList,
|
||||
cbVins.NewDataSourceVINSList,
|
||||
cbVins.NewDataSourceVINSListDeleted,
|
||||
cbVins.NewDataSourceVINSNATRuleList,
|
||||
cbVins.NewDataSourceVINSStaticRoute,
|
||||
cbVins.NewDataSourceVINSStaticRouteList,
|
||||
|
||||
cbRG.NewDataSourceRG,
|
||||
cbRG.NewDataSourceRGList,
|
||||
cbRG.NewDataSourceRGListDeleted,
|
||||
cbRG.NewDataSourceRGAffinityGroupComputes,
|
||||
cbRG.NewDataSourceRGAffinityGroupsGet,
|
||||
cbRG.NewDataSourceRGAffinityGroupsList,
|
||||
cbRG.NewDataSourceRGAudits,
|
||||
cbRG.NewDataSourceRGGetResourceConsumption,
|
||||
cbRG.NewDataSourceRGResourceConsumptionList,
|
||||
cbRG.NewDataSourceRGUsage,
|
||||
cbRG.NewDataSourceRGListComputes,
|
||||
cbRG.NewDataSourceRGListLB,
|
||||
cbRG.NewDataSourceRGListPFW,
|
||||
cbRG.NewDataSourceRGListVins,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ func (p *DynamixProvider) Schema(_ context.Context, _ provider.SchemaRequest, re
|
||||
resp.Schema = schema.Schema{
|
||||
Attributes: map[string]schema.Attribute{
|
||||
"authenticator": schema.StringAttribute{
|
||||
MarkdownDescription: "Authentication mode to use when connecting to DECORT cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
||||
MarkdownDescription: "Authentication mode to use when connecting to DYNAMIX cloud API. Should be one of 'decs3o', 'legacy', 'jwt' or 'bvs'.",
|
||||
Required: true,
|
||||
Validators: []validator.String{
|
||||
stringvalidator.OneOfCaseInsensitive("decs3o", "legacy", "jwt", "bvs"), // ignore case while validating
|
||||
@@ -76,43 +76,43 @@ func (p *DynamixProvider) Schema(_ context.Context, _ provider.SchemaRequest, re
|
||||
Optional: true,
|
||||
},
|
||||
"controller_url": schema.StringAttribute{
|
||||
MarkdownDescription: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
|
||||
MarkdownDescription: "URL of DYNAMIX Cloud controller to use. API calls will be directed to this URL.",
|
||||
Required: true,
|
||||
},
|
||||
"user": schema.StringAttribute{
|
||||
MarkdownDescription: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||
MarkdownDescription: "User name for DYNAMIX cloud API operations in 'legacy' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"password": schema.StringAttribute{
|
||||
MarkdownDescription: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
|
||||
MarkdownDescription: "User password for DYNAMIX cloud API operations in 'legacy' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"bvs_user": schema.StringAttribute{
|
||||
MarkdownDescription: "User name for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||
MarkdownDescription: "User name for DYNAMIX cloud API operations in 'bvs' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"bvs_password": schema.StringAttribute{
|
||||
MarkdownDescription: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||
MarkdownDescription: "User password for DYNAMIX cloud API operations in 'bvs' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"domain": schema.StringAttribute{
|
||||
MarkdownDescription: "User password for DECORT cloud API operations in 'bvs' authentication mode.",
|
||||
MarkdownDescription: "User password for DYNAMIX cloud API operations in 'bvs' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"app_id": schema.StringAttribute{
|
||||
MarkdownDescription: "Application ID to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||
MarkdownDescription: "Application ID to access DYNAMIX cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"app_secret": schema.StringAttribute{
|
||||
MarkdownDescription: "Application secret to access DECORT cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||
MarkdownDescription: "Application secret to access DYNAMIX cloud API in 'decs3o' and 'bvs' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"jwt": schema.StringAttribute{
|
||||
MarkdownDescription: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
|
||||
MarkdownDescription: "JWT to access DYNAMIX cloud API in 'jwt' authentication mode.",
|
||||
Optional: true,
|
||||
},
|
||||
"allow_unverified_ssl": schema.BoolAttribute{
|
||||
MarkdownDescription: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only! Default is false.",
|
||||
MarkdownDescription: "If true, DYNAMIX API will not verify SSL certificates. Use this with caution and in trusted environments only! Default is false.",
|
||||
Optional: true,
|
||||
},
|
||||
"path_config": schema.StringAttribute{
|
||||
@@ -137,7 +137,8 @@ func (p *DynamixProvider) Configure(ctx context.Context, req provider.ConfigureR
|
||||
diags := req.Config.Get(ctx, &config)
|
||||
resp.Diagnostics.Append(diags...)
|
||||
if resp.Diagnostics.HasError() {
|
||||
log.Debugf("Provider Configure error after req.Config.Get")
|
||||
resp.Diagnostics.AddError("Provider Configure: ", "error after req.Config.Get")
|
||||
log.Error("Provider Configure error after req.Config.Get")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -148,7 +149,8 @@ func (p *DynamixProvider) Configure(ctx context.Context, req provider.ConfigureR
|
||||
// Validate and set up authentication mode
|
||||
mode, err := dynamixConfig.validateAuthenticator()
|
||||
if err != nil {
|
||||
log.Debug(err)
|
||||
log.Error(err)
|
||||
resp.Diagnostics.AddError("Provider Configure: validate error:", err.Error())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
sdk_config "repository.basistech.ru/BASIS/decort-golang-sdk/config"
|
||||
)
|
||||
|
||||
@@ -38,82 +37,82 @@ type dynamixProviderConfig struct {
|
||||
func (d *dynamixProviderConfig) new(config dynamixProviderModel) {
|
||||
d.authenticator = strings.ToLower(config.Authenticator.ValueString())
|
||||
|
||||
if config.Oauth2Url.IsUnknown() {
|
||||
d.oauth2Url = os.Getenv("DECORT_OAUTH2_URL")
|
||||
if config.Oauth2Url.IsNull() {
|
||||
d.oauth2Url = os.Getenv("DYNAMIX_OAUTH2_URL")
|
||||
} else {
|
||||
d.oauth2Url = config.Oauth2Url.ValueString()
|
||||
}
|
||||
d.oauth2Url = strings.ToLower(d.oauth2Url)
|
||||
|
||||
d.controllerUrl = strings.ToLower(config.ControllerUrl.ValueString())
|
||||
if d.controllerUrl == "" {
|
||||
log.Debugf("empty DECORT cloud controller URL provided")
|
||||
return
|
||||
if config.ControllerUrl.IsNull() {
|
||||
d.controllerUrl = os.Getenv("DYNAMIX_CONTROLLER_URL")
|
||||
} else {
|
||||
d.controllerUrl = strings.ToLower(config.ControllerUrl.ValueString())
|
||||
}
|
||||
|
||||
if config.User.IsUnknown() {
|
||||
d.user = os.Getenv("DECORT_USER")
|
||||
if config.User.IsNull() {
|
||||
d.user = os.Getenv("DYNAMIX_USER")
|
||||
} else {
|
||||
d.user = config.User.ValueString()
|
||||
}
|
||||
|
||||
if config.Password.IsUnknown() {
|
||||
d.password = os.Getenv("DECORT_PASSWORD")
|
||||
if config.Password.IsNull() {
|
||||
d.password = os.Getenv("DYNAMIX_PASSWORD")
|
||||
} else {
|
||||
d.password = config.Password.ValueString()
|
||||
}
|
||||
|
||||
if config.BvsUser.IsUnknown() {
|
||||
d.bvsUser = os.Getenv("DECORT_BVS_USER")
|
||||
if config.BvsUser.IsNull() {
|
||||
d.bvsUser = os.Getenv("DYNAMIX_BVS_USER")
|
||||
} else {
|
||||
d.bvsUser = config.BvsUser.ValueString()
|
||||
}
|
||||
|
||||
if config.BvsPassword.IsUnknown() {
|
||||
d.bvsPassword = os.Getenv("DECORT_BVS_PASSWORD")
|
||||
if config.BvsPassword.IsNull() {
|
||||
d.bvsPassword = os.Getenv("DYNAMIX_BVS_PASSWORD")
|
||||
} else {
|
||||
d.bvsPassword = config.BvsPassword.ValueString()
|
||||
}
|
||||
|
||||
if config.Domain.IsUnknown() {
|
||||
d.domain = os.Getenv("DECORT_DOMAIN")
|
||||
if config.Domain.IsNull() {
|
||||
d.domain = os.Getenv("DYNAMIX_DOMAIN")
|
||||
} else {
|
||||
d.domain = config.Domain.ValueString()
|
||||
}
|
||||
|
||||
if config.AppId.IsUnknown() {
|
||||
d.appId = os.Getenv("DECORT_APP_ID")
|
||||
if config.AppId.IsNull() {
|
||||
d.appId = os.Getenv("DYNAMIX_APP_ID")
|
||||
} else {
|
||||
d.appId = config.AppId.ValueString()
|
||||
}
|
||||
|
||||
if config.AppSecret.IsUnknown() {
|
||||
d.appSecret = os.Getenv("DECORT_APP_SECRET")
|
||||
if config.AppSecret.IsNull() {
|
||||
d.appSecret = os.Getenv("DYNAMIX_APP_SECRET")
|
||||
} else {
|
||||
d.appSecret = config.AppSecret.ValueString()
|
||||
}
|
||||
|
||||
if config.Jwt.IsUnknown() {
|
||||
d.jwt = os.Getenv("DECORT_JWT")
|
||||
if config.Jwt.IsNull() {
|
||||
d.jwt = os.Getenv("DYNAMIX_JWT")
|
||||
} else {
|
||||
d.jwt = config.Jwt.ValueString()
|
||||
}
|
||||
|
||||
if config.AllowUnverifiedSsl.IsUnknown() {
|
||||
if config.AllowUnverifiedSsl.IsNull() {
|
||||
d.allowUnverifiedSsl = false // default false
|
||||
} else {
|
||||
d.allowUnverifiedSsl = config.AllowUnverifiedSsl.ValueBool()
|
||||
}
|
||||
|
||||
if !config.PathConfig.IsUnknown() {
|
||||
if !config.PathConfig.IsNull() {
|
||||
d.pathConfig = config.PathConfig.ValueString()
|
||||
}
|
||||
|
||||
if !config.PathToken.IsUnknown() {
|
||||
if !config.PathToken.IsNull() {
|
||||
d.pathToken = config.PathToken.ValueString()
|
||||
}
|
||||
|
||||
if !config.TimeToRefresh.IsUnknown() {
|
||||
if !config.TimeToRefresh.IsNull() {
|
||||
d.timeToRefresh = config.TimeToRefresh.ValueInt64()
|
||||
}
|
||||
|
||||
@@ -125,6 +124,12 @@ func (d *dynamixProviderConfig) new(config dynamixProviderModel) {
|
||||
// reason, the method will return mode = MODE_UNDEF and error.
|
||||
func (d *dynamixProviderConfig) validateAuthenticator() (int, error) {
|
||||
var mode = MODE_UNDEF
|
||||
if d.oauth2Url == "" {
|
||||
return mode, fmt.Errorf("OAuth2 URL is required")
|
||||
}
|
||||
if d.controllerUrl == "" {
|
||||
return mode, fmt.Errorf("controllerURL is required")
|
||||
}
|
||||
switch d.authenticator {
|
||||
case "jwt":
|
||||
if d.jwt == "" {
|
||||
@@ -132,9 +137,6 @@ func (d *dynamixProviderConfig) validateAuthenticator() (int, error) {
|
||||
}
|
||||
mode = MODE_JWT
|
||||
case "decs3o":
|
||||
if d.oauth2Url == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'decs3o' specified but no OAuth2 URL provided")
|
||||
}
|
||||
if d.appId == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'decs3o' specified but no Application ID provided")
|
||||
}
|
||||
@@ -149,6 +151,12 @@ func (d *dynamixProviderConfig) validateAuthenticator() (int, error) {
|
||||
if d.password == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'legacy' specified but no password provided")
|
||||
}
|
||||
if d.appId == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'legacy' specified but no Application ID provided")
|
||||
}
|
||||
if d.appSecret == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'legacy' specified but no Secret ID provided")
|
||||
}
|
||||
mode = MODE_LEGACY
|
||||
case "bvs":
|
||||
if d.bvsUser == "" {
|
||||
@@ -157,9 +165,6 @@ func (d *dynamixProviderConfig) validateAuthenticator() (int, error) {
|
||||
if d.bvsPassword == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'bvs' specified but no bvs password provided")
|
||||
}
|
||||
if d.oauth2Url == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'bvs' specified but no bvs URL provided")
|
||||
}
|
||||
if d.appId == "" {
|
||||
return mode, fmt.Errorf("authenticator mode 'bvs' specified but no Application ID provided")
|
||||
}
|
||||
|
||||
@@ -12,6 +12,10 @@ import (
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/lb"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/rg"
|
||||
"repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudapi/vins"
|
||||
cbLb "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/lb"
|
||||
cbAccount "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/account"
|
||||
cbVFpool "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/vfpool"
|
||||
cbVins "repository.basistech.ru/BASIS/terraform-provider-dynamix/internal/service/cloudbroker/vins"
|
||||
)
|
||||
|
||||
func newResourcesMap() []func() resource.Resource {
|
||||
@@ -36,5 +40,16 @@ func newResourcesMap() []func() resource.Resource {
|
||||
vins.NewResourceVINSStaticRoute,
|
||||
bservice.NewResourceBService,
|
||||
bservice.NewResourceBServiceGroup,
|
||||
|
||||
cbAccount.NewResourceAccount,
|
||||
|
||||
cbLb.NewResourceLB,
|
||||
cbLb.NewResourceLBBackend,
|
||||
cbLb.NewResourceLBBackendServer,
|
||||
cbLb.NewResourceLBFrontend,
|
||||
cbLb.NewResourceLBFrontendBind,
|
||||
cbVFpool.NewResourceVFPool,
|
||||
cbVins.NewResourceVINS,
|
||||
cbVins.NewResourceVINSStaticRoute,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user