Migrate to sdkv2 and project structure refactoring

gos_tech_4.4.3
stSolo 3 years ago
parent 3c2eb0407c
commit 3613bbea28

1
.gitignore vendored

@ -2,3 +2,4 @@ decort/vendor/
examples/ examples/
url_scrapping/ url_scrapping/
terraform-provider-decort* terraform-provider-decort*
.vscode/

@ -4,6 +4,7 @@ NAMESPACE=decort
NAME=terraform-provider-decort NAME=terraform-provider-decort
#BINARY=terraform-provider-${NAME} #BINARY=terraform-provider-${NAME}
BINARY=${NAME}.exe BINARY=${NAME}.exe
MAINPATH = ./cmd/decort/
VERSION=0.2 VERSION=0.2
#OS_ARCH=darwin_amd64 #OS_ARCH=darwin_amd64
OS_ARCH=windows_amd64 OS_ARCH=windows_amd64
@ -11,8 +12,7 @@ OS_ARCH=windows_amd64
default: install default: install
build: build:
go build -o ${BINARY} go build -o ${BINARY} ${MAINPATH}
release: release:
GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64 GOOS=darwin GOARCH=amd64 go build -o ./bin/${BINARY}_${VERSION}_darwin_amd64
GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386 GOOS=freebsd GOARCH=386 go build -o ./bin/${BINARY}_${VERSION}_freebsd_386

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -32,10 +34,10 @@ package main
import ( import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/plugin" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/terraform" "github.com/hashicorp/terraform-plugin-sdk/v2/plugin"
"github.com/rudecs/terraform-provider-decort/decort" "github.com/rudecs/terraform-provider-decort/internal/provider"
) )
//go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs //go:generate go run github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
@ -45,8 +47,8 @@ func main() {
log.Debug("Debug logging enabled") log.Debug("Debug logging enabled")
plugin.Serve(&plugin.ServeOpts{ plugin.Serve(&plugin.ServeOpts{
ProviderFunc: func() terraform.ResourceProvider { ProviderFunc: func() *schema.Provider {
return decort.Provider() return provider.Provider()
}, },
}) })
} }

@ -1,58 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceAccountDeletedListRead(d *schema.ResourceData, m interface{}) error {
accountDeletedList, err := utilityAccountDeletedListCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenAccountList(accountDeletedList))
return nil
}
func dataSourceAccountDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceAccountDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceAccountListSchemaMake(),
}
}

@ -1,58 +0,0 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import (
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func dataSourceBasicServiceDeletedListRead(d *schema.ResourceData, m interface{}) error {
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
return nil
}
func dataSourceBasicServiceDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceBasicServiceDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceBasicServiceListSchemaMake(),
}
}

File diff suppressed because it is too large Load Diff

@ -1,196 +0,0 @@
/*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package decort
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation"
// "github.com/hashicorp/terraform-plugin-sdk/terraform"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"authenticator": {
Type: schema.TypeString,
Required: true,
StateFunc: 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'.",
},
"oauth2_url": {
Type: schema.TypeString,
Optional: true,
StateFunc: stateFuncToLower,
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
Description: "OAuth2 application URL in 'oauth2' authentication mode.",
},
"controller_url": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: stateFuncToLower,
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
},
"user": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
},
"password": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
},
"app_id": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.",
},
"app_secret": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.",
},
"jwt": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
},
"allow_unverified_ssl": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
},
},
ResourcesMap: map[string]*schema.Resource{
"decort_resgroup": resourceResgroup(),
"decort_kvmvm": resourceCompute(),
"decort_disk": resourceDisk(),
"decort_vins": resourceVins(),
"decort_pfw": resourcePfw(),
"decort_k8s": resourceK8s(),
"decort_k8s_wg": resourceK8sWg(),
"decort_image": resourceImage(),
"decort_virtual_image": resourceVirtualImage(),
"decort_cdrom_image": resourceCDROMImage(),
"decort_delete_images": resourceDeleteImages(),
"decort_snapshot": resourceSnapshot(),
"decort_pcidevice": resourcePcidevice(),
"decort_sep": resourceSep(),
"decort_sep_config": resourceSepConfig(),
"decort_account": resourceAccount(),
"decort_bservice": resourceBasicService(),
"decort_bservice_group": resourceBasicServiceGroup(),
},
DataSourcesMap: map[string]*schema.Resource{
"decort_account": dataSourceAccount(),
"decort_resgroup": dataSourceResgroup(),
"decort_kvmvm": dataSourceCompute(),
"decort_image": dataSourceImage(),
"decort_disk": dataSourceDisk(),
"decort_vins": dataSourceVins(),
"decort_grid": dataSourceGrid(),
"decort_grid_list": dataSourceGridList(),
"decort_image_list": dataSourceImageList(),
"decort_image_list_stacks": dataSourceImageListStacks(),
"decort_snapshot_list": dataSourceSnapshotList(),
"decort_vgpu": dataSourceVGPU(),
"decort_pcidevice": dataSourcePcidevice(),
"decort_pcidevice_list": dataSourcePcideviceList(),
"decort_sep_list": dataSourceSepList(),
"decort_sep": dataSourceSep(),
"decort_sep_consumption": dataSourceSepConsumption(),
"decort_sep_disk_list": dataSourceSepDiskList(),
"decort_sep_config": dataSourceSepConfig(),
"decort_sep_pool": dataSourceSepPool(),
"decort_disk_list": dataSourceDiskList(),
"decort_rg_list": dataSourceRgList(),
"decort_account_list": dataSourceAccountList(),
"decort_account_computes_list": dataSourceAccountComputesList(),
"decort_account_disks_list": dataSourceAccountDisksList(),
"decort_account_vins_list": dataSourceAccountVinsList(),
"decort_account_audits_list": dataSourceAccountAuditsList(),
"decort_account_rg_list": dataSourceAccountRGList(),
"decort_account_consumed_units": dataSourceAccountConsumedUnits(),
"decort_account_consumed_units_by_type": dataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": dataSourceAccountReservedUnits(),
"decort_account_templates_list": dataSourceAccountTemplatessList(),
"decort_account_deleted_list": dataSourceAccountDeletedList(),
"decort_account_flipgroups_list": dataSourceAccountFlipGroupsList(),
"decort_bservice_list": dataSourceBasicServiceList(),
"decort_bservice": dataSourceBasicService(),
"decort_bservice_snapshot_list": dataSourceBasicServiceSnapshotList(),
"decort_bservice_group": dataSourceBasicServiceGroup(),
"decort_bservice_deleted_list": dataSourceBasicServiceDeletedList(),
"decort_extnet_list": dataSourceExtnetList(),
"decort_extnet_computes_list": dataSourceExtnetComputesList(),
"decort_extnet": dataSourceExtnet(),
"decort_extnet_default": dataSourceExtnetDefault(),
"decort_vins_list": dataSourceVinsList(),
// "decort_pfw": dataSourcePfw(),
},
ConfigureFunc: providerConfigure,
}
}
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 := ControllerConfigure(d)
if err != nil {
return nil, err
}
// initialize global default Grid ID - it will be needed to create some resource types, e.g. disks
gridId, err := decsController.utilityLocationGetDefaultGridID()
if err != nil {
return nil, err
}
if gridId == 0 {
return nil, fmt.Errorf("providerConfigure: invalid default Grid ID = 0")
}
return decsController, nil
}

@ -6,6 +6,6 @@ require (
github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/google/uuid v1.3.0 github.com/google/uuid v1.3.0
github.com/hashicorp/terraform-plugin-docs v0.5.1 github.com/hashicorp/terraform-plugin-docs v0.5.1
github.com/hashicorp/terraform-plugin-sdk v1.16.0 github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0 // indirect
github.com/sirupsen/logrus v1.7.0 github.com/sirupsen/logrus v1.7.0
) )

@ -55,13 +55,17 @@ github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7/go.mod h1:6zEj6s6u/g
github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE= github.com/andybalholm/crlf v0.0.0-20171020200849-670099aa064f/go.mod h1:k8feO4+kXDxro6ErPXBRTJ/ro2mf0SsFG8s7doP9kJE=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239 h1:kFOfPq6dUM1hTo4JG6LR5AXSUEsOjtdm0kw0FtQtMJA=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c= github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY=
github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U= github.com/apparentlymart/go-cidr v1.0.1 h1:NmIwLZ/KdsjIUlhf+/Np40atNXm/+lZ5txfTJ/SpF+U=
github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc= github.com/apparentlymart/go-cidr v1.0.1/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
github.com/apparentlymart/go-cidr v1.1.0 h1:2mAhrMoF+nhXqxTzSZMUzDHkLjmIHC+Zzn4tdgBZjnU=
github.com/apparentlymart/go-cidr v1.1.0/go.mod h1:EBcsNrHc3zQeuaeCeCtQruQm+n9/YjEn/vI25Lg7Gwc=
github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20180507223929-23540a00eaa3/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0 h1:MzVXffFUye+ZcSR6opIgz9Co7WcDx6ZcY+RjfFHoA0I=
github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM= github.com/apparentlymart/go-dump v0.0.0-20190214190832-042adf3cf4a0/go.mod h1:oL81AME2rN47vu18xqj1S1jPIPuN7afo62yKTNn3XMM=
github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0= github.com/apparentlymart/go-textseg v1.0.0 h1:rRmlIsPEEhUTIKQb7T++Nz/A5Q6C9IuX2wFoYVvnCs0=
github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk= github.com/apparentlymart/go-textseg v1.0.0/go.mod h1:z96Txxhf3xSFMPmb5X/1W05FF/Nj9VFpLOpjS5yuumk=
github.com/apparentlymart/go-textseg/v12 v12.0.0/go.mod h1:S/4uRK2UtaQttw1GenVJEynmyUenKwP++x/+DdGV/Ec=
github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw= github.com/apparentlymart/go-textseg/v13 v13.0.0 h1:Y+KvPE1NYz0xl601PVImeQfFyEy6iT90AvPUL1NNfNw=
github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo= github.com/apparentlymart/go-textseg/v13 v13.0.0/go.mod h1:ZK2fH7c4NqDTLtiYLvIkEghdlcqw7yxLeM89kiTRPUo=
github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8=
@ -77,12 +81,18 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ
github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY=
github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI=
github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@ -94,11 +104,14 @@ github.com/emirpasic/gods v1.12.0/go.mod h1:YfzfFFoVP/catgzJb4IKIqXjX78Ha8FMSDh3
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys= github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc= github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0= github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0= github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4= github.com/go-git/gcfg v1.5.0 h1:Q5ViNfGF8zFgyJWPqYwA7qGFoMTEiBmdlkcfRmpIMa4=
@ -145,6 +158,10 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0= github.com/golang/protobuf v1.4.2 h1:+Z5KGCizgyZCbGh1KZqA0fcLLkwbsjIzS4aV2v7wJX0=
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/golang/snappy v0.0.1/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
@ -154,8 +171,12 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE=
github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg=
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs= github.com/google/martian/v3 v3.0.0 h1:pMen7vLs8nvgEYhywH3KDWJIJTeEr2ULsVWHWYHQyBs=
@ -175,6 +196,7 @@ github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+
github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg=
github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM= github.com/googleapis/gax-go/v2 v2.0.5 h1:sjZBwGj9Jlw33ImPtvFviGYvseOtDM7hkSKB7+Tv3SM=
github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk=
github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw=
github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA=
github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4=
github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU= github.com/hashicorp/go-checkpoint v0.5.0 h1:MFYpPZCnQqQTE18jFwSII6eUQrD/oxMFp3mlgcqk5mU=
@ -183,6 +205,8 @@ github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtng
github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80=
github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ=
github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 h1:1/D3zfFHttUKaCaGKZ/dR2roBXv0vKbSCnssIldfQdI=
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320/go.mod h1:EiZBMaudVLy8fmjf9Npq1dq9RalhveqZG5w/yz3mHWs=
github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY=
github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= github.com/hashicorp/go-getter v1.4.2-0.20200106182914-9813cbd4eb02/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY=
github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU= github.com/hashicorp/go-getter v1.5.3 h1:NF5+zOlQegim+w/EUhSLh6QhXHmZMEeHLQzllkQ3ROU=
@ -190,27 +214,43 @@ github.com/hashicorp/go-getter v1.5.3/go.mod h1:BrrV/1clo8cCYu6mxvboYg+KutTiFnXj
github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI= github.com/hashicorp/go-hclog v0.0.0-20180709165350-ff2cf002a8dd/go.mod h1:9bjs9uLqI8l75knNv3lV1kA55veR+WUPSiKIWcQHudI=
github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI= github.com/hashicorp/go-hclog v0.9.2 h1:CG6TE5H9/JXsFWJCfoIVpKFIkFe6ysEuHirp4DxCsHI=
github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ= github.com/hashicorp/go-hclog v0.9.2/go.mod h1:5CU+agLiy3J7N7QjHK5d05KxGsuXiQLrjA0H7acj2lQ=
github.com/hashicorp/go-hclog v0.14.1/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-hclog v1.2.0 h1:La19f8d7WIlm4ogzNHB0JGqs5AUDAZ2UfCY4sJXcJdM=
github.com/hashicorp/go-hclog v1.2.0/go.mod h1:whpDNt7SSdeAju8AWKIWsul05p54N/39EeqMAyrmvFQ=
github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o= github.com/hashicorp/go-multierror v1.0.0 h1:iVjPR7a6H0tWELX5NxNe7bYopibicUzc7uPribsnS6o=
github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk=
github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo=
github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM=
github.com/hashicorp/go-plugin v1.3.0 h1:4d/wJojzvHV1I4i/rrjVaeuyxWrLzDE1mDCyDy8fXS8= github.com/hashicorp/go-plugin v1.3.0 h1:4d/wJojzvHV1I4i/rrjVaeuyxWrLzDE1mDCyDy8fXS8=
github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0= github.com/hashicorp/go-plugin v1.3.0/go.mod h1:F9eH4LrE/ZsRdbwhfjs9k9HoDUwAHnYtXdgmf1AVNs0=
github.com/hashicorp/go-plugin v1.4.4 h1:NVdrSdFRt3SkZtNckJ6tog7gbpRrcbOjQi/rgF7JYWQ=
github.com/hashicorp/go-plugin v1.4.4/go.mod h1:viDMjcLJuDui6pXb8U4HVfb8AamCWhHGUjr2IrTF67s=
github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo=
github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I=
github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8=
github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw= github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04x7iNw=
github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.4.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/go-version v1.5.0 h1:O293SZ2Eg+AAYijkVK3jR786Am1bhDEh2GHT0tIVE5E=
github.com/hashicorp/go-version v1.5.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hc-install v0.3.1/go.mod h1:3LCdWcCDS1gaHC9mhHCGbkYfoY6vdsKohGjugbZdZak=
github.com/hashicorp/hc-install v0.3.2/go.mod h1:xMG6Tr8Fw1WFjlxH0A9v61cW15pFwgEGqEz0V4jisHs=
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f h1:UdxlrJz4JOnY8W+DbLISwf2B8WXEolNRA8BGCwI9jws=
github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w= github.com/hashicorp/hcl v0.0.0-20170504190234-a4b07c25de5f/go.mod h1:oZtUIOe8dh44I2q6ScRibXws4Ajl+d+nod3AaR9vL5w=
github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90= github.com/hashicorp/hcl/v2 v2.0.0/go.mod h1:oVVDG71tEinNGYCxinCYadcmKU9bglqW9pV3txagJ90=
github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE= github.com/hashicorp/hcl/v2 v2.3.0 h1:iRly8YaMwTBAKhn1Ybk7VSdzbnopghktCD031P8ggUE=
github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8= github.com/hashicorp/hcl/v2 v2.3.0/go.mod h1:d+FwDBbOLvpAM3Z6J7gPj/VoAGkNe/gm352ZhjJ/Zv8=
github.com/hashicorp/hcl/v2 v2.12.0 h1:PsYxySWpMD4KPaoJLnsHwtK5Qptvj/4Q6s0t4sUxZf4=
github.com/hashicorp/hcl/v2 v2.12.0/go.mod h1:FwWsfWEjyV/CMj8s/gqAuiviY72rJ1/oayI9WftqcKg=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 h1:+RyjwU+Gnd/aTJBPZVDNm903eXVjjqhbaR4Ypx3xYyY= github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8 h1:+RyjwU+Gnd/aTJBPZVDNm903eXVjjqhbaR4Ypx3xYyY=
@ -218,16 +258,28 @@ github.com/hashicorp/terraform-config-inspect v0.0.0-20191115094559-17f92b0546e8
github.com/hashicorp/terraform-exec v0.10.0/go.mod h1:tOT8j1J8rP05bZBGWXfMyU3HkLi1LWyqL3Bzsc3CJjo= github.com/hashicorp/terraform-exec v0.10.0/go.mod h1:tOT8j1J8rP05bZBGWXfMyU3HkLi1LWyqL3Bzsc3CJjo=
github.com/hashicorp/terraform-exec v0.15.0 h1:cqjh4d8HYNQrDoEmlSGelHmg2DYDh5yayckvJ5bV18E= github.com/hashicorp/terraform-exec v0.15.0 h1:cqjh4d8HYNQrDoEmlSGelHmg2DYDh5yayckvJ5bV18E=
github.com/hashicorp/terraform-exec v0.15.0/go.mod h1:H4IG8ZxanU+NW0ZpDRNsvh9f0ul7C0nHP+rUR/CHs7I= github.com/hashicorp/terraform-exec v0.15.0/go.mod h1:H4IG8ZxanU+NW0ZpDRNsvh9f0ul7C0nHP+rUR/CHs7I=
github.com/hashicorp/terraform-exec v0.16.1/go.mod h1:aj0lVshy8l+MHhFNoijNHtqTJQI3Xlowv5EOsEaGO7M=
github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU= github.com/hashicorp/terraform-json v0.5.0/go.mod h1:eAbqb4w0pSlRmdvl8fOyHAi/+8jnkVYN28gJkSJrLhU=
github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY= github.com/hashicorp/terraform-json v0.13.0 h1:Li9L+lKD1FO5RVFRM1mMMIBDoUHslOniyEi5CM+FWGY=
github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk= github.com/hashicorp/terraform-json v0.13.0/go.mod h1:y5OdLBCT+rxbwnpxZs9kGL7R9ExU76+cpdY8zHwoazk=
github.com/hashicorp/terraform-json v0.14.0/go.mod h1:5A9HIWPkk4e5aeeXIBbkcOvaZbIYnAIkEyqP2pNSckM=
github.com/hashicorp/terraform-plugin-docs v0.5.1 h1:WwrUcamix9x0TqfTw/WGHMRqoTe1QPZKaeWJPuFb4lQ= github.com/hashicorp/terraform-plugin-docs v0.5.1 h1:WwrUcamix9x0TqfTw/WGHMRqoTe1QPZKaeWJPuFb4lQ=
github.com/hashicorp/terraform-plugin-docs v0.5.1/go.mod h1:SQwEgy0/B0UPQ07rNEG1Wpt6E3jvRcCwkVHPNybGgc0= github.com/hashicorp/terraform-plugin-docs v0.5.1/go.mod h1:SQwEgy0/B0UPQ07rNEG1Wpt6E3jvRcCwkVHPNybGgc0=
github.com/hashicorp/terraform-plugin-go v0.9.1 h1:vXdHaQ6aqL+OF076nMSBV+JKPdmXlzG5mzVDD04WyPs=
github.com/hashicorp/terraform-plugin-go v0.9.1/go.mod h1:ItjVSlQs70otlzcCwlPcU8FRXLdO973oYFRZwAOxy8M=
github.com/hashicorp/terraform-plugin-log v0.4.0 h1:F3eVnm8r2EfQCe2k9blPIiF/r2TT01SHijXnS7bujvc=
github.com/hashicorp/terraform-plugin-log v0.4.0/go.mod h1:9KclxdunFownr4pIm1jdmwKRmE4d6HVG2c9XDq47rpg=
github.com/hashicorp/terraform-plugin-sdk v1.16.0 h1:NrkXMRjHErUPPTHQkZ6JIn6bByiJzGnlJzH1rVdNEuE= github.com/hashicorp/terraform-plugin-sdk v1.16.0 h1:NrkXMRjHErUPPTHQkZ6JIn6bByiJzGnlJzH1rVdNEuE=
github.com/hashicorp/terraform-plugin-sdk v1.16.0/go.mod h1:5sVxrwW6/xzFhZyql+Q9zXCUEJaGWcBIxBbZFLpVXOI= github.com/hashicorp/terraform-plugin-sdk v1.16.0/go.mod h1:5sVxrwW6/xzFhZyql+Q9zXCUEJaGWcBIxBbZFLpVXOI=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0 h1:Qr5fWNg1SPSfCRMtou67Y6Kcy9UnMYRNlIJTKRuUvXU=
github.com/hashicorp/terraform-plugin-sdk/v2 v2.17.0/go.mod h1:b+LFg8WpYgFgvEBP/6Htk5H9/pJp1V1E8NJAekfH2Ws=
github.com/hashicorp/terraform-plugin-test/v2 v2.1.2/go.mod h1:jerO5mrd+jVNALy8aiq+VZOg/CR8T2T1QR3jd6JKGOI= github.com/hashicorp/terraform-plugin-test/v2 v2.1.2/go.mod h1:jerO5mrd+jVNALy8aiq+VZOg/CR8T2T1QR3jd6JKGOI=
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896 h1:1FGtlkJw87UsTMg5s8jrekrHmUPUJaMcu6ELiVhQrNw=
github.com/hashicorp/terraform-registry-address v0.0.0-20210412075316-9b2996cce896/go.mod h1:bzBPnUIkI0RxauU8Dqo+2KrZZ28Cf48s8V6IHt3p4co=
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg= github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596 h1:hjyO2JsNZUKT1ym+FAdlBEkGPevazYsmVgIMw7dVELg=
github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg= github.com/hashicorp/terraform-svchost v0.0.0-20191011084731-65d371908596/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734 h1:HKLsbzeOsfXmKNpr3GiT18XAblV0BjCbzL8KQAMZGa0=
github.com/hashicorp/terraform-svchost v0.0.0-20200729002733-f050f53b9734/go.mod h1:kNDNcF7sN4DocDLBkQYz73HGKwN1ANB1blq4lIYLYvg=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d h1:kJCB4vdITiW1eC1vq2e6IsrXKrZit1bv/TDYFGMp4BQ=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM= github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
@ -272,11 +324,14 @@ github.com/matryer/is v1.2.0 h1:92UTHpy8CDwaJ08GqLDzhhuixiBUUD1p3AU6PHddz4A=
github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA= github.com/matryer/is v1.2.0/go.mod h1:2fLPjFQM9rhQ15aVEtbuwhJinnOqrmgXPNdZsdwlWXA=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs= github.com/mattn/go-colorable v0.1.11 h1:nQ+aFkoE2TMGc0b68U2OKSexC+eq46+XwZzWXHRmPYs=
github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.11/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.10/go.mod h1:qgIWMr58cqv1PHHyhnkY9lrL7etaEgOFcMEpPG5Rm84=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
@ -294,16 +349,21 @@ github.com/mitchellh/go-testing-interface v0.0.0-20171004221916-a61a99592b77/go.
github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/go-testing-interface v1.0.4 h1:ZU1VNC02qyufSZsjjs7+khruk2fKvbQ3TwRV/IBCeFA= github.com/mitchellh/go-testing-interface v1.0.4 h1:ZU1VNC02qyufSZsjjs7+khruk2fKvbQ3TwRV/IBCeFA=
github.com/mitchellh/go-testing-interface v1.0.4/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/go-testing-interface v1.0.4/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI=
github.com/mitchellh/go-testing-interface v1.14.1 h1:jrgshOhYAUVNMAJiKbEu7EqAwgJJ2JqpQmpLJOu07cU=
github.com/mitchellh/go-testing-interface v1.14.1/go.mod h1:gfgS7OtZj6MA4U1UrDRp04twqAjfvlZyCfX3sDjEym8=
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4=
github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo=
github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE= github.com/mitchellh/mapstructure v1.1.2 h1:fmNYVwqnSfB9mZU6OS2O6GsXM+wcskZDuKQzvN1EDeE=
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.0/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.1/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ=
github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nsf/jsondiff v0.0.0-20200515183724-f29ed568f4ce/go.mod h1:uFMI8w+ref4v2r9jz+c9i1IfIttS/OkmLfrk1jne5hs=
github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw= github.com/oklog/run v1.0.0 h1:Ru7dDtJNOyC66gQ5dQmaCa0qIsAUFY3sFpK1Xk8igrw=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA= github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
@ -316,6 +376,7 @@ github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndr
github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6DI= github.com/posener/complete v1.2.1 h1:LrvDIY//XNo65Lq84G/akBuMGlawHvGBABv8f/ZN6DI=
github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E= github.com/posener/complete v1.2.1/go.mod h1:6gapUrK/U1TAN7ciCoNRIdVC5sbdBTUh1DKN0g6uH7E=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww= github.com/russross/blackfriday v1.6.0 h1:KqfZb0pUVN2lYqZUYRddxF4OR8ZMURnJIG5Y3VRLtww=
github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY= github.com/russross/blackfriday v1.6.0/go.mod h1:ti0ldHuxg49ri4ksnFxlkCfN+hvslNlmVHqNRXXJNAY=
@ -336,6 +397,7 @@ github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@ -346,6 +408,8 @@ github.com/ulikunitz/xz v0.5.8/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oW
github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v3.3.3+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU= github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU=
github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk= github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack v4.0.4+incompatible h1:dSLoQfGFAo3F6OoNhwUmLwVgaUXK79GlxNBwueZn0xI=
github.com/vmihailenco/msgpack v4.0.4+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=
github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U= github.com/vmihailenco/msgpack/v4 v4.3.12 h1:07s4sz9IReOgdikxLTKNbBdqDMLsjPKXwvCazn8G65U=
github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4= github.com/vmihailenco/msgpack/v4 v4.3.12/go.mod h1:gborTTJjAo/GWTqqRjrLCn9pgNN+NXzzngzBKDPIqw4=
github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY= github.com/vmihailenco/tagparser v0.1.1 h1:quXMXlA39OCbd2wAdTsGDlK9RkOk6Wuw+x37wVyIuWY=
@ -360,6 +424,7 @@ github.com/zclconf/go-cty v1.0.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLE
github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s= github.com/zclconf/go-cty v1.1.0/go.mod h1:xnAOWiHeOqg2nWS62VtQ7pbOu17FtxJNW8RLEih+O3s=
github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.0/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8= github.com/zclconf/go-cty v1.2.1/go.mod h1:hOPWgoHbaTUnI5k4D2ld+GRpFJSCe6bCM7m1q/N4PQ8=
github.com/zclconf/go-cty v1.8.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.9.1/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0= github.com/zclconf/go-cty v1.10.0 h1:mp9ZXQeIcN8kAwuqorjH+Q+njbJKjLrvB2yIh4q7U+0=
github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk= github.com/zclconf/go-cty v1.10.0/go.mod h1:vVKLxnk3puL4qRAv72AO+W99LUD4da90g3uUAzyuvAk=
@ -372,6 +437,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto= go.opencensus.io v0.22.4 h1:LYy1Hy3MJdrCdMwwzxA/dRok4ejH+RwNGbuoD9fCjto=
go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw=
go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI=
golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190219172222-a4c6cb3142f2/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20190426145343-a29dc8fdc734/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
@ -384,6 +450,7 @@ golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b h1:7mWr3k41Qtv8XlltBkDkl8LoP3mpSgBW8BUoxtEdbXg=
golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4= golang.org/x/crypto v0.0.0-20210421170649-83a5a9bb288b/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
@ -444,6 +511,9 @@ golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs= golang.org/x/net v0.0.0-20210326060303-6b1517762897 h1:KrsHThm5nFk34YtATK1LsThyGhGbGe1olrte/HInHvs=
golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k= golang.org/x/net v0.0.0-20210326060303-6b1517762897/go.mod h1:uSPa2vr4CLtc/ILN5odXGNXS6mhrKVzTaCXzk9m6W3k=
@ -477,6 +547,7 @@ golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191008105621-543471e840be/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -492,10 +563,13 @@ golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210502180810-71e4cd670f79/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6 h1:foEbQz/B0Oz6YIqu/69kfXPYeFQAuuMYFkjaqXzl5Wo=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -554,6 +628,7 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE=
google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M=
google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg=
@ -601,6 +676,7 @@ google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfG
google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c=
google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA=
@ -619,6 +695,11 @@ google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKa
google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk=
google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE= google.golang.org/grpc v1.30.0 h1:M5a8xTlYTxwMn5ZFkwhRabsygDY5G8TYLyQDBxJNAxE=
google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak=
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.46.0 h1:oCjezcn6g6A75TGoKYBPgKmVBLexhYLM6MebdrPApP8=
google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.2.0/go.mod h1:DNq5QpG7LJqD2AamLZ7zvKE0DEpVl2BSEVjFycAAjRY=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
@ -630,6 +711,11 @@ google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpAD
google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4=
google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c= google.golang.org/protobuf v1.25.0 h1:Ejskq+SyPohKW+1uil0JJMtmHCgJPJ/qWTxr8qp+R4c=
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.28.0 h1:w43yiav+6bVFTBQFZX0r7ipe9JQ1QsbMgHwbBziscLw=
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
@ -641,6 +727,7 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME= gopkg.in/warnings.v0 v0.1.2 h1:wFXVbFY8DY5/xOe1ECiWdKCzZlxgshcYVNkBHstARME=
gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI= gopkg.in/warnings.v0 v0.1.2/go.mod h1:jksf8JmL6Qr/oQM2OXTHunEvvTAsrWBLb6OOjuVWRNI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU= gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=

@ -0,0 +1,26 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package constants
//CloudApi - a part of url for cloudapi
const CloudApi = "/restmachine/cloudapi"
//CloudBroker - a part of url for cloudbroker
const CloudBroker = "/restmachine/cloudbroker"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,29 +17,22 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
/* package constants
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
// LimitMaxVinsPerResgroup set maximum number of VINs instances per Resource Group // LimitMaxVinsPerResgroup set maximum number of VINs instances per Resource Group
const LimitMaxVinsPerResgroup=4 const LimitMaxVinsPerResgroup = 4
// MaxSshKeysPerCompute sets maximum number of user:ssh_key pairs to authorize when creating new compute // MaxSshKeysPerCompute sets maximum number of user:ssh_key pairs to authorize when creating new compute
const MaxSshKeysPerCompute=12 const MaxSshKeysPerCompute = 12
// MaxExtraDisksPerCompute sets maximum number of extra disks that can be added when creating new compute // MaxExtraDisksPerCompute sets maximum number of extra disks that can be added when creating new compute
const MaxExtraDisksPerCompute=12 const MaxExtraDisksPerCompute = 12
// MaxNetworksPerCompute sets maximum number of vNICs per compute // MaxNetworksPerCompute sets maximum number of vNICs per compute
const MaxNetworksPerCompute=8 const MaxNetworksPerCompute = 8
// MaxCpusPerCompute sets maximum number of vCPUs per compute // MaxCpusPerCompute sets maximum number of vCPUs per compute
const MaxCpusPerCompute=128 const MaxCpusPerCompute = 128
// MinRamPerCompute sets minimum amount of RAM per compute in MB // MinRamPerCompute sets minimum amount of RAM per compute in MB
const MinRamPerCompute=128 const MinRamPerCompute = 128

@ -0,0 +1,28 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package constants
import "time"
// timeouts for API calls from CRUD functions of Terraform plugin
var Timeout30s = time.Second * 30
var Timeout60s = time.Second * 60
var Timeout180s = time.Second * 180
var Timeout20m = time.Minute * 20

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,14 +17,7 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
/* package controller
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import ( import (
"bytes" "bytes"
@ -41,8 +36,7 @@ import (
"github.com/dgrijalva/jwt-go" "github.com/dgrijalva/jwt-go"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
// "github.com/hashicorp/terraform-plugin-sdk/terraform"
) )
// enumerated constants that define authentication modes // enumerated constants that define authentication modes
@ -191,7 +185,7 @@ func ControllerConfigure(d *schema.ResourceData) (*ControllerCfg, error) {
return ret_config, nil return ret_config, nil
} }
func (config *ControllerCfg) getDecortUsername() string { func (config *ControllerCfg) GetDecortUsername() string {
return config.decort_username return config.decort_username
} }
@ -331,7 +325,7 @@ func (config *ControllerCfg) validateLegacyUser() (bool, error) {
return true, nil return true, nil
} }
func (config *ControllerCfg) decortAPICall(method string, api_name string, url_values *url.Values) (json_resp string, err error) { //nolint:unparam func (config *ControllerCfg) DecortAPICall(method string, api_name string, url_values *url.Values) (json_resp string, err error) { //nolint:unparam
// This is a convenience wrapper around standard HTTP request methods that is aware of the // This is a convenience wrapper around standard HTTP request methods that is aware of the
// authorization mode for which the provider was initialized and compiles request accordingly. // authorization mode for which the provider was initialized and compiles request accordingly.

@ -0,0 +1,41 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package flattens
import "strconv"
func FlattenMeta(m []interface{}) []string {
output := []string{}
for _, item := range m {
switch d := item.(type) {
case string:
output = append(output, d)
case int:
output = append(output, strconv.Itoa(d))
case int64:
output = append(output, strconv.FormatInt(d, 10))
case float64:
output = append(output, strconv.FormatInt(int64(d), 10))
default:
output = append(output, "")
}
}
return output
}

@ -0,0 +1,22 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package location
const LocationsListAPI = "/restmachine/cloudapi/locations/list" // Returns list of GridRecord on success

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,33 +17,26 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
/* package location
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration
Technology platfom.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates.
*/
package decort
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/url" "net/url"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
// "github.com/hashicorp/terraform-plugin-sdk/helper/schema"
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
) )
var DefaultGridID int var DefaultGridID int
func (controller *ControllerCfg) utilityLocationGetDefaultGridID() (int, error) { func UtilityLocationGetDefaultGridID(m interface{}) (int, error) {
c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
log.Debug("utilityLocationGetDefaultGridID: retrieving locations list") log.Debug("utilityLocationGetDefaultGridID: retrieving locations list")
apiResp, err := controller.decortAPICall("POST", LocationsListAPI, urlValues) apiResp, err := c.DecortAPICall("POST", LocationsListAPI, urlValues)
if err != nil { if err != nil {
return 0, err return 0, err
} }
@ -62,4 +57,3 @@ func (controller *ControllerCfg) utilityLocationGetDefaultGridID() (int, error)
return DefaultGridID, nil return DefaultGridID, nil
} }

@ -0,0 +1,30 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package location
type LocationRecord struct {
GridID int `json:"gid"`
Id int `json:"id"`
LocationCode string `json:"locationCode"`
Name string `json:"name"`
Flag string `json:"flag"`
}
type LocationsListResp []LocationRecord

@ -0,0 +1,87 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package provider
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/account"
"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/rg"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/snapshot"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/vgpu"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/vins"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/grid"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/image"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/sep"
)
func NewDataSourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_account": account.DataSourceAccount(),
"decort_resgroup": rg.DataSourceResgroup(),
// "decort_kvmvm": dataSourceCompute(),
"decort_image": image.DataSourceImage(),
"decort_disk": disks.DataSourceDisk(),
"decort_vins": vins.DataSourceVins(),
"decort_grid": grid.DataSourceGrid(),
"decort_grid_list": grid.DataSourceGridList(),
"decort_image_list": image.DataSourceImageList(),
"decort_image_list_stacks": image.DataSourceImageListStacks(),
"decort_snapshot_list": snapshot.DataSourceSnapshotList(),
"decort_vgpu": vgpu.DataSourceVGPU(),
"decort_pcidevice": pcidevice.DataSourcePcidevice(),
"decort_pcidevice_list": pcidevice.DataSourcePcideviceList(),
"decort_sep_list": sep.DataSourceSepList(),
"decort_sep": sep.DataSourceSep(),
"decort_sep_consumption": sep.DataSourceSepConsumption(),
"decort_sep_disk_list": sep.DataSourceSepDiskList(),
"decort_sep_config": sep.DataSourceSepConfig(),
"decort_sep_pool": sep.DataSourceSepPool(),
"decort_disk_list": disks.DataSourceDiskList(),
"decort_rg_list": rg.DataSourceRgList(),
"decort_account_list": account.DataSourceAccountList(),
"decort_account_computes_list": account.DataSourceAccountComputesList(),
"decort_account_disks_list": account.DataSourceAccountDisksList(),
"decort_account_vins_list": account.DataSourceAccountVinsList(),
"decort_account_audits_list": account.DataSourceAccountAuditsList(),
"decort_account_rg_list": account.DataSourceAccountRGList(),
"decort_account_consumed_units": account.DataSourceAccountConsumedUnits(),
"decort_account_consumed_units_by_type": account.DataSourceAccountConsumedUnitsByType(),
"decort_account_reserved_units": account.DataSourceAccountReservedUnits(),
"decort_account_templates_list": account.DataSourceAccountTemplatessList(),
"decort_account_deleted_list": account.DataSourceAccountDeletedList(),
"decort_account_flipgroups_list": account.DataSourceAccountFlipGroupsList(),
"decort_bservice_list": bservice.DataSourceBasicServiceList(),
"decort_bservice": bservice.DataSourceBasicService(),
"decort_bservice_snapshot_list": bservice.DataSourceBasicServiceSnapshotList(),
"decort_bservice_group": bservice.DataSourceBasicServiceGroup(),
"decort_bservice_deleted_list": bservice.DataSourceBasicServiceDeletedList(),
"decort_extnet_list": extnet.DataSourceExtnetList(),
"decort_extnet_computes_list": extnet.DataSourceExtnetComputesList(),
"decort_extnet": extnet.DataSourceExtnet(),
"decort_extnet_default": extnet.DataSourceExtnetDefault(),
"decort_vins_list": vins.DataSourceVinsList(),
// "decort_pfw": dataSourcePfw(),
}
}

@ -0,0 +1,134 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package provider
import (
"fmt"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/location"
)
func Provider() *schema.Provider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"authenticator": {
Type: schema.TypeString,
Required: true,
StateFunc: 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'.",
},
"oauth2_url": {
Type: schema.TypeString,
Optional: true,
StateFunc: StateFuncToLower,
DefaultFunc: schema.EnvDefaultFunc("DECORT_OAUTH2_URL", nil),
Description: "OAuth2 application URL in 'oauth2' authentication mode.",
},
"controller_url": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
StateFunc: StateFuncToLower,
Description: "URL of DECORT Cloud controller to use. API calls will be directed to this URL.",
},
"user": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_USER", nil),
Description: "User name for DECORT cloud API operations in 'legacy' authentication mode.",
},
"password": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_PASSWORD", nil),
Description: "User password for DECORT cloud API operations in 'legacy' authentication mode.",
},
"app_id": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_ID", nil),
Description: "Application ID to access DECORT cloud API in 'oauth2' authentication mode.",
},
"app_secret": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_APP_SECRET", nil),
Description: "Application secret to access DECORT cloud API in 'oauth2' authentication mode.",
},
"jwt": {
Type: schema.TypeString,
Optional: true,
DefaultFunc: schema.EnvDefaultFunc("DECORT_JWT", nil),
Description: "JWT to access DECORT cloud API in 'jwt' authentication mode.",
},
"allow_unverified_ssl": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "If true, DECORT API will not verify SSL certificates. Use this with caution and in trusted environments only!",
},
},
ResourcesMap: NewRersourcesMap(),
DataSourcesMap: NewDataSourcesMap(),
ConfigureFunc: providerConfigure,
}
}
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 {
return nil, err
}
gridId, err := location.UtilityLocationGetDefaultGridID(decsController)
if err != nil {
return nil, err
}
if gridId == 0 {
return nil, fmt.Errorf("providerConfigure: invalid default Grid ID = 0")
}
return decsController, nil
}

@ -0,0 +1,58 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package provider
import (
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/account"
"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/k8s"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudapi/pfw"
"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/vins"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/image"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/pcidevice"
"github.com/rudecs/terraform-provider-decort/internal/service/cloudbroker/sep"
)
func NewRersourcesMap() map[string]*schema.Resource {
return map[string]*schema.Resource{
"decort_resgroup": rg.ResourceResgroup(),
// "decort_kvmvm": resourceCompute(),
"decort_disk": disks.ResourceDisk(),
"decort_vins": vins.ResourceVins(),
"decort_pfw": pfw.ResourcePfw(),
"decort_k8s": k8s.ResourceK8s(),
"decort_k8s_wg": k8s.ResourceK8sWg(),
"decort_image": image.ResourceImage(),
"decort_virtual_image": image.ResourceVirtualImage(),
"decort_cdrom_image": image.ResourceCDROMImage(),
"decort_delete_images": image.ResourceDeleteImages(),
"decort_snapshot": snapshot.ResourceSnapshot(),
"decort_pcidevice": pcidevice.ResourcePcidevice(),
"decort_sep": sep.ResourceSep(),
"decort_sep_config": sep.ResourceSepConfig(),
"decort_account": account.ResourceAccount(),
"decort_bservice": bservice.ResourceBasicService(),
"decort_bservice_group": bservice.ResourceBasicServiceGroup(),
}
}

@ -0,0 +1,55 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package account
const accountAddUserAPI = "/restmachine/cloudapi/account/addUser"
const accountAuditsAPI = "/restmachine/cloudapi/account/audits"
const accountCreateAPI = "/restmachine/cloudapi/account/create"
const accountDeleteAPI = "/restmachine/cloudapi/account/delete"
const accountDeleteUserAPI = "/restmachine/cloudapi/account/deleteUser"
const accountDisableAPI = "/restmachine/cloudapi/account/disable"
const accountEnableAPI = "/restmachine/cloudapi/account/enable"
const accountGetAPI = "/restmachine/cloudapi/account/get"
const accountGetConsumedUnitsAPI = "/restmachine/cloudapi/account/getConsumedAccountUnits"
const accountGetConsumedUnitsByTypeAPI = "/restmachine/cloudapi/account/getConsumedCloudUnitsByType"
const accountGetReservedUnitsAPI = "/restmachine/cloudapi/account/getReservedAccountUnits"
const accountListAPI = "/restmachine/cloudapi/account/list"
const accountListComputesAPI = "/restmachine/cloudapi/account/listComputes"
const accountListDeletedAPI = "/restmachine/cloudapi/account/listDeleted"
const accountListDisksAPI = "/restmachine/cloudapi/account/listDisks"
const accountListFlipGroupsAPI = "/restmachine/cloudapi/account/listFlipGroups"
const accountListRGAPI = "/restmachine/cloudapi/account/listRG"
const accountListTemplatesAPI = "/restmachine/cloudapi/account/listTemplates"
const accountListVinsAPI = "/restmachine/cloudapi/account/listVins"
const accountRestoreAPI = "/restmachine/cloudapi/account/restore"
const accountUpdateAPI = "/restmachine/cloudapi/account/update"
const accountUpdateUserAPI = "/restmachine/cloudapi/account/updateUser"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/flattens"
) )
func dataSourceAccountRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
acc, err := utilityAccountCheckPresence(d, m) acc, err := utilityAccountCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -40,7 +52,7 @@ func dataSourceAccountRead(d *schema.ResourceData, m interface{}) error {
d.Set("dc_location", acc.DCLocation) d.Set("dc_location", acc.DCLocation)
d.Set("resources", flattenAccResources(acc.Resources)) d.Set("resources", flattenAccResources(acc.Resources))
d.Set("ckey", acc.CKey) d.Set("ckey", acc.CKey)
d.Set("meta", flattenMeta(acc.Meta)) d.Set("meta", flattens.FlattenMeta(acc.Meta))
d.Set("acl", flattenAccAcl(acc.Acl)) d.Set("acl", flattenAccAcl(acc.Acl))
d.Set("company", acc.Company) d.Set("company", acc.Company)
d.Set("companyurl", acc.CompanyUrl) d.Set("companyurl", acc.CompanyUrl)
@ -103,6 +115,22 @@ func flattenAccAcl(acls []AccountAclRecord) []map[string]interface{} {
return res return res
} }
func flattenRgResourceLimits(rl ResourceLimits) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{
"cu_c": rl.CUC,
"cu_d": rl.CUD,
"cu_i": rl.CUI,
"cu_m": rl.CUM,
"cu_np": rl.CUNP,
"gpu_units": rl.GpuUnits,
}
res = append(res, temp)
return res
}
func flattenAccResources(r Resources) []map[string]interface{} { func flattenAccResources(r Resources) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
temp := map[string]interface{}{ temp := map[string]interface{}{
@ -401,15 +429,15 @@ func dataSourceAccountSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccount() *schema.Resource { func DataSourceAccount() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountRead, ReadContext: dataSourceAccountRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountSchemaMake(), Schema: dataSourceAccountSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountAuditsList(aal AccountAuditsList) []map[string]interface{} { func flattenAccountAuditsList(aal AccountAuditsList) []map[string]interface{} {
@ -45,10 +56,10 @@ func flattenAccountAuditsList(aal AccountAuditsList) []map[string]interface{} {
} }
func dataSourceAccountAuditsListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountAuditsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountAuditsList, err := utilityAccountAuditsListCheckPresence(d, m) accountAuditsList, err := utilityAccountAuditsListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -98,15 +109,15 @@ func dataSourceAccountAuditsListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountAuditsList() *schema.Resource { func DataSourceAccountAuditsList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountAuditsListRead, ReadContext: dataSourceAccountAuditsListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountAuditsListSchemaMake(), Schema: dataSourceAccountAuditsListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountComputesList(acl AccountComputesList) []map[string]interface{} { func flattenAccountComputesList(acl AccountComputesList) []map[string]interface{} {
@ -60,10 +71,10 @@ func flattenAccountComputesList(acl AccountComputesList) []map[string]interface{
} }
func dataSourceAccountComputesListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountComputesList, err := utilityAccountComputesListCheckPresence(d, m) accountComputesList, err := utilityAccountComputesListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -173,15 +184,15 @@ func dataSourceAccountComputesListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountComputesList() *schema.Resource { func DataSourceAccountComputesList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountComputesListRead, ReadContext: dataSourceAccountComputesListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountComputesListSchemaMake(), Schema: dataSourceAccountComputesListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,32 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceAccountConsumedUnitsRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountConsumedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(d, m) accountConsumedUnits, err := utilityAccountConsumedUnitsCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -82,15 +93,15 @@ func dataSourceAccountConsumedUnitsSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountConsumedUnits() *schema.Resource { func DataSourceAccountConsumedUnits() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountConsumedUnitsRead, ReadContext: dataSourceAccountConsumedUnitsRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountConsumedUnitsSchemaMake(), Schema: dataSourceAccountConsumedUnitsSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,32 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceAccountConsumedUnitsByTypeRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountConsumedUnitsByTypeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
result, err := utilityAccountConsumedUnitsByTypeCheckPresence(d, m) result, err := utilityAccountConsumedUnitsByTypeCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -62,15 +73,15 @@ func dataSourceAccountConsumedUnitsByTypeSchemaMake() map[string]*schema.Schema
return res return res
} }
func dataSourceAccountConsumedUnitsByType() *schema.Resource { func DataSourceAccountConsumedUnitsByType() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountConsumedUnitsByTypeRead, ReadContext: dataSourceAccountConsumedUnitsByTypeRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(), Schema: dataSourceAccountConsumedUnitsByTypeSchemaMake(),

@ -0,0 +1,69 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package account
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
)
func dataSourceAccountDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountDeletedList, err := utilityAccountDeletedListCheckPresence(d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenAccountList(accountDeletedList))
return nil
}
func DataSourceAccountDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceAccountDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceAccountListSchemaMake(),
}
}

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,25 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
*/
Please see README.md to learn where to place source code so that it
builds seamlessly.
package decort Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountDisksList(adl AccountDisksList) []map[string]interface{} { func flattenAccountDisksList(adl AccountDisksList) []map[string]interface{} {
@ -46,10 +56,10 @@ func flattenAccountDisksList(adl AccountDisksList) []map[string]interface{} {
} }
func dataSourceAccountDisksListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountDisksListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountDisksList, err := utilityAccountDisksListCheckPresence(d, m) accountDisksList, err := utilityAccountDisksListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -103,15 +113,15 @@ func dataSourceAccountDisksListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountDisksList() *schema.Resource { func DataSourceAccountDisksList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountDisksListRead, ReadContext: dataSourceAccountDisksListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountDisksListSchemaMake(), Schema: dataSourceAccountDisksListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountFlipGroupsList(afgl AccountFlipGroupsList) []map[string]interface{} { func flattenAccountFlipGroupsList(afgl AccountFlipGroupsList) []map[string]interface{} {
@ -61,10 +72,10 @@ func flattenAccountFlipGroupsList(afgl AccountFlipGroupsList) []map[string]inter
} }
func dataSourceAccountFlipGroupsListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountFlipGroupsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(d, m) accountFlipGroupsList, err := utilityAccountFlipGroupsListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -178,15 +189,15 @@ func dataSourceAccountFlipGroupsListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountFlipGroupsList() *schema.Resource { func DataSourceAccountFlipGroupsList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountFlipGroupsListRead, ReadContext: dataSourceAccountFlipGroupsListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountFlipGroupsListSchemaMake(), Schema: dataSourceAccountFlipGroupsListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountList(al AccountCloudApiList) []map[string]interface{} { func flattenAccountList(al AccountCloudApiList) []map[string]interface{} {
@ -46,6 +57,22 @@ func flattenAccountList(al AccountCloudApiList) []map[string]interface{} {
return res return res
} }
func flattenRgAcl(rgAcls []AccountAclRecord) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, rgAcl := range rgAcls {
temp := map[string]interface{}{
"explicit": rgAcl.IsExplicit,
"guid": rgAcl.Guid,
"right": rgAcl.Rights,
"status": rgAcl.Status,
"type": rgAcl.Type,
"user_group_id": rgAcl.UgroupID,
}
res = append(res, temp)
}
return res
}
/*uncomment for cloudbroker /*uncomment for cloudbroker
func flattenAccountList(al AccountList) []map[string]interface{} { func flattenAccountList(al AccountList) []map[string]interface{} {
res := make([]map[string]interface{}, 0) res := make([]map[string]interface{}, 0)
@ -91,10 +118,10 @@ func flattenAccountList(al AccountList) []map[string]interface{} {
} }
*/ */
func dataSourceAccountListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountList, err := utilityAccountListCheckPresence(d, m) accountList, err := utilityAccountListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -290,15 +317,15 @@ func dataSourceAccountListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountList() *schema.Resource { func DataSourceAccountList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountListRead, ReadContext: dataSourceAccountListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountListSchemaMake(), Schema: dataSourceAccountListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,32 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceAccountReservedUnitsRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountReservedUnitsRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(d, m) accountReservedUnits, err := utilityAccountReservedUnitsCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -82,15 +93,15 @@ func dataSourceAccountReservedUnitsSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountReservedUnits() *schema.Resource { func DataSourceAccountReservedUnits() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountReservedUnitsRead, ReadContext: dataSourceAccountReservedUnitsRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountReservedUnitsSchemaMake(), Schema: dataSourceAccountReservedUnitsSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountRGList(argl AccountRGList) []map[string]interface{} { func flattenAccountRGList(argl AccountRGList) []map[string]interface{} {
@ -74,10 +85,10 @@ func flattenAccRGResources(argr AccountRGResources) []map[string]interface{} {
return res return res
} }
func dataSourceAccountRGListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountRGListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountRGList, err := utilityAccountRGListCheckPresence(d, m) accountRGList, err := utilityAccountRGListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -278,15 +289,15 @@ func dataSourceAccountRGListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountRGList() *schema.Resource { func DataSourceAccountRGList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountRGListRead, ReadContext: dataSourceAccountRGListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountRGListSchemaMake(), Schema: dataSourceAccountRGListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountTemplatesList(atl AccountTemplatesList) []map[string]interface{} { func flattenAccountTemplatesList(atl AccountTemplatesList) []map[string]interface{} {
@ -50,10 +61,10 @@ func flattenAccountTemplatesList(atl AccountTemplatesList) []map[string]interfac
} }
func dataSourceAccountTemplatesListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountTemplatesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(d, m) accountTemplatesList, err := utilityAccountTemplatesListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -123,15 +134,15 @@ func dataSourceAccountTemplatesListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountTemplatessList() *schema.Resource { func DataSourceAccountTemplatessList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountTemplatesListRead, ReadContext: dataSourceAccountTemplatesListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountTemplatesListSchemaMake(), Schema: dataSourceAccountTemplatesListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenAccountVinsList(avl AccountVinsList) []map[string]interface{} { func flattenAccountVinsList(avl AccountVinsList) []map[string]interface{} {
@ -57,10 +68,10 @@ func flattenAccountVinsList(avl AccountVinsList) []map[string]interface{} {
} }
func dataSourceAccountVinsListRead(d *schema.ResourceData, m interface{}) error { func dataSourceAccountVinsListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
accountVinsList, err := utilityAccountVinsListCheckPresence(d, m) accountVinsList, err := utilityAccountVinsListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -158,15 +169,15 @@ func dataSourceAccountVinsListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceAccountVinsList() *schema.Resource { func DataSourceAccountVinsList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceAccountVinsListRead, ReadContext: dataSourceAccountVinsListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceAccountVinsListSchemaMake(), Schema: dataSourceAccountVinsListSchemaMake(),

@ -0,0 +1,260 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package account
type AccountAclRecord struct {
IsExplicit bool `json:"explicit"`
Guid string `json:"guid"`
Rights string `json:"right"`
Status string `json:"status"`
Type string `json:"type"`
UgroupID string `json:"userGroupId"`
CanBeDeleted bool `json:"canBeDeleted"`
}
type ResourceLimits struct {
CUC float64 `json:"CU_C"`
CUD float64 `json:"CU_D"`
CUI float64 `json:"CU_I"`
CUM float64 `json:"CU_M"`
CUNP float64 `json:"CU_NP"`
GpuUnits float64 `json:"gpu_units"`
}
type Account struct {
DCLocation string `json:"DCLocation"`
CKey string `jspn:"_ckey"`
Meta []interface{} `json:"_meta"`
Acl []AccountAclRecord `json:"acl"`
Company string `json:"company"`
CompanyUrl string `json:"companyurl"`
CreatedBy string `jspn:"createdBy"`
CreatedTime int `json:"createdTime"`
DeactiovationTime float64 `json:"deactivationTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
DisplayName string `json:"displayname"`
GUID int `json:"guid"`
ID int `json:"id"`
Name string `json:"name"`
ResourceLimits ResourceLimits `json:"resourceLimits"`
SendAccessEmails bool `json:"sendAccessEmails"`
ServiceAccount bool `json:"serviceAccount"`
Status string `json:"status"`
UpdatedTime int `json:"updatedTime"`
Version int `json:"version"`
Vins []int `json:"vins"`
}
type AccountList []Account
type AccountCloudApi struct {
Acl []AccountAclRecord `json:"acl"`
CreatedTime int `json:"createdTime"`
DeletedTime int `json:"deletedTime"`
ID int `json:"id"`
Name string `json:"name"`
Status string `json:"status"`
UpdatedTime int `json:"updatedTime"`
}
type AccountCloudApiList []AccountCloudApi
type Resource struct {
CPU int `json:"cpu"`
Disksize int `json:"disksize"`
Extips int `json:"extips"`
Exttraffic int `json:"exttraffic"`
GPU int `json:"gpu"`
RAM int `json:"ram"`
}
type Resources struct {
Current Resource `json:"Current"`
Reserved Resource `json:"Reserved"`
}
type Computes struct {
Started int `json:"started"`
Stopped int `json:"stopped"`
}
type Machines struct {
Running int `json:"running"`
Halted int `json:"halted"`
}
type AccountWithResources struct {
Account
Resources Resources `json:"Resources"`
Computes Computes `json:"computes"`
Machines Machines `json:"machines"`
Vinses int `json:"vinses"`
}
type AccountCompute struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
CPUs int `json:"cpus"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
ComputeId int `json:"id"`
ComputeName string `json:"name"`
RAM int `json:"ram"`
Registered bool `json:"registered"`
RgId int `json:"rgId"`
RgName string `json:"rgName"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
TotalDisksSize int `json:"totalDisksSize"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
UserManaged bool `json:"userManaged"`
VinsConnected int `json:"vinsConnected"`
}
type AccountComputesList []AccountCompute
type AccountDisk struct {
ID int `json:"id"`
Name string `json:"name"`
Pool string `json:"pool"`
SepId int `json:"sepId"`
SizeMax int `json:"sizeMax"`
Type string `json:"type"`
}
type AccountDisksList []AccountDisk
type AccountVin struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
Computes int `json:"computes"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
ExternalIP string `json:"externalIP"`
ID int `json:"id"`
Name string `json:"name"`
Network string `json:"network"`
PriVnfDevId int `json:"priVnfDevId"`
RgId int `json:"rgId"`
RgName string `json:"rgName"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
}
type AccountVinsList []AccountVin
type AccountAudit struct {
Call string `json:"call"`
ResponseTime float64 `json:"responsetime"`
StatusCode int `json:"statuscode"`
Timestamp float64 `json:"timestamp"`
User string `json:"user"`
}
type AccountAuditsList []AccountAudit
type AccountRGComputes struct {
Started int `json:"Started"`
Stopped int `json:"Stopped"`
}
type AccountRGResources struct {
Consumed Resource `json:"Consumed"`
Limits Resource `json:"Limits"`
Reserved Resource `json:"Reserved"`
}
type AccountRG struct {
Computes AccountRGComputes `json:"Computes"`
Resources AccountRGResources `json:"Resources"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
RGID int `json:"id"`
Milestones int `json:"milestones"`
RGName string `json:"name"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
Vinses int `json:"vinses"`
}
type AccountRGList []AccountRG
type AccountTemplate struct {
UNCPath string `json:"UNCPath"`
AccountId int `json:"accountId"`
Desc string `json:"desc"`
ID int `json:"id"`
Name string `json:"name"`
Public bool `json:"public"`
Size int `json:"size"`
Status string `json:"status"`
Type string `json:"type"`
Username string `json:"username"`
}
type AccountTemplatesList []AccountTemplate
type AccountFlipGroup struct {
AccountId int `json:"accountId"`
ClientType string `json:"clientType"`
ConnType string `json:"connType"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DefaultGW string `json:"defaultGW"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
Desc string `json:"desc"`
GID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
IP string `json:"ip"`
Milestones int `json:"milestones"`
Name string `json:"name"`
NetID int `json:"netId"`
NetType string `json:"netType"`
NetMask int `json:"netmask"`
Status string `json:"status"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
}
type AccountFlipGroupsList []AccountFlipGroup

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,45 +18,54 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"errors" "context"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/flattens"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourceAccountCreate(d *schema.ResourceData, m interface{}) error { func resourceAccountCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceAccountCreate") log.Debugf("resourceAccountCreate")
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
if exists, err := resourceAccountExists(d, m); exists { if exists, err := resourceAccountExists(d, m); exists {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId(strconv.Itoa(accountId.(int))) d.SetId(strconv.Itoa(accountId.(int)))
err = resourceAccountRead(d, m) diagnostics := resourceAccountRead(ctx, d, m)
if err != nil { if diagnostics != nil {
return err return diagnostics
} }
return nil return nil
} }
return errors.New("provided account id does not exist") return diag.Errorf("provided account id does not exist")
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("name", d.Get("account_name").(string)) urlValues.Add("name", d.Get("account_name").(string))
@ -122,18 +133,18 @@ func resourceAccountCreate(d *schema.ResourceData, m interface{}) error {
} }
} }
accountId, err := controller.decortAPICall("POST", accountCreateAPI, urlValues) accountId, err := c.DecortAPICall("POST", accountCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(accountId) d.SetId(accountId)
d.Set("account_id", accountId) d.Set("account_id", accountId)
err = resourceAccountRead(d, m) diagnostics := resourceAccountRead(ctx, d, m)
if err != nil { if diagnostics != nil {
return err return diagnostics
} }
d.SetId(id.String()) d.SetId(id.String())
@ -141,19 +152,19 @@ func resourceAccountCreate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceAccountRead(d *schema.ResourceData, m interface{}) error { func resourceAccountRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceAccountRead") log.Debugf("resourceAccountRead")
acc, err := utilityAccountCheckPresence(d, m) acc, err := utilityAccountCheckPresence(d, m)
if acc == nil { if acc == nil {
d.SetId("") d.SetId("")
return err return diag.FromErr(err)
} }
d.Set("dc_location", acc.DCLocation) d.Set("dc_location", acc.DCLocation)
d.Set("resources", flattenAccResources(acc.Resources)) d.Set("resources", flattenAccResources(acc.Resources))
d.Set("ckey", acc.CKey) d.Set("ckey", acc.CKey)
d.Set("meta", flattenMeta(acc.Meta)) d.Set("meta", flattens.FlattenMeta(acc.Meta))
d.Set("acl", flattenAccAcl(acc.Acl)) d.Set("acl", flattenAccAcl(acc.Acl))
d.Set("company", acc.Company) d.Set("company", acc.Company)
d.Set("companyurl", acc.CompanyUrl) d.Set("companyurl", acc.CompanyUrl)
@ -180,25 +191,25 @@ func resourceAccountRead(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceAccountDelete(d *schema.ResourceData, m interface{}) error { func resourceAccountDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceAccountDelete") log.Debugf("resourceAccountDelete")
account, err := utilityAccountCheckPresence(d, m) account, err := utilityAccountCheckPresence(d, m)
if account == nil { if account == nil {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
urlValues.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool))) urlValues.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool)))
_, err = controller.decortAPICall("POST", accountDeleteAPI, urlValues) _, err = c.DecortAPICall("POST", accountDeleteAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId("") d.SetId("")
@ -219,9 +230,9 @@ func resourceAccountExists(d *schema.ResourceData, m interface{}) (bool, error)
return true, nil return true, nil
} }
func resourceAccountEdit(d *schema.ResourceData, m interface{}) error { func resourceAccountEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceAccountEdit") log.Debugf("resourceAccountEdit")
c := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if d.HasChange("enable") { if d.HasChange("enable") {
@ -232,9 +243,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
} }
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
_, err := c.decortAPICall("POST", api, urlValues) _, err := c.DecortAPICall("POST", api, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -243,9 +254,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
if d.HasChange("account_name") { if d.HasChange("account_name") {
urlValues.Add("name", d.Get("account_name").(string)) urlValues.Add("name", d.Get("account_name").(string))
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
_, err := c.decortAPICall("POST", accountUpdateAPI, urlValues) _, err := c.DecortAPICall("POST", accountUpdateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -307,9 +318,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
} }
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
_, err := c.decortAPICall("POST", accountUpdateAPI, urlValues) _, err := c.DecortAPICall("POST", accountUpdateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -318,9 +329,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
if d.HasChange("send_access_emails") { if d.HasChange("send_access_emails") {
urlValues.Add("sendAccessEmails", strconv.FormatBool(d.Get("send_access_emails").(bool))) urlValues.Add("sendAccessEmails", strconv.FormatBool(d.Get("send_access_emails").(bool)))
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
_, err := c.decortAPICall("POST", accountUpdateAPI, urlValues) _, err := c.DecortAPICall("POST", accountUpdateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -330,9 +341,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
restore := d.Get("restore").(bool) restore := d.Get("restore").(bool)
if restore { if restore {
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
_, err := c.decortAPICall("POST", accountRestoreAPI, urlValues) _, err := c.DecortAPICall("POST", accountRestoreAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -368,9 +379,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
urlValues.Add("userId", userConv["user_id"].(string)) urlValues.Add("userId", userConv["user_id"].(string))
urlValues.Add("recursivedelete", strconv.FormatBool(userConv["recursive_delete"].(bool))) urlValues.Add("recursivedelete", strconv.FormatBool(userConv["recursive_delete"].(bool)))
_, err := c.decortAPICall("POST", accountDeleteUserAPI, urlValues) _, err := c.DecortAPICall("POST", accountDeleteUserAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -383,9 +394,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
urlValues.Add("userId", userConv["user_id"].(string)) urlValues.Add("userId", userConv["user_id"].(string))
urlValues.Add("accesstype", strings.ToUpper(userConv["access_type"].(string))) urlValues.Add("accesstype", strings.ToUpper(userConv["access_type"].(string)))
_, err := c.decortAPICall("POST", accountAddUserAPI, urlValues) _, err := c.DecortAPICall("POST", accountAddUserAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -398,9 +409,9 @@ func resourceAccountEdit(d *schema.ResourceData, m interface{}) error {
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
urlValues.Add("userId", userConv["user_id"].(string)) urlValues.Add("userId", userConv["user_id"].(string))
urlValues.Add("accesstype", strings.ToUpper(userConv["access_type"].(string))) urlValues.Add("accesstype", strings.ToUpper(userConv["access_type"].(string)))
_, err := c.decortAPICall("POST", accountUpdateUserAPI, urlValues) _, err := c.DecortAPICall("POST", accountUpdateUserAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -767,26 +778,26 @@ func resourceAccountSchemaMake() map[string]*schema.Schema {
} }
} }
func resourceAccount() *schema.Resource { func ResourceAccount() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceAccountCreate, CreateContext: resourceAccountCreate,
Read: resourceAccountRead, ReadContext: resourceAccountRead,
Update: resourceAccountEdit, UpdateContext: resourceAccountEdit,
Delete: resourceAccountDelete, DeleteContext: resourceAccountDelete,
Exists: resourceAccountExists, Exists: resourceAccountExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s, Create: &constants.Timeout60s,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout60s, Update: &constants.Timeout60s,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourceAccountSchemaMake(), Schema: resourceAccountSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountCheckPresence(d *schema.ResourceData, m interface{}) (*AccountWithResources, error) { func utilityAccountCheckPresence(d *schema.ResourceData, m interface{}) (*AccountWithResources, error) {
account := &AccountWithResources{} account := &AccountWithResources{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if (strconv.Itoa(d.Get("account_id").(int))) != "0" { if (strconv.Itoa(d.Get("account_id").(int))) != "0" {
@ -46,7 +54,7 @@ func utilityAccountCheckPresence(d *schema.ResourceData, m interface{}) (*Accoun
} }
log.Debugf("utilityAccountCheckPresence: load account") log.Debugf("utilityAccountCheckPresence: load account")
accountRaw, err := controller.decortAPICall("POST", accountGetAPI, urlValues) accountRaw, err := c.DecortAPICall("POST", accountGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountAuditsListCheckPresence(d *schema.ResourceData, m interface{}) (AccountAuditsList, error) { func utilityAccountAuditsListCheckPresence(d *schema.ResourceData, m interface{}) (AccountAuditsList, error) {
accountAuditsList := AccountAuditsList{} accountAuditsList := AccountAuditsList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountAuditsListCheckPresence: load account list") log.Debugf("utilityAccountAuditsListCheckPresence: load account list")
accountAuditsListRaw, err := controller.decortAPICall("POST", accountAuditsAPI, urlValues) accountAuditsListRaw, err := c.DecortAPICall("POST", accountAuditsAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountComputesListCheckPresence(d *schema.ResourceData, m interface{}) (AccountComputesList, error) { func utilityAccountComputesListCheckPresence(d *schema.ResourceData, m interface{}) (AccountComputesList, error) {
accountComputesList := AccountComputesList{} accountComputesList := AccountComputesList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountComputesListCheckPresence: load account list") log.Debugf("utilityAccountComputesListCheckPresence: load account list")
accountComputesListRaw, err := controller.decortAPICall("POST", accountListComputesAPI, urlValues) accountComputesListRaw, err := c.DecortAPICall("POST", accountListComputesAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountConsumedUnitsCheckPresence(d *schema.ResourceData, m interface{}) (*ResourceLimits, error) { func utilityAccountConsumedUnitsCheckPresence(d *schema.ResourceData, m interface{}) (*ResourceLimits, error) {
accountConsumedUnits := &ResourceLimits{} accountConsumedUnits := &ResourceLimits{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountConsumedUnitsCheckPresence: load account list") log.Debugf("utilityAccountConsumedUnitsCheckPresence: load account list")
accountConsumedUnitsRaw, err := controller.decortAPICall("POST", accountGetConsumedUnitsAPI, urlValues) accountConsumedUnitsRaw, err := c.DecortAPICall("POST", accountGetConsumedUnitsAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountConsumedUnitsByTypeCheckPresence(d *schema.ResourceData, m interface{}) (float64, error) { func utilityAccountConsumedUnitsByTypeCheckPresence(d *schema.ResourceData, m interface{}) (float64, error) {
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
urlValues.Add("cutype", strings.ToUpper(d.Get("cu_type").(string))) urlValues.Add("cutype", strings.ToUpper(d.Get("cu_type").(string)))
log.Debugf("utilityAccountConsumedUnitsByTypeCheckPresence") log.Debugf("utilityAccountConsumedUnitsByTypeCheckPresence")
resultRaw, err := controller.decortAPICall("POST", accountGetConsumedUnitsByTypeAPI, urlValues) resultRaw, err := c.DecortAPICall("POST", accountGetConsumedUnitsByTypeAPI, urlValues)
if err != nil { if err != nil {
return 0, err return 0, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountDeletedListCheckPresence(d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) { func utilityAccountDeletedListCheckPresence(d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) {
accountDeletedList := AccountCloudApiList{} accountDeletedList := AccountCloudApiList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
@ -47,7 +55,7 @@ func utilityAccountDeletedListCheckPresence(d *schema.ResourceData, m interface{
} }
log.Debugf("utilityAccountDeletedListCheckPresence: load") log.Debugf("utilityAccountDeletedListCheckPresence: load")
accountDeletedListRaw, err := controller.decortAPICall("POST", accountListDeletedAPI, urlValues) accountDeletedListRaw, err := c.DecortAPICall("POST", accountListDeletedAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountDisksListCheckPresence(d *schema.ResourceData, m interface{}) (AccountDisksList, error) { func utilityAccountDisksListCheckPresence(d *schema.ResourceData, m interface{}) (AccountDisksList, error) {
accountDisksList := AccountDisksList{} accountDisksList := AccountDisksList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountDisksListCheckPresence: load account list") log.Debugf("utilityAccountDisksListCheckPresence: load account list")
accountDisksListRaw, err := controller.decortAPICall("POST", accountListDisksAPI, urlValues) accountDisksListRaw, err := c.DecortAPICall("POST", accountListDisksAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountFlipGroupsListCheckPresence(d *schema.ResourceData, m interface{}) (AccountFlipGroupsList, error) { func utilityAccountFlipGroupsListCheckPresence(d *schema.ResourceData, m interface{}) (AccountFlipGroupsList, error) {
accountFlipGroupsList := AccountFlipGroupsList{} accountFlipGroupsList := AccountFlipGroupsList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountFlipGroupsListCheckPresence") log.Debugf("utilityAccountFlipGroupsListCheckPresence")
accountFlipGroupsListRaw, err := controller.decortAPICall("POST", accountListFlipGroupsAPI, urlValues) accountFlipGroupsListRaw, err := c.DecortAPICall("POST", accountListFlipGroupsAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountListCheckPresence(d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) { func utilityAccountListCheckPresence(d *schema.ResourceData, m interface{}) (AccountCloudApiList, error) {
accountList := AccountCloudApiList{} accountList := AccountCloudApiList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
@ -47,7 +55,7 @@ func utilityAccountListCheckPresence(d *schema.ResourceData, m interface{}) (Acc
} }
log.Debugf("utilityAccountListCheckPresence: load account list") log.Debugf("utilityAccountListCheckPresence: load account list")
accountListRaw, err := controller.decortAPICall("POST", accountListAPI, urlValues) accountListRaw, err := c.DecortAPICall("POST", accountListAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountReservedUnitsCheckPresence(d *schema.ResourceData, m interface{}) (*ResourceLimits, error) { func utilityAccountReservedUnitsCheckPresence(d *schema.ResourceData, m interface{}) (*ResourceLimits, error) {
accountReservedUnits := &ResourceLimits{} accountReservedUnits := &ResourceLimits{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountReservedUnitsCheckPresence: load units") log.Debugf("utilityAccountReservedUnitsCheckPresence: load units")
accountReservedUnitsRaw, err := controller.decortAPICall("POST", accountGetReservedUnitsAPI, urlValues) accountReservedUnitsRaw, err := c.DecortAPICall("POST", accountGetReservedUnitsAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountRGListCheckPresence(d *schema.ResourceData, m interface{}) (AccountRGList, error) { func utilityAccountRGListCheckPresence(d *schema.ResourceData, m interface{}) (AccountRGList, error) {
accountRGList := AccountRGList{} accountRGList := AccountRGList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountRGListCheckPresence: load account list") log.Debugf("utilityAccountRGListCheckPresence: load account list")
accountRGListRaw, err := controller.decortAPICall("POST", accountListRGAPI, urlValues) accountRGListRaw, err := c.DecortAPICall("POST", accountListRGAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountTemplatesListCheckPresence(d *schema.ResourceData, m interface{}) (AccountTemplatesList, error) { func utilityAccountTemplatesListCheckPresence(d *schema.ResourceData, m interface{}) (AccountTemplatesList, error) {
accountTemplatesList := AccountTemplatesList{} accountTemplatesList := AccountTemplatesList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountTemplatesListCheckPresence: load") log.Debugf("utilityAccountTemplatesListCheckPresence: load")
accountTemplatesListRaw, err := controller.decortAPICall("POST", accountListTemplatesAPI, urlValues) accountTemplatesListRaw, err := c.DecortAPICall("POST", accountListTemplatesAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package account
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityAccountVinsListCheckPresence(d *schema.ResourceData, m interface{}) (AccountVinsList, error) { func utilityAccountVinsListCheckPresence(d *schema.ResourceData, m interface{}) (AccountVinsList, error) {
accountVinsList := AccountVinsList{} accountVinsList := AccountVinsList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityAccountVinsListCheckPresence: load account list") log.Debugf("utilityAccountVinsListCheckPresence: load account list")
accountVinsListRaw, err := controller.decortAPICall("POST", accountListVinsAPI, urlValues) accountVinsListRaw, err := c.DecortAPICall("POST", accountListVinsAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -0,0 +1,59 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package bservice
const bserviceCreateAPI = "/restmachine/cloudapi/bservice/create"
const bserviceDeleteAPI = "/restmachine/cloudapi/bservice/delete"
const bserviceDisableAPI = "/restmachine/cloudapi/bservice/disable"
const bserviceEnableAPI = "/restmachine/cloudapi/bservice/enable"
const bserviceGetAPI = "/restmachine/cloudapi/bservice/get"
const bserviceGroupAddAPI = "/restmachine/cloudapi/bservice/groupAdd"
const bserviceGroupComputeRemoveAPI = "/restmachine/cloudapi/bservice/groupComputeRemove"
const bserviceGroupGetAPI = "/restmachine/cloudapi/bservice/groupGet"
const bserviceGroupParentAddAPI = "/restmachine/cloudapi/bservice/groupParentAdd"
const bserviceGroupParentRemoveAPI = "/restmachine/cloudapi/bservice/groupParentRemove"
const bserviceGroupRemoveAPI = "/restmachine/cloudapi/bservice/groupRemove"
const bserviceGroupResizeAPI = "/restmachine/cloudapi/bservice/groupResize"
const bserviceGroupStartAPI = "/restmachine/cloudapi/bservice/groupStart"
const bserviceGroupStopAPI = "/restmachine/cloudapi/bservice/groupStop"
const bserviceGroupUpdateAPI = "/restmachine/cloudapi/bservice/groupUpdate"
const bserviceGroupUpdateExtnetAPI = "/restmachine/cloudapi/bservice/groupUpdateExtnet"
const bserviceGroupUpdateVinsAPI = "/restmachine/cloudapi/bservice/groupUpdateVins"
const bserviceListAPI = "/restmachine/cloudapi/bservice/list"
const bserviceListDeletedAPI = "/restmachine/cloudapi/bservice/listDeleted"
const bserviceRestoreAPI = "/restmachine/cloudapi/bservice/restore"
const bserviceSnapshotCreateAPI = "/restmachine/cloudapi/bservice/snapshotCreate"
const bserviceSnapshotDeleteAPI = "/restmachine/cloudapi/bservice/snapshotDelete"
const bserviceSnapshotListAPI = "/restmachine/cloudapi/bservice/snapshotList"
const bserviceSnapshotRollbackAPI = "/restmachine/cloudapi/bservice/snapshotRollback"
const bserviceStartAPI = "/restmachine/cloudapi/bservice/start"
const bserviceStopAPI = "/restmachine/cloudapi/bservice/stop"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,32 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceBasicServiceRead(d *schema.ResourceData, m interface{}) error { func dataSourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
bs, err := utilityBasicServiceCheckPresence(d, m) bs, err := utilityBasicServiceCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -277,15 +288,15 @@ func dataSourceBasicServiceSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceBasicService() *schema.Resource { func DataSourceBasicService() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceBasicServiceRead, ReadContext: dataSourceBasicServiceRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceBasicServiceSchemaMake(), Schema: dataSourceBasicServiceSchemaMake(),

@ -0,0 +1,69 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package bservice
import (
"context"
"github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
)
func dataSourceBasicServiceDeletedListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceDeletedList, err := utilityBasicServiceDeletedListCheckPresence(d, m)
if err != nil {
return diag.FromErr(err)
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenBasicServiceList(basicServiceDeletedList))
return nil
}
func DataSourceBasicServiceDeletedList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
ReadContext: dataSourceBasicServiceDeletedListRead,
Timeouts: &schema.ResourceTimeout{
Read: &constants.Timeout30s,
Default: &constants.Timeout60s,
},
Schema: dataSourceBasicServiceListSchemaMake(),
}
}

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,32 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceBasicServiceGroupRead(d *schema.ResourceData, m interface{}) error { func dataSourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
bsg, err := utilityBasicServiceGroupCheckPresence(d, m) bsg, err := utilityBasicServiceGroupCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -275,15 +286,15 @@ func dataSourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceBasicServiceGroup() *schema.Resource { func DataSourceBasicServiceGroup() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceBasicServiceGroupRead, ReadContext: dataSourceBasicServiceGroupRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceBasicServiceGroupSchemaMake(), Schema: dataSourceBasicServiceGroupSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenBasicServiceList(bsl BasicServiceList) []map[string]interface{} { func flattenBasicServiceList(bsl BasicServiceList) []map[string]interface{} {
@ -61,10 +72,10 @@ func flattenBasicServiceList(bsl BasicServiceList) []map[string]interface{} {
return res return res
} }
func dataSourceBasicServiceListRead(d *schema.ResourceData, m interface{}) error { func dataSourceBasicServiceListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceList, err := utilityBasicServiceListCheckPresence(d, m) basicServiceList, err := utilityBasicServiceListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -199,15 +210,15 @@ func dataSourceBasicServiceListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceBasicServiceList() *schema.Resource { func DataSourceBasicServiceList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceBasicServiceListRead, ReadContext: dataSourceBasicServiceListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceBasicServiceListSchemaMake(), Schema: dataSourceBasicServiceListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,32 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceBasicServiceSnapshotListRead(d *schema.ResourceData, m interface{}) error { func dataSourceBasicServiceSnapshotListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(d, m) basicServiceSnapshotList, err := utilityBasicServiceSnapshotListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -77,15 +88,15 @@ func dataSourceBasicServiceSnapshotListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceBasicServiceSnapshotList() *schema.Resource { func DataSourceBasicServiceSnapshotList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceBasicServiceSnapshotListRead, ReadContext: dataSourceBasicServiceSnapshotListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceBasicServiceSnapshotListSchemaMake(), Schema: dataSourceBasicServiceSnapshotListSchemaMake(),

@ -0,0 +1,144 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package bservice
///Structs
type BasicServiceCompute struct {
CompGroupId int `json:"compgroupId"`
CompGroupName string `json:"compgroupName"`
CompGroupRole string `json:"compgroupRole"`
ID int `json:"id"`
Name string `json:"name"`
}
type BasicServiceComputes []BasicServiceCompute
type BasicServiceSnapshot struct {
GUID string `json:"guid"`
Label string `json:"label"`
Timestamp int `json:"timestamp"`
Valid bool `json:"valid"`
}
type BasicServiceSnapshots []BasicServiceSnapshot
type BasicService struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
BaseDomain string `json:"baseDomain"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
GID int `json:"gid"`
Groups []int `json:"groups"`
GUID int `json:"guid"`
ID int `json:"id"`
Name string `json:"name"`
ParentSrvId int `json:"parentSrvId"`
ParentSrvType string `json:"parentSrvType"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
SSHUser string `json:"sshUser"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
UserManaged bool `json:"userManaged"`
}
type BasicServiceList []BasicService
type BasicServiceExtend struct {
BasicService
Computes BasicServiceComputes `json:"computes"`
CPUTotal int `json:"cpuTotal"`
DiskTotal int `json:"diskTotal"`
GroupsName []string `json:"groupsName"`
Milestones int `json:"milestones"`
RamTotal int `json:"ramTotal"`
Snapshots BasicServiceSnapshots `json:"snapshots"`
SSHKey string `json:"sshKey"`
}
type BasicServiceGroupOSUser struct {
Login string `json:"login"`
Password string `json:"password"`
}
type BasicServiceGroupOSUsers []BasicServiceGroupOSUser
type BasicServicceGroupCompute struct {
ID int `json:"id"`
IPAdresses []string `json:"ipAddresses"`
Name string `json:"name"`
OSUsers BasicServiceGroupOSUsers `json:"osUsers"`
}
type BasicServiceGroupComputes []BasicServicceGroupCompute
type BasicServiceGroup struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
Computes BasicServiceGroupComputes `json:"computes"`
Consistency bool `json:"consistency"`
CPU int `json:"cpu"`
CreatedBy string `json:"createdBy"`
CreatedTime int `json:"createdTime"`
DeletedBy string `json:"deletedBy"`
DeletedTime int `json:"deletedTime"`
Disk int `json:"disk"`
Driver string `json:"driver"`
Extnets []int `json:"extnets"`
GID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
ImageId int `json:"imageId"`
Milestones int `json:"milestones"`
Name string `json:"name"`
Parents []int `json:"parents"`
RAM int `json:"ram"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
Role string `json:"role"`
SepId int `json:"sepId"`
SeqNo int `json:"seqNo"`
ServiceId int `json:"serviceId"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
TimeoutStart int `json:"timeoutStart"`
UpdatedBy string `json:"updatedBy"`
UpdatedTime int `json:"updatedTime"`
Vinses []int `json:"vinses"`
}

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,46 +18,54 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"errors" "context"
"net/url" "net/url"
"strconv" "strconv"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourceBasicServiceCreate(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceCreate") log.Debugf("resourceBasicServiceCreate")
if serviceId, ok := d.GetOk("service_id"); ok { if serviceId, ok := d.GetOk("service_id"); ok {
if exists, err := resourceBasicServiceExists(d, m); exists { if exists, err := resourceBasicServiceExists(d, m); exists {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(strconv.Itoa(serviceId.(int))) d.SetId(strconv.Itoa(serviceId.(int)))
d.Set("service_id", strconv.Itoa(serviceId.(int))) d.Set("service_id", strconv.Itoa(serviceId.(int)))
err = resourceBasicServiceRead(d, m) diagnostics := resourceBasicServiceRead(ctx, d, m)
if err != nil { if diagnostics != nil {
return err return diagnostics
} }
d.SetId(id.String()) d.SetId(id.String())
return nil return nil
} }
return errors.New("provided service id does not exist") return diag.Errorf("provided service id does not exist")
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("name", d.Get("service_name").(string)) urlValues.Add("name", d.Get("service_name").(string))
@ -68,18 +78,18 @@ func resourceBasicServiceCreate(d *schema.ResourceData, m interface{}) error {
urlValues.Add("sshUser", sshUser.(string)) urlValues.Add("sshUser", sshUser.(string))
} }
serviceId, err := controller.decortAPICall("POST", bserviceCreateAPI, urlValues) serviceId, err := c.DecortAPICall("POST", bserviceCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(serviceId) d.SetId(serviceId)
d.Set("service_id", serviceId) d.Set("service_id", serviceId)
err = resourceBasicServiceRead(d, m) diagnostics := resourceBasicServiceRead(ctx, d, m)
if err != nil { if diagnostics != nil {
return err return diagnostics
} }
d.SetId(id.String()) d.SetId(id.String())
@ -87,13 +97,13 @@ func resourceBasicServiceCreate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceBasicServiceRead(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceRead") log.Debugf("resourceBasicServiceRead")
bs, err := utilityBasicServiceCheckPresence(d, m) bs, err := utilityBasicServiceCheckPresence(d, m)
if bs == nil { if bs == nil {
d.SetId("") d.SetId("")
return err return diag.FromErr(err)
} }
d.Set("account_id", bs.AccountId) d.Set("account_id", bs.AccountId)
@ -130,25 +140,25 @@ func resourceBasicServiceRead(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceBasicServiceDelete(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceDelete") log.Debugf("resourceBasicServiceDelete")
bs, err := utilityBasicServiceCheckPresence(d, m) bs, err := utilityBasicServiceCheckPresence(d, m)
if bs == nil { if bs == nil {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool))) urlValues.Add("permanently", strconv.FormatBool(d.Get("permanently").(bool)))
_, err = controller.decortAPICall("POST", bserviceDeleteAPI, urlValues) _, err = c.DecortAPICall("POST", bserviceDeleteAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId("") d.SetId("")
@ -169,9 +179,9 @@ func resourceBasicServiceExists(d *schema.ResourceData, m interface{}) (bool, er
return true, nil return true, nil
} }
func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceEdit") log.Debugf("resourceBasicServiceEdit")
c := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if d.HasChange("enable") { if d.HasChange("enable") {
@ -182,9 +192,9 @@ func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error {
} }
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
_, err := c.decortAPICall("POST", api, urlValues) _, err := c.DecortAPICall("POST", api, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -194,9 +204,9 @@ func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error {
restore := d.Get("restore").(bool) restore := d.Get("restore").(bool)
if restore { if restore {
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
_, err := c.decortAPICall("POST", bserviceRestoreAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceRestoreAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -211,9 +221,9 @@ func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error {
} }
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
_, err := c.decortAPICall("POST", api, urlValues) _, err := c.DecortAPICall("POST", api, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -247,9 +257,9 @@ func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error {
snapshotConv := snapshot.(map[string]interface{}) snapshotConv := snapshot.(map[string]interface{})
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("label", snapshotConv["label"].(string)) urlValues.Add("label", snapshotConv["label"].(string))
_, err := c.decortAPICall("POST", bserviceSnapshotDeleteAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceSnapshotDeleteAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -261,9 +271,9 @@ func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error {
snapshotConv := snapshot.(map[string]interface{}) snapshotConv := snapshot.(map[string]interface{})
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("label", snapshotConv["label"].(string)) urlValues.Add("label", snapshotConv["label"].(string))
_, err := c.decortAPICall("POST", bserviceSnapshotCreateAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceSnapshotCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -275,9 +285,9 @@ func resourceBasicServiceEdit(d *schema.ResourceData, m interface{}) error {
snapshotConv := snapshot.(map[string]interface{}) snapshotConv := snapshot.(map[string]interface{})
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("label", snapshotConv["label"].(string)) urlValues.Add("label", snapshotConv["label"].(string))
_, err := c.decortAPICall("POST", bserviceSnapshotRollbackAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceSnapshotRollbackAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -527,26 +537,26 @@ func resourceBasicServiceSchemaMake() map[string]*schema.Schema {
} }
} }
func resourceBasicService() *schema.Resource { func ResourceBasicService() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceBasicServiceCreate, CreateContext: resourceBasicServiceCreate,
Read: resourceBasicServiceRead, ReadContext: resourceBasicServiceRead,
Update: resourceBasicServiceEdit, UpdateContext: resourceBasicServiceEdit,
Delete: resourceBasicServiceDelete, DeleteContext: resourceBasicServiceDelete,
Exists: resourceBasicServiceExists, Exists: resourceBasicServiceExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s, Create: &constants.Timeout60s,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout60s, Update: &constants.Timeout60s,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourceBasicServiceSchemaMake(), Schema: resourceBasicServiceSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,50 +18,58 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"errors" "context"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourceBasicServiceGroupCreate(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceGroupCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceGroupCreate") log.Debugf("resourceBasicServiceGroupCreate")
if compgroupId, ok := d.GetOk("compgroup_id"); ok { if compgroupId, ok := d.GetOk("compgroup_id"); ok {
if _, ok := d.GetOk("service_id"); ok { if _, ok := d.GetOk("service_id"); ok {
if exists, err := resourceBasicServiceGroupExists(d, m); exists { if exists, err := resourceBasicServiceGroupExists(d, m); exists {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(strconv.Itoa(compgroupId.(int))) d.SetId(strconv.Itoa(compgroupId.(int)))
d.Set("compgroup_id", strconv.Itoa(compgroupId.(int))) d.Set("compgroup_id", strconv.Itoa(compgroupId.(int)))
err = resourceBasicServiceGroupRead(d, m) diagnostics := resourceBasicServiceGroupRead(ctx, d, m)
if err != nil { if diagnostics != nil {
return err return diagnostics
} }
d.SetId(id.String()) d.SetId(id.String())
return nil return nil
} }
return errors.New("provided compgroup id does not exist") return diag.Errorf("provided compgroup id does not exist")
} }
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
@ -109,18 +119,18 @@ func resourceBasicServiceGroupCreate(d *schema.ResourceData, m interface{}) erro
urlValues.Add("extnets", temp) urlValues.Add("extnets", temp)
} }
compgroupId, err := controller.decortAPICall("POST", bserviceGroupAddAPI, urlValues) compgroupId, err := c.DecortAPICall("POST", bserviceGroupAddAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(compgroupId) d.SetId(compgroupId)
d.Set("compgroup_id", compgroupId) d.Set("compgroup_id", compgroupId)
err = resourceBasicServiceGroupRead(d, m) diagnostics := resourceBasicServiceGroupRead(ctx, d, m)
if err != nil { if diagnostics != nil {
return err return diagnostics
} }
d.SetId(id.String()) d.SetId(id.String())
@ -128,13 +138,13 @@ func resourceBasicServiceGroupCreate(d *schema.ResourceData, m interface{}) erro
return nil return nil
} }
func resourceBasicServiceGroupRead(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceGroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceGroupRead") log.Debugf("resourceBasicServiceGroupRead")
bsg, err := utilityBasicServiceGroupCheckPresence(d, m) bsg, err := utilityBasicServiceGroupCheckPresence(d, m)
if bsg == nil { if bsg == nil {
d.SetId("") d.SetId("")
return err return diag.FromErr(err)
} }
d.Set("account_id", bsg.AccountId) d.Set("account_id", bsg.AccountId)
@ -172,25 +182,25 @@ func resourceBasicServiceGroupRead(d *schema.ResourceData, m interface{}) error
return nil return nil
} }
func resourceBasicServiceGroupDelete(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceGroupDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceGroupDelete") log.Debugf("resourceBasicServiceGroupDelete")
bsg, err := utilityBasicServiceGroupCheckPresence(d, m) bsg, err := utilityBasicServiceGroupCheckPresence(d, m)
if bsg == nil { if bsg == nil {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
_, err = controller.decortAPICall("POST", bserviceGroupRemoveAPI, urlValues) _, err = c.DecortAPICall("POST", bserviceGroupRemoveAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId("") d.SetId("")
@ -211,9 +221,9 @@ func resourceBasicServiceGroupExists(d *schema.ResourceData, m interface{}) (boo
return true, nil return true, nil
} }
func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error { func resourceBasicServiceGroupEdit(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceBasicServiceGroupEdit") log.Debugf("resourceBasicServiceGroupEdit")
c := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
@ -222,9 +232,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
urlValues.Add("count", strconv.Itoa(d.Get("comp_count").(int))) urlValues.Add("count", strconv.Itoa(d.Get("comp_count").(int)))
urlValues.Add("mode", strings.ToUpper(d.Get("mode").(string))) urlValues.Add("mode", strings.ToUpper(d.Get("mode").(string)))
_, err := c.decortAPICall("POST", bserviceGroupResizeAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupResizeAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -241,9 +251,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
_, err := c.decortAPICall("POST", api, urlValues) _, err := c.DecortAPICall("POST", api, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -260,9 +270,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
_, err := c.decortAPICall("POST", bserviceGroupUpdateAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupUpdateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -286,9 +296,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
urlValues.Add("extnets", temp) urlValues.Add("extnets", temp)
_, err := c.decortAPICall("POST", bserviceGroupUpdateExtnetAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupUpdateExtnetAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -312,9 +322,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
urlValues.Add("vinses", temp) urlValues.Add("vinses", temp)
_, err := c.decortAPICall("POST", bserviceGroupUpdateVinsAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupUpdateVinsAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -346,9 +356,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
urlValues.Add("parentId", strconv.Itoa(parentConv)) urlValues.Add("parentId", strconv.Itoa(parentConv))
_, err := c.decortAPICall("POST", bserviceGroupParentRemoveAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupParentRemoveAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -361,9 +371,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
urlValues.Add("parentId", strconv.Itoa(parentConv)) urlValues.Add("parentId", strconv.Itoa(parentConv))
_, err := c.decortAPICall("POST", bserviceGroupParentAddAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupParentAddAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -379,9 +389,9 @@ func resourceBasicServiceGroupEdit(d *schema.ResourceData, m interface{}) error
urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int))) urlValues.Add("compgroupId", strconv.Itoa(d.Get("compgroup_id").(int)))
urlValues.Add("computeId", strconv.Itoa(rc.(int))) urlValues.Add("computeId", strconv.Itoa(rc.(int)))
_, err := c.decortAPICall("POST", bserviceGroupComputeRemoveAPI, urlValues) _, err := c.DecortAPICall("POST", bserviceGroupComputeRemoveAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
@ -634,26 +644,26 @@ func resourceBasicServiceGroupSchemaMake() map[string]*schema.Schema {
} }
} }
func resourceBasicServiceGroup() *schema.Resource { func ResourceBasicServiceGroup() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceBasicServiceGroupCreate, CreateContext: resourceBasicServiceGroupCreate,
Read: resourceBasicServiceGroupRead, ReadContext: resourceBasicServiceGroupRead,
Update: resourceBasicServiceGroupEdit, UpdateContext: resourceBasicServiceGroupEdit,
Delete: resourceBasicServiceGroupDelete, DeleteContext: resourceBasicServiceGroupDelete,
Exists: resourceBasicServiceGroupExists, Exists: resourceBasicServiceGroupExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s, Create: &constants.Timeout60s,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout60s, Update: &constants.Timeout60s,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourceBasicServiceGroupSchemaMake(), Schema: resourceBasicServiceGroupSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceDeletedListCheckPresence(d *schema.ResourceData, m interface{}) (BasicServiceList, error) { func utilityBasicServiceDeletedListCheckPresence(d *schema.ResourceData, m interface{}) (BasicServiceList, error) {
basicServiceDeletedList := BasicServiceList{} basicServiceDeletedList := BasicServiceList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
@ -53,7 +61,7 @@ func utilityBasicServiceDeletedListCheckPresence(d *schema.ResourceData, m inter
} }
log.Debugf("utilityBasicServiceDeletedListCheckPresence") log.Debugf("utilityBasicServiceDeletedListCheckPresence")
basicServiceDeletedListRaw, err := controller.decortAPICall("POST", bserviceListDeletedAPI, urlValues) basicServiceDeletedListRaw, err := c.DecortAPICall("POST", bserviceListDeletedAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceCheckPresence(d *schema.ResourceData, m interface{}) (*BasicServiceExtend, error) { func utilityBasicServiceCheckPresence(d *schema.ResourceData, m interface{}) (*BasicServiceExtend, error) {
bservice := &BasicServiceExtend{} bservice := &BasicServiceExtend{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if (strconv.Itoa(d.Get("service_id").(int))) != "0" { if (strconv.Itoa(d.Get("service_id").(int))) != "0" {
@ -46,7 +54,7 @@ func utilityBasicServiceCheckPresence(d *schema.ResourceData, m interface{}) (*B
} }
log.Debugf("utilityBasicServiceCheckPresence") log.Debugf("utilityBasicServiceCheckPresence")
bserviceRaw, err := controller.decortAPICall("POST", bserviceGetAPI, urlValues) bserviceRaw, err := c.DecortAPICall("POST", bserviceGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceGroupCheckPresence(d *schema.ResourceData, m interface{}) (*BasicServiceGroup, error) { func utilityBasicServiceGroupCheckPresence(d *schema.ResourceData, m interface{}) (*BasicServiceGroup, error) {
bserviceGroup := &BasicServiceGroup{} bserviceGroup := &BasicServiceGroup{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int))) urlValues.Add("serviceId", strconv.Itoa(d.Get("service_id").(int)))
@ -47,7 +55,7 @@ func utilityBasicServiceGroupCheckPresence(d *schema.ResourceData, m interface{}
} }
log.Debugf("utilityBasicServiceGroupCheckPresence") log.Debugf("utilityBasicServiceGroupCheckPresence")
bserviceGroupRaw, err := controller.decortAPICall("POST", bserviceGroupGetAPI, urlValues) bserviceGroupRaw, err := c.DecortAPICall("POST", bserviceGroupGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceListCheckPresence(d *schema.ResourceData, m interface{}) (BasicServiceList, error) { func utilityBasicServiceListCheckPresence(d *schema.ResourceData, m interface{}) (BasicServiceList, error) {
basicServiceList := BasicServiceList{} basicServiceList := BasicServiceList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
@ -53,7 +61,7 @@ func utilityBasicServiceListCheckPresence(d *schema.ResourceData, m interface{})
} }
log.Debugf("utilityBasicServiceListCheckPresence") log.Debugf("utilityBasicServiceListCheckPresence")
basicServiceListRaw, err := controller.decortAPICall("POST", bserviceListAPI, urlValues) basicServiceListRaw, err := c.DecortAPICall("POST", bserviceListAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package bservice
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityBasicServiceSnapshotListCheckPresence(d *schema.ResourceData, m interface{}) (BasicServiceSnapshots, error) { func utilityBasicServiceSnapshotListCheckPresence(d *schema.ResourceData, m interface{}) (BasicServiceSnapshots, error) {
basicServiceSnapshotList := BasicServiceSnapshots{} basicServiceSnapshotList := BasicServiceSnapshots{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if serviceId, ok := d.GetOk("service_id"); ok { if serviceId, ok := d.GetOk("service_id"); ok {
@ -44,7 +52,7 @@ func utilityBasicServiceSnapshotListCheckPresence(d *schema.ResourceData, m inte
} }
log.Debugf("utilityBasicServiceSnapshotListCheckPresence") log.Debugf("utilityBasicServiceSnapshotListCheckPresence")
basicServiceSnapshotListRaw, err := controller.decortAPICall("POST", bserviceSnapshotListAPI, urlValues) basicServiceSnapshotListRaw, err := c.DecortAPICall("POST", bserviceSnapshotListAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -0,0 +1,39 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package disks
const DisksCreateAPI = "/restmachine/cloudapi/disks/create"
const DisksGetAPI = "/restmachine/cloudapi/disks/get" // Returns single DiskRecord on success
const DisksListAPI = "/restmachine/cloudapi/disks/list" // Returns list of DiskRecord on success
const DisksResizeAPI = "/restmachine/cloudapi/disks/resize2"
const DisksRenameAPI = "/restmachine/cloudapi/disks/rename"
const DisksDeleteAPI = "/restmachine/cloudapi/disks/delete"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,23 +18,31 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package disks
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
// "net/url" // "net/url"
"github.com/rudecs/terraform-provider-decort/internal/constants"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func flattenDisk(d *schema.ResourceData, disk_facts string) error { func flattenDisk(d *schema.ResourceData, disk_facts string) error {
@ -71,16 +81,16 @@ func flattenDisk(d *schema.ResourceData, disk_facts string) error {
return nil return nil
} }
func dataSourceDiskRead(d *schema.ResourceData, m interface{}) error { func dataSourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
disk_facts, err := utilityDiskCheckPresence(d, m) disk_facts, err := utilityDiskCheckPresence(d, m)
if disk_facts == "" { if disk_facts == "" {
// if empty string is returned from utilityDiskCheckPresence then there is no // if empty string is returned from utilityDiskCheckPresence then there is no
// such Disk and err tells so - just return it to the calling party // such Disk and err tells so - just return it to the calling party
d.SetId("") // ensure ID is empty d.SetId("") // ensure ID is empty
return err return diag.FromErr(err)
} }
return flattenDisk(d, disk_facts) return diag.FromErr(flattenDisk(d, disk_facts))
} }
func dataSourceDiskSchemaMake() map[string]*schema.Schema { func dataSourceDiskSchemaMake() map[string]*schema.Schema {
@ -153,47 +163,47 @@ func dataSourceDiskSchemaMake() map[string]*schema.Schema {
}, },
/* /*
"snapshots": { "snapshots": {
Type: schema.TypeList, Type: schema.TypeList,
Computed: true, Computed: true,
Elem: &schema.Resource { Elem: &schema.Resource {
Schema: snapshotSubresourceSchemaMake(), Schema: snapshotSubresourceSchemaMake(),
},
Description: "List of user-created snapshots for this disk."
}, },
Description: "List of user-created snapshots for this disk."
},
"status": { "status": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "Current model status of this disk.", Description: "Current model status of this disk.",
}, },
"tech_status": { "tech_status": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "Current technical status of this disk.", Description: "Current technical status of this disk.",
}, },
"compute_id": { "compute_id": {
Type: schema.TypeInt, Type: schema.TypeInt,
Computed: true, Computed: true,
Description: "ID of the compute instance where this disk is attached to, or 0 for unattached disk.", Description: "ID of the compute instance where this disk is attached to, or 0 for unattached disk.",
}, },
*/ */
} }
return rets return rets
} }
func dataSourceDisk() *schema.Resource { func DataSourceDisk() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceDiskRead, ReadContext: dataSourceDiskRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceDiskSchemaMake(), Schema: dataSourceDiskSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,19 +18,27 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package disks
import ( import (
"context"
"encoding/json" "encoding/json"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenDiskList(dl DisksListResp) []map[string]interface{} { func flattenDiskList(dl DisksListResp) []map[string]interface{} {
@ -109,10 +119,10 @@ func flattendDiskSnapshotList(sl SnapshotRecordList) []interface{} {
} }
func dataSourceDiskListRead(d *schema.ResourceData, m interface{}) error { func dataSourceDiskListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
diskList, err := utilityDiskListCheckPresence(d, m) diskList, err := utilityDiskListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -375,15 +385,15 @@ func dataSourceDiskListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceDiskList() *schema.Resource { func DataSourceDiskList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceDiskListRead, ReadContext: dataSourceDiskListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceDiskListSchemaMake(), Schema: dataSourceDiskListSchemaMake(),

@ -0,0 +1,95 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package disks
type DiskRecord struct {
Acl map[string]interface{} `json:"acl"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
BootPartition int `json:"bootPartition"`
CreatedTime uint64 `json:"creationTime"`
ComputeID int `json:"computeId"`
ComputeName string `json:"computeName"`
DeletedTime uint64 `json:"deletionTime"`
DeviceName string `json:"devicename"`
Desc string `json:"desc"`
DestructionTime uint64 `json:"destructionTime"`
DiskPath string `json:"diskPath"`
GridID int `json:"gid"`
GUID int `json:"guid"`
ID uint `json:"id"`
ImageID int `json:"imageId"`
Images []int `json:"images"`
IOTune map[string]interface{} `json:"iotune"`
IQN string `json:"iqn"`
Login string `json:"login"`
Name string `json:"name"`
MachineId int `json:"machineId"`
MachineName string `json:"machineName"`
Milestones uint64 `json:"milestones"`
Order int `json:"order"`
Params string `json:"params"`
Passwd string `json:"passwd"`
ParentId int `json:"parentId"`
PciSlot int `json:"pciSlot"`
Pool string `json:"pool"`
PurgeTime uint64 `json:"purgeTime"`
PurgeAttempts uint64 `json:"purgeAttempts"`
RealityDeviceNumber int `json:"realityDeviceNumber"`
ReferenceId string `json:"referenceId"`
ResID string `json:"resId"`
ResName string `json:"resName"`
Role string `json:"role"`
SepType string `json:"sepType"`
SepID int `json:"sepId"` // NOTE: absent from compute/get output
SizeMax int `json:"sizeMax"`
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
Snapshots []SnapshotRecord `json:"snapshots"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
UpdateBy uint64 `json:"updateBy"`
VMID int `json:"vmid"`
}
type SnapshotRecord struct {
Guid string `json:"guid"`
Label string `json:"label"`
ResId string `json:"resId"`
SnapSetGuid string `json:"snapSetGuid"`
SnapSetTime uint64 `json:"snapSetTime"`
TimeStamp uint64 `json:"timestamp"`
}
type SnapshotRecordList []SnapshotRecord
type DisksListResp []DiskRecord

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,34 +18,44 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package disks
import ( import (
// "encoding/json" // "encoding/json"
"context"
"fmt" "fmt"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/location"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
) )
func resourceDiskCreate(d *schema.ResourceData, m interface{}) error { func resourceDiskCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceDiskCreate: called for Disk name %q, Account ID %d", d.Get("name").(string), d.Get("account_id").(int)) log.Debugf("resourceDiskCreate: called for Disk name %q, Account ID %d", d.Get("name").(string), d.Get("account_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
// accountId, gid, name, description, size, type, sep_id, pool // accountId, gid, name, description, size, type, sep_id, pool
urlValues.Add("accountId", fmt.Sprintf("%d", d.Get("account_id").(int))) urlValues.Add("accountId", fmt.Sprintf("%d", d.Get("account_id").(int)))
urlValues.Add("gid", fmt.Sprintf("%d", DefaultGridID)) // we use default Grid ID, which was obtained along with DECORT Controller init urlValues.Add("gid", fmt.Sprintf("%d", location.DefaultGridID)) // we use default Grid ID, which was obtained along with DECORT Controller init
urlValues.Add("name", d.Get("name").(string)) urlValues.Add("name", d.Get("name").(string))
urlValues.Add("size", fmt.Sprintf("%d", d.Get("size").(int))) urlValues.Add("size", fmt.Sprintf("%d", d.Get("size").(int)))
urlValues.Add("type", "D") // NOTE: only disks of Data type are managed via plugin urlValues.Add("type", "D") // NOTE: only disks of Data type are managed via plugin
@ -61,9 +73,9 @@ func resourceDiskCreate(d *schema.ResourceData, m interface{}) error {
urlValues.Add("description", argVal.(string)) urlValues.Add("description", argVal.(string))
} }
apiResp, err := controller.decortAPICall("POST", DisksCreateAPI, urlValues) apiResp, err := c.DecortAPICall("POST", DisksCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId(apiResp) // update ID of the resource to tell Terraform that the disk resource exists d.SetId(apiResp) // update ID of the resource to tell Terraform that the disk resource exists
@ -75,22 +87,22 @@ func resourceDiskCreate(d *schema.ResourceData, m interface{}) error {
// between Disk resource and Disk data source schemas // between Disk resource and Disk data source schemas
// Disk resource read function will also update resource ID on success, so that Terraform // Disk resource read function will also update resource ID on success, so that Terraform
// will know the resource exists (however, we already did it a few lines before) // will know the resource exists (however, we already did it a few lines before)
return dataSourceDiskRead(d, m) return dataSourceDiskRead(ctx, d, m)
} }
func resourceDiskRead(d *schema.ResourceData, m interface{}) error { func resourceDiskRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
diskFacts, err := utilityDiskCheckPresence(d, m) diskFacts, err := utilityDiskCheckPresence(d, m)
if diskFacts == "" { if diskFacts == "" {
// if empty string is returned from utilityDiskCheckPresence then there is no // if empty string is returned from utilityDiskCheckPresence then there is no
// such Disk and err tells so - just return it to the calling party // such Disk and err tells so - just return it to the calling party
d.SetId("") // ensure ID is empty d.SetId("") // ensure ID is empty
return err return diag.FromErr(err)
} }
return flattenDisk(d, diskFacts) return diag.FromErr(flattenDisk(d, diskFacts))
} }
func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error { func resourceDiskUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// Update will only change the following attributes of the disk: // Update will only change the following attributes of the disk:
// - Size; to keep data safe, shrinking disk is not allowed. // - Size; to keep data safe, shrinking disk is not allowed.
// - Name // - Name
@ -100,9 +112,7 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceDiskUpdate: called for Disk ID / name %s / %s, Account ID %d", log.Debugf("resourceDiskUpdate: called for Disk ID / name %s / %s, Account ID %d",
d.Id(), d.Get("name").(string), d.Get("account_id").(int)) d.Id(), d.Get("name").(string), d.Get("account_id").(int))
d.Partial(true) c := m.(*controller.ControllerCfg)
controller := m.(*ControllerCfg)
oldSize, newSize := d.GetChange("size") oldSize, newSize := d.GetChange("size")
if oldSize.(int) < newSize.(int) { if oldSize.(int) < newSize.(int) {
@ -111,13 +121,13 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
sizeParams := &url.Values{} sizeParams := &url.Values{}
sizeParams.Add("diskId", d.Id()) sizeParams.Add("diskId", d.Id())
sizeParams.Add("size", fmt.Sprintf("%d", newSize.(int))) sizeParams.Add("size", fmt.Sprintf("%d", newSize.(int)))
_, err := controller.decortAPICall("POST", DisksResizeAPI, sizeParams) _, err := c.DecortAPICall("POST", DisksResizeAPI, sizeParams)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetPartial("size") d.Set("size", newSize)
} else if oldSize.(int) > newSize.(int) { } else if oldSize.(int) > newSize.(int) {
return fmt.Errorf("resourceDiskUpdate: Disk ID %s - reducing disk size is not allowed", d.Id()) return diag.FromErr(fmt.Errorf("resourceDiskUpdate: Disk ID %s - reducing disk size is not allowed", d.Id()))
} }
oldName, newName := d.GetChange("name") oldName, newName := d.GetChange("name")
@ -127,11 +137,10 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
renameParams := &url.Values{} renameParams := &url.Values{}
renameParams.Add("diskId", d.Id()) renameParams.Add("diskId", d.Id())
renameParams.Add("name", newName.(string)) renameParams.Add("name", newName.(string))
_, err := controller.decortAPICall("POST", DisksRenameAPI, renameParams) _, err := c.DecortAPICall("POST", DisksRenameAPI, renameParams)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetPartial("name")
} }
/* /*
@ -143,14 +152,12 @@ func resourceDiskUpdate(d *schema.ResourceData, m interface{}) error {
} }
*/ */
d.Partial(false)
// we may reuse dataSourceDiskRead here as we maintain similarity // we may reuse dataSourceDiskRead here as we maintain similarity
// between Compute resource and Compute data source schemas // between Compute resource and Compute data source schemas
return dataSourceDiskRead(d, m) return dataSourceDiskRead(ctx, d, m)
} }
func resourceDiskDelete(d *schema.ResourceData, m interface{}) error { func resourceDiskDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// NOTE: this function tries to detach and destroy target Disk "permanently", so // NOTE: this function tries to detach and destroy target Disk "permanently", so
// there is no way to restore it. // there is no way to restore it.
// If, however, the disk is attached to a compute, the method will // If, however, the disk is attached to a compute, the method will
@ -161,7 +168,7 @@ func resourceDiskDelete(d *schema.ResourceData, m interface{}) error {
diskFacts, err := utilityDiskCheckPresence(d, m) diskFacts, err := utilityDiskCheckPresence(d, m)
if diskFacts == "" { if diskFacts == "" {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
// the specified Disk does not exist - in this case according to Terraform best practice // the specified Disk does not exist - in this case according to Terraform best practice
// we exit from Destroy method without error // we exit from Destroy method without error
@ -179,10 +186,10 @@ func resourceDiskDelete(d *schema.ResourceData, m interface{}) error {
params.Add("detach", "0") params.Add("detach", "0")
params.Add("permanently", "1") params.Add("permanently", "1")
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
_, err = controller.decortAPICall("POST", DisksDeleteAPI, params) _, err = c.DecortAPICall("POST", DisksDeleteAPI, params)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
@ -305,26 +312,26 @@ func resourceDiskSchemaMake() map[string]*schema.Schema {
return rets return rets
} }
func resourceDisk() *schema.Resource { func ResourceDisk() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceDiskCreate, CreateContext: resourceDiskCreate,
Read: resourceDiskRead, ReadContext: resourceDiskRead,
Update: resourceDiskUpdate, UpdateContext: resourceDiskUpdate,
Delete: resourceDiskDelete, DeleteContext: resourceDiskDelete,
Exists: resourceDiskExists, Exists: resourceDiskExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout180s, Create: &constants.Timeout180s,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout180s, Update: &constants.Timeout180s,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourceDiskSchemaMake(), Schema: resourceDiskSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,13 +18,18 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package disks
import ( import (
"encoding/json" "encoding/json"
@ -30,9 +37,10 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityDiskCheckPresence(d *schema.ResourceData, m interface{}) (string, error) { func utilityDiskCheckPresence(d *schema.ResourceData, m interface{}) (string, error) {
@ -52,7 +60,7 @@ func utilityDiskCheckPresence(d *schema.ResourceData, m interface{}) (string, er
// method for resource's Exists method. // method for resource's Exists method.
// //
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
// make it possible to use "read" & "check presence" functions with disk ID set so // make it possible to use "read" & "check presence" functions with disk ID set so
@ -73,7 +81,7 @@ func utilityDiskCheckPresence(d *schema.ResourceData, m interface{}) (string, er
// disk ID is specified, try to get disk instance straight by this ID // disk ID is specified, try to get disk instance straight by this ID
log.Debugf("utilityDiskCheckPresence: locating disk by its ID %d", theId) log.Debugf("utilityDiskCheckPresence: locating disk by its ID %d", theId)
urlValues.Add("diskId", fmt.Sprintf("%d", theId)) urlValues.Add("diskId", fmt.Sprintf("%d", theId))
diskFacts, err := controller.decortAPICall("POST", DisksGetAPI, urlValues) diskFacts, err := c.DecortAPICall("POST", DisksGetAPI, urlValues)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -92,7 +100,7 @@ func utilityDiskCheckPresence(d *schema.ResourceData, m interface{}) (string, er
// obtain Account ID by account name - it should not be zero on success // obtain Account ID by account name - it should not be zero on success
urlValues.Add("accountId", fmt.Sprintf("%d", d.Get("account_id").(int))) urlValues.Add("accountId", fmt.Sprintf("%d", d.Get("account_id").(int)))
diskFacts, err := controller.decortAPICall("POST", DisksListAPI, urlValues) diskFacts, err := c.DecortAPICall("POST", DisksListAPI, urlValues)
if err != nil { if err != nil {
return "", err return "", err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,13 +18,18 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package disks
import ( import (
"encoding/json" "encoding/json"
@ -30,14 +37,15 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityDiskListCheckPresence(d *schema.ResourceData, m interface{}) (DisksListResp, error) { func utilityDiskListCheckPresence(d *schema.ResourceData, m interface{}) (DisksListResp, error) {
diskList := DisksListResp{} diskList := DisksListResp{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if page, ok := d.GetOk("page"); ok { if page, ok := d.GetOk("page"); ok {
@ -54,7 +62,7 @@ func utilityDiskListCheckPresence(d *schema.ResourceData, m interface{}) (DisksL
} }
log.Debugf("utilityDiskListCheckPresence: load grid list") log.Debugf("utilityDiskListCheckPresence: load grid list")
diskListRaw, err := controller.decortAPICall("POST", DisksListAPI, urlValues) diskListRaw, err := c.DecortAPICall("POST", DisksListAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -0,0 +1,37 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package extnet
const extnetListAPI = "/restmachine/cloudapi/extnet/list"
const extnetListComputesAPI = "/restmachine/cloudapi/extnet/listComputes"
const extnetGetDefaultAPI = "/restmachine/cloudapi/extnet/getDefault"
const extnetGetAPI = "/restmachine/cloudapi/extnet/get"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,29 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/flattens"
) )
func dataSourceExtnetRead(d *schema.ResourceData, m interface{}) error { func dataSourceExtnetRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
e, err := utilityExtnetCheckPresence(d, m) e, err := utilityExtnetCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
d.Set("ckey", e.CKey) d.Set("ckey", e.CKey)
d.Set("meta", flattenMeta(e.Meta)) d.Set("meta", flattens.FlattenMeta(e.Meta))
d.Set("check__ips", e.CheckIPs) d.Set("check__ips", e.CheckIPs)
d.Set("check_ips", e.CheckIps) d.Set("check_ips", e.CheckIps)
d.Set("default", e.Default) d.Set("default", e.Default)
@ -305,15 +317,15 @@ func dataSourceExtnetSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceExtnet() *schema.Resource { func DataSourceExtnet() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceExtnetRead, ReadContext: dataSourceExtnetRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceExtnetSchemaMake(), Schema: dataSourceExtnetSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenExtnetsComputes(ecs ExtnetExtendList) []map[string]interface{} { func flattenExtnetsComputes(ecs ExtnetExtendList) []map[string]interface{} {
@ -60,10 +71,10 @@ func flattenExtnetComputesList(ecl ExtnetComputesList) []map[string]interface{}
return res return res
} }
func dataSourceExtnetComputesListRead(d *schema.ResourceData, m interface{}) error { func dataSourceExtnetComputesListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
extnetComputesList, err := utilityExtnetComputesListCheckPresence(d, m) extnetComputesList, err := utilityExtnetComputesListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -140,15 +151,15 @@ func dataSourceExtnetComputesListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceExtnetComputesList() *schema.Resource { func DataSourceExtnetComputesList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceExtnetComputesListRead, ReadContext: dataSourceExtnetComputesListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceExtnetComputesListSchemaMake(), Schema: dataSourceExtnetComputesListSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,32 +18,40 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"context"
"strconv" "strconv"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func dataSourceExtnetDefaultRead(d *schema.ResourceData, m interface{}) error { func dataSourceExtnetDefaultRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
extnetId, err := utilityExtnetDefaultCheckPresence(d, m) extnetId, err := utilityExtnetDefaultCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
d.SetId(id.String()) d.SetId(id.String())
extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32) extnetIdInt, err := strconv.ParseInt(extnetId, 10, 32)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.Set("net_id", extnetIdInt) d.Set("net_id", extnetIdInt)
@ -58,15 +68,15 @@ func dataSourceExtnetDefaultSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceExtnetDefault() *schema.Resource { func DataSourceExtnetDefault() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceExtnetDefaultRead, ReadContext: dataSourceExtnetDefaultRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceExtnetDefaultSchemaMake(), Schema: dataSourceExtnetDefaultSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,17 +18,26 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"context"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
) )
func flattenExtnetList(el ExtnetList) []map[string]interface{} { func flattenExtnetList(el ExtnetList) []map[string]interface{} {
@ -42,10 +53,10 @@ func flattenExtnetList(el ExtnetList) []map[string]interface{} {
return res return res
} }
func dataSourceExtnetListRead(d *schema.ResourceData, m interface{}) error { func dataSourceExtnetListRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
extnetList, err := utilityExtnetListCheckPresence(d, m) extnetList, err := utilityExtnetListCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
id := uuid.New() id := uuid.New()
@ -96,15 +107,15 @@ func dataSourceExtnetListSchemaMake() map[string]*schema.Schema {
return res return res
} }
func dataSourceExtnetList() *schema.Resource { func DataSourceExtnetList() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceExtnetListRead, ReadContext: dataSourceExtnetListRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: dataSourceExtnetListSchemaMake(), Schema: dataSourceExtnetListSchemaMake(),

@ -0,0 +1,111 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package extnet
type Extnet struct {
ID int `json:"id"`
IPCidr string `json:"ipcidr"`
Name string `json:"name"`
}
type ExtnetExtend struct {
Extnet
IPAddr string `json:"ipaddr"`
}
type ExtnetList []Extnet
type ExtnetExtendList []ExtnetExtend
type ExtnetComputes struct {
AccountId int `json:"accountId"`
AccountName string `json:"accountName"`
Extnets ExtnetExtendList `json:"extnets"`
ID int `json:"id"`
Name string `json:"name"`
RGID int `json:"rgId"`
RGName string `json:"rgName"`
}
type ExtnetComputesList []ExtnetComputes
type ExtnetQos struct {
ERate int `json:"eRate"`
GUID string `json:"guid"`
InBurst int `json:"inBurst"`
InRate int `json:"inRate"`
}
type ExtnetReservation struct {
ClientType string `json:"clientType"`
Desc string `json:"desc"`
DomainName string `json:"domainname"`
HostName string `json:"hostname"`
IP string `json:"ip"`
MAC string `json:"mac"`
Type string `json:"type"`
VMID int `json:"vmId"`
}
type ExtnetReservations []ExtnetReservation
type ExtnetVNFS struct {
DHCP int `json:"dhcp"`
}
type ExtnetDetailed struct {
CKey string `json:"_ckey"`
Meta []interface{} `json:"_meta"`
CheckIPs []string `json:"checkIPs"`
CheckIps []string `json:"checkIps"`
Default bool `json:"default"`
DefaultQos ExtnetQos `json:"defaultQos"`
Desc string `json:"desc"`
Dns []string `json:"dns"`
Excluded []string `json:"excluded"`
FreeIps int `json:"free_ips"`
Gateway string `json:"gateway"`
GID int `json:"gid"`
GUID int `json:"guid"`
ID int `json:"id"`
IPCidr string `json:"ipcidr"`
Milestones int `json:"milestones"`
Name string `json:"name"`
Network string `json:"network"`
NetworkId int `json:"networkId"`
PreReservationsNum int `json:"preReservationsNum"`
Prefix int `json:"prefix"`
PriVnfDevId int `json:"priVnfDevId"`
Reservations ExtnetReservations `json:"reservations"`
SharedWith []int `json:"sharedWith"`
Status string `json:"status"`
VlanID int `json:"vlanId"`
VNFS ExtnetVNFS `json:"vnfs"`
}

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityExtnetCheckPresence(d *schema.ResourceData, m interface{}) (*ExtnetDetailed, error) { func utilityExtnetCheckPresence(d *schema.ResourceData, m interface{}) (*ExtnetDetailed, error) {
extnet := &ExtnetDetailed{} extnet := &ExtnetDetailed{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("net_id", strconv.Itoa(d.Get("net_id").(int))) urlValues.Add("net_id", strconv.Itoa(d.Get("net_id").(int)))
log.Debugf("utilityExtnetCheckPresence") log.Debugf("utilityExtnetCheckPresence")
extnetRaw, err := controller.decortAPICall("POST", extnetGetAPI, urlValues) extnetRaw, err := c.DecortAPICall("POST", extnetGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,33 +18,39 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityExtnetComputesListCheckPresence(d *schema.ResourceData, m interface{}) (ExtnetComputesList, error) { func utilityExtnetComputesListCheckPresence(d *schema.ResourceData, m interface{}) (ExtnetComputesList, error) {
extnetComputesList := ExtnetComputesList{} extnetComputesList := ExtnetComputesList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int))) urlValues.Add("accountId", strconv.Itoa(d.Get("account_id").(int)))
log.Debugf("utilityExtnetComputesListCheckPresence") log.Debugf("utilityExtnetComputesListCheckPresence")
extnetComputesListRaw, err := controller.decortAPICall("POST", extnetListComputesAPI, urlValues) extnetComputesListRaw, err := c.DecortAPICall("POST", extnetListComputesAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,28 +18,34 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"net/url" "net/url"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityExtnetDefaultCheckPresence(_ *schema.ResourceData, m interface{}) (string, error) { func utilityExtnetDefaultCheckPresence(_ *schema.ResourceData, m interface{}) (string, error) {
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
log.Debugf("utilityExtnetDefaultCheckPresence") log.Debugf("utilityExtnetDefaultCheckPresence")
res, err := controller.decortAPICall("POST", extnetGetDefaultAPI, urlValues) res, err := c.DecortAPICall("POST", extnetGetDefaultAPI, urlValues)
if err != nil { if err != nil {
return "", err return "", err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package extnet
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func utilityExtnetListCheckPresence(d *schema.ResourceData, m interface{}) (ExtnetList, error) { func utilityExtnetListCheckPresence(d *schema.ResourceData, m interface{}) (ExtnetList, error) {
extnetList := ExtnetList{} extnetList := ExtnetList{}
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
if accountId, ok := d.GetOk("account_id"); ok { if accountId, ok := d.GetOk("account_id"); ok {
@ -50,7 +58,7 @@ func utilityExtnetListCheckPresence(d *schema.ResourceData, m interface{}) (Extn
} }
log.Debugf("utilityExtnetListCheckPresence") log.Debugf("utilityExtnetListCheckPresence")
extnetListRaw, err := controller.decortAPICall("POST", extnetListAPI, urlValues) extnetListRaw, err := c.DecortAPICall("POST", extnetListAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -0,0 +1,49 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package k8s
const K8sCreateAPI = "/restmachine/cloudapi/k8s/create"
const K8sGetAPI = "/restmachine/cloudapi/k8s/get"
const K8sUpdateAPI = "/restmachine/cloudapi/k8s/update"
const K8sDeleteAPI = "/restmachine/cloudapi/k8s/delete"
const K8sWgCreateAPI = "/restmachine/cloudapi/k8s/workersGroupAdd"
const K8sWgDeleteAPI = "/restmachine/cloudapi/k8s/workersGroupDelete"
const K8sWorkerAddAPI = "/restmachine/cloudapi/k8s/workerAdd"
const K8sWorkerDeleteAPI = "/restmachine/cloudapi/k8s/deleteWorkerFromGroup"
const K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
const LbGetAPI = "/restmachine/cloudapi/lb/get"
const AsyncTaskGetAPI = "/restmachine/cloudapi/tasks/get"

@ -0,0 +1,131 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package k8s
import (
"encoding/json"
"fmt"
"strconv"
)
type K8sNodeRecord struct {
ID int `json:"id"`
Name string `json:"name"`
Disk int `json:"disk"`
Cpu int `json:"cpu"`
Num int `json:"num"`
Ram int `json:"ram"`
DetailedInfo []struct {
ID int `json:"id"`
Name string `json:"name"`
} `json:"detailedInfo"`
}
//K8sRecord represents k8s instance
type K8sRecord struct {
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
CI int `json:"ciId"`
ID int `json:"id"`
Groups struct {
Masters K8sNodeRecord `json:"masters"`
Workers []K8sNodeRecord `json:"workers"`
} `json:"k8sGroups"`
LbID int `json:"lbId"`
Name string `json:"name"`
RgID int `json:"rgId"`
RgName string `json:"rgName"`
}
//LbRecord represents load balancer instance
type LbRecord struct {
ID int `json:"id"`
Name string `json:"name"`
RgID int `json:"rgId"`
VinsID int `json:"vinsId"`
ExtNetID int `json:"extnetId"`
PrimaryNode struct {
BackendIP string `json:"backendIp"`
ComputeID int `json:"computeId"`
FrontendIP string `json:"frontendIp"`
NetworkID int `json:"networkId"`
} `json:"primaryNode"`
}
//Blasphemous workaround for parsing Result value
type TaskResult int
func (r *TaskResult) UnmarshalJSON(b []byte) error {
if b[0] == '"' {
b := b[1 : len(b)-1]
if len(b) == 0 {
*r = 0
return nil
}
n, err := strconv.Atoi(string(b))
if err != nil {
return err
}
*r = TaskResult(n)
} else if b[0] == '[' {
res := []interface{}{}
if err := json.Unmarshal(b, &res); err != nil {
return err
}
if n, ok := res[0].(float64); ok {
*r = TaskResult(n)
} else {
return fmt.Errorf("could not unmarshal %v into int", res[0])
}
}
return nil
}
//AsyncTask represents a long task completion status
type AsyncTask struct {
AuditID string `json:"auditId"`
Completed bool `json:"completed"`
Error string `json:"error"`
Log []string `json:"log"`
Result TaskResult `json:"result"`
Stage string `json:"stage"`
Status string `json:"status"`
UpdateTime uint64 `json:"updateTime"`
UpdatedTime uint64 `json:"updatedTime"`
}
type SshKeyConfig struct {
User string
SshKey string
UserShell string
}

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,15 +18,20 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package k8s
import "github.com/hashicorp/terraform-plugin-sdk/helper/schema" import "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
func nodeMasterDefault() K8sNodeRecord { func nodeMasterDefault() K8sNodeRecord {
return K8sNodeRecord{ return K8sNodeRecord{

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,15 +18,21 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package k8s
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/url" "net/url"
@ -32,14 +40,17 @@ import (
"strings" "strings"
"time" "time"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourceK8sCreate(d *schema.ResourceData, m interface{}) error { func resourceK8sCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sCreate: called with name %s, rg %d", d.Get("name").(string), d.Get("rg_id").(int)) log.Debugf("resourceK8sCreate: called with name %s, rg %d", d.Get("name").(string), d.Get("rg_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("name", d.Get("name").(string)) urlValues.Add("name", d.Get("name").(string))
urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int))) urlValues.Add("rgId", strconv.Itoa(d.Get("rg_id").(int)))
@ -83,29 +94,29 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
//urlValues.Add("desc", desc.(string)) //urlValues.Add("desc", desc.(string))
//} //}
resp, err := controller.decortAPICall("POST", K8sCreateAPI, urlValues) resp, err := c.DecortAPICall("POST", K8sCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues = &url.Values{} urlValues = &url.Values{}
urlValues.Add("auditId", strings.Trim(resp, `"`)) urlValues.Add("auditId", strings.Trim(resp, `"`))
for { for {
resp, err := controller.decortAPICall("POST", AsyncTaskGetAPI, urlValues) resp, err := c.DecortAPICall("POST", AsyncTaskGetAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
task := AsyncTask{} task := AsyncTask{}
if err := json.Unmarshal([]byte(resp), &task); err != nil { if err := json.Unmarshal([]byte(resp), &task); err != nil {
return err return diag.FromErr(err)
} }
log.Debugf("resourceK8sCreate: instance creating - %s", task.Stage) log.Debugf("resourceK8sCreate: instance creating - %s", task.Stage)
if task.Completed { if task.Completed {
if task.Error != "" { if task.Error != "" {
return fmt.Errorf("cannot create k8s instance: %v", task.Error) return diag.FromErr(fmt.Errorf("cannot create k8s instance: %v", task.Error))
} }
d.SetId(strconv.Itoa(int(task.Result))) d.SetId(strconv.Itoa(int(task.Result)))
@ -117,7 +128,7 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
k8s, err := utilityK8sCheckPresence(d, m) k8s, err := utilityK8sCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.Set("default_wg_id", k8s.Groups.Workers[0].ID) d.Set("default_wg_id", k8s.Groups.Workers[0].ID)
@ -125,21 +136,21 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
urlValues = &url.Values{} urlValues = &url.Values{}
urlValues.Add("lbId", strconv.Itoa(k8s.LbID)) urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
resp, err = controller.decortAPICall("POST", LbGetAPI, urlValues) resp, err = c.DecortAPICall("POST", LbGetAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
var lb LbRecord var lb LbRecord
if err := json.Unmarshal([]byte(resp), &lb); err != nil { if err := json.Unmarshal([]byte(resp), &lb); err != nil {
return err return diag.FromErr(err)
} }
d.Set("extnet_id", lb.ExtNetID) d.Set("extnet_id", lb.ExtNetID)
d.Set("lb_ip", lb.PrimaryNode.FrontendIP) d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
urlValues = &url.Values{} urlValues = &url.Values{}
urlValues.Add("k8sId", d.Id()) urlValues.Add("k8sId", d.Id())
kubeconfig, err := controller.decortAPICall("POST", K8sGetConfigAPI, urlValues) kubeconfig, err := c.DecortAPICall("POST", K8sGetConfigAPI, urlValues)
if err != nil { if err != nil {
log.Warnf("could not get kubeconfig: %v", err) log.Warnf("could not get kubeconfig: %v", err)
} }
@ -148,13 +159,13 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceK8sRead(d *schema.ResourceData, m interface{}) error { func resourceK8sRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sRead: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int)) log.Debugf("resourceK8sRead: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
k8s, err := utilityK8sCheckPresence(d, m) k8s, err := utilityK8sCheckPresence(d, m)
if k8s == nil { if k8s == nil {
d.SetId("") d.SetId("")
return err return diag.FromErr(err)
} }
d.Set("name", k8s.Name) d.Set("name", k8s.Name)
@ -165,25 +176,25 @@ func resourceK8sRead(d *schema.ResourceData, m interface{}) error {
d.Set("workers", nodeToResource(k8s.Groups.Workers[0])) d.Set("workers", nodeToResource(k8s.Groups.Workers[0]))
d.Set("default_wg_id", k8s.Groups.Workers[0].ID) d.Set("default_wg_id", k8s.Groups.Workers[0].ID)
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(k8s.LbID)) urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
resp, err := controller.decortAPICall("POST", LbGetAPI, urlValues) resp, err := c.DecortAPICall("POST", LbGetAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
var lb LbRecord var lb LbRecord
if err := json.Unmarshal([]byte(resp), &lb); err != nil { if err := json.Unmarshal([]byte(resp), &lb); err != nil {
return err return diag.FromErr(err)
} }
d.Set("extnet_id", lb.ExtNetID) d.Set("extnet_id", lb.ExtNetID)
d.Set("lb_ip", lb.PrimaryNode.FrontendIP) d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
urlValues = &url.Values{} urlValues = &url.Values{}
urlValues.Add("k8sId", d.Id()) urlValues.Add("k8sId", d.Id())
kubeconfig, err := controller.decortAPICall("POST", K8sGetConfigAPI, urlValues) kubeconfig, err := c.DecortAPICall("POST", K8sGetConfigAPI, urlValues)
if err != nil { if err != nil {
log.Warnf("could not get kubeconfig: %v", err) log.Warnf("could not get kubeconfig: %v", err)
} }
@ -192,26 +203,26 @@ func resourceK8sRead(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceK8sUpdate(d *schema.ResourceData, m interface{}) error { func resourceK8sUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sUpdate: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int)) log.Debugf("resourceK8sUpdate: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
if d.HasChange("name") { if d.HasChange("name") {
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("k8sId", d.Id()) urlValues.Add("k8sId", d.Id())
urlValues.Add("name", d.Get("name").(string)) urlValues.Add("name", d.Get("name").(string))
_, err := controller.decortAPICall("POST", K8sUpdateAPI, urlValues) _, err := c.DecortAPICall("POST", K8sUpdateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
} }
if d.HasChange("workers") { if d.HasChange("workers") {
k8s, err := utilityK8sCheckPresence(d, m) k8s, err := utilityK8sCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
wg := k8s.Groups.Workers[0] wg := k8s.Groups.Workers[0]
@ -223,14 +234,14 @@ func resourceK8sUpdate(d *schema.ResourceData, m interface{}) error {
if newWorkers.Num > wg.Num { if newWorkers.Num > wg.Num {
urlValues.Add("num", strconv.Itoa(newWorkers.Num-wg.Num)) urlValues.Add("num", strconv.Itoa(newWorkers.Num-wg.Num))
if _, err := controller.decortAPICall("POST", K8sWorkerAddAPI, urlValues); err != nil { if _, err := c.DecortAPICall("POST", K8sWorkerAddAPI, urlValues); err != nil {
return err return diag.FromErr(err)
} }
} else { } else {
for i := wg.Num - 1; i >= newWorkers.Num; i-- { for i := wg.Num - 1; i >= newWorkers.Num; i-- {
urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID)) urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID))
if _, err := controller.decortAPICall("POST", K8sWorkerDeleteAPI, urlValues); err != nil { if _, err := c.DecortAPICall("POST", K8sWorkerDeleteAPI, urlValues); err != nil {
return err return diag.FromErr(err)
} }
} }
} }
@ -239,25 +250,25 @@ func resourceK8sUpdate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceK8sDelete(d *schema.ResourceData, m interface{}) error { func resourceK8sDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int)) log.Debugf("resourceK8sDelete: called with id %s, rg %d", d.Id(), d.Get("rg_id").(int))
k8s, err := utilityK8sCheckPresence(d, m) k8s, err := utilityK8sCheckPresence(d, m)
if k8s == nil { if k8s == nil {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("k8sId", d.Id()) urlValues.Add("k8sId", d.Id())
urlValues.Add("permanently", "true") urlValues.Add("permanently", "true")
_, err = controller.decortAPICall("POST", K8sDeleteAPI, urlValues) _, err = c.DecortAPICall("POST", K8sDeleteAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
@ -366,26 +377,26 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
} }
} }
func resourceK8s() *schema.Resource { func ResourceK8s() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceK8sCreate, CreateContext: resourceK8sCreate,
Read: resourceK8sRead, ReadContext: resourceK8sRead,
Update: resourceK8sUpdate, UpdateContext: resourceK8sUpdate,
Delete: resourceK8sDelete, DeleteContext: resourceK8sDelete,
Exists: resourceK8sExists, Exists: resourceK8sExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout20m, Create: &constants.Timeout20m,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout20m, Update: &constants.Timeout20m,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourceK8sSchemaMake(), Schema: resourceK8sSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,26 +18,35 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package k8s
import ( import (
"context"
"net/url" "net/url"
"strconv" "strconv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourceK8sWgCreate(d *schema.ResourceData, m interface{}) error { func resourceK8sWgCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sWgCreate: called with k8s id %d", d.Get("k8s_id").(int)) log.Debugf("resourceK8sWgCreate: called with k8s id %d", d.Get("k8s_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int))) urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
urlValues.Add("name", d.Get("name").(string)) urlValues.Add("name", d.Get("name").(string))
@ -44,9 +55,9 @@ func resourceK8sWgCreate(d *schema.ResourceData, m interface{}) error {
urlValues.Add("workerRam", strconv.Itoa(d.Get("ram").(int))) urlValues.Add("workerRam", strconv.Itoa(d.Get("ram").(int)))
urlValues.Add("workerDisk", strconv.Itoa(d.Get("disk").(int))) urlValues.Add("workerDisk", strconv.Itoa(d.Get("disk").(int)))
resp, err := controller.decortAPICall("POST", K8sWgCreateAPI, urlValues) resp, err := c.DecortAPICall("POST", K8sWgCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId(resp) d.SetId(resp)
@ -83,13 +94,13 @@ func resourceK8sWgCreate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceK8sWgRead(d *schema.ResourceData, m interface{}) error { func resourceK8sWgRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sWgRead: called with k8s id %d", d.Get("k8s_id").(int)) log.Debugf("resourceK8sWgRead: called with k8s id %d", d.Get("k8s_id").(int))
wg, err := utilityK8sWgCheckPresence(d, m) wg, err := utilityK8sWgCheckPresence(d, m)
if wg == nil { if wg == nil {
d.SetId("") d.SetId("")
return err return diag.FromErr(err)
} }
d.Set("name", wg.Name) d.Set("name", wg.Name)
@ -101,14 +112,14 @@ func resourceK8sWgRead(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceK8sWgUpdate(d *schema.ResourceData, m interface{}) error { func resourceK8sWgUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sWgUpdate: called with k8s id %d", d.Get("k8s_id").(int)) log.Debugf("resourceK8sWgUpdate: called with k8s id %d", d.Get("k8s_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
wg, err := utilityK8sWgCheckPresence(d, m) wg, err := utilityK8sWgCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
urlValues := &url.Values{} urlValues := &url.Values{}
@ -117,16 +128,16 @@ func resourceK8sWgUpdate(d *schema.ResourceData, m interface{}) error {
if newNum := d.Get("num").(int); newNum > wg.Num { if newNum := d.Get("num").(int); newNum > wg.Num {
urlValues.Add("num", strconv.Itoa(newNum-wg.Num)) urlValues.Add("num", strconv.Itoa(newNum-wg.Num))
_, err := controller.decortAPICall("POST", K8sWorkerAddAPI, urlValues) _, err := c.DecortAPICall("POST", K8sWorkerAddAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
} else { } else {
for i := wg.Num - 1; i >= newNum; i-- { for i := wg.Num - 1; i >= newNum; i-- {
urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID)) urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID))
_, err := controller.decortAPICall("POST", K8sWorkerDeleteAPI, urlValues) _, err := c.DecortAPICall("POST", K8sWorkerDeleteAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
} }
} }
@ -134,25 +145,25 @@ func resourceK8sWgUpdate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceK8sWgDelete(d *schema.ResourceData, m interface{}) error { func resourceK8sWgDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceK8sWgDelete: called with k8s id %d", d.Get("k8s_id").(int)) log.Debugf("resourceK8sWgDelete: called with k8s id %d", d.Get("k8s_id").(int))
wg, err := utilityK8sWgCheckPresence(d, m) wg, err := utilityK8sWgCheckPresence(d, m)
if wg == nil { if wg == nil {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int))) urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
urlValues.Add("workersGroupId", strconv.Itoa(wg.ID)) urlValues.Add("workersGroupId", strconv.Itoa(wg.ID))
_, err = controller.decortAPICall("POST", K8sWgDeleteAPI, urlValues) _, err = c.DecortAPICall("POST", K8sWgDeleteAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
@ -221,26 +232,26 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
} }
} }
func resourceK8sWg() *schema.Resource { func ResourceK8sWg() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceK8sWgCreate, CreateContext: resourceK8sWgCreate,
Read: resourceK8sWgRead, ReadContext: resourceK8sWgRead,
Update: resourceK8sWgUpdate, UpdateContext: resourceK8sWgUpdate,
Delete: resourceK8sWgDelete, DeleteContext: resourceK8sWgDelete,
Exists: resourceK8sWgExists, Exists: resourceK8sWgExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout20m, Create: &constants.Timeout20m,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout20m, Update: &constants.Timeout20m,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourceK8sWgSchemaMake(), Schema: resourceK8sWgSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,27 +18,33 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package k8s
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
) )
func utilityK8sCheckPresence(d *schema.ResourceData, m interface{}) (*K8sRecord, error) { func utilityK8sCheckPresence(d *schema.ResourceData, m interface{}) (*K8sRecord, error) {
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("k8sId", d.Id()) urlValues.Add("k8sId", d.Id())
resp, err := controller.decortAPICall("POST", K8sGetAPI, urlValues) resp, err := c.DecortAPICall("POST", K8sGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,28 +18,34 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package k8s
import ( import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"strconv" "strconv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
) )
func utilityK8sWgCheckPresence(d *schema.ResourceData, m interface{}) (*K8sNodeRecord, error) { func utilityK8sWgCheckPresence(d *schema.ResourceData, m interface{}) (*K8sNodeRecord, error) {
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int))) urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
resp, err := controller.decortAPICall("POST", K8sGetAPI, urlValues) resp, err := c.DecortAPICall("POST", K8sGetAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -0,0 +1,46 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package kvmvm
const KvmX86CreateAPI = "/restmachine/cloudapi/kvmx86/create"
const KvmPPCCreateAPI = "/restmachine/cloudapi/kvmppc/create"
const ComputeGetAPI = "/restmachine/cloudapi/compute/get"
const RgListComputesAPI = "/restmachine/cloudapi/rg/listComputes"
const ComputeNetAttachAPI = "/restmachine/cloudapi/compute/netAttach"
const ComputeNetDetachAPI = "/restmachine/cloudapi/compute/netDetach"
const ComputeDiskAttachAPI = "/restmachine/cloudapi/compute/diskAttach"
const ComputeDiskDetachAPI = "/restmachine/cloudapi/compute/diskDetach"
const ComputeStartAPI = "/restmachine/cloudapi/compute/start"
const ComputeStopAPI = "/restmachine/cloudapi/compute/stop"
const ComputeResizeAPI = "/restmachine/cloudapi/compute/resize"
const DisksResizeAPI = "/restmachine/cloudapi/disks/resize2"
const ComputeDeleteAPI = "/restmachine/cloudapi/compute/delete"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,24 +18,31 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package kvmvm
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
// "net/url" // "net/url"
"github.com/rudecs/terraform-provider-decort/internal/constants"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
// Parse list of all disks from API compute/get into a list of "extra disks" attached to this compute // Parse list of all disks from API compute/get into a list of "extra disks" attached to this compute
@ -186,27 +195,27 @@ func flattenCompute(d *schema.ResourceData, compFacts string) error {
return nil return nil
} }
func dataSourceComputeRead(d *schema.ResourceData, m interface{}) error { func dataSourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
compFacts, err := utilityComputeCheckPresence(d, m) compFacts, err := utilityComputeCheckPresence(d, m)
if compFacts == "" { if compFacts == "" {
// if empty string is returned from utilityComputeCheckPresence then there is no // if empty string is returned from utilityComputeCheckPresence then there is no
// such Compute and err tells so - just return it to the calling party // such Compute and err tells so - just return it to the calling party
d.SetId("") // ensure ID is empty d.SetId("") // ensure ID is empty
return err return diag.FromErr(err)
} }
return flattenCompute(d, compFacts) return diag.FromErr(flattenCompute(d, compFacts))
} }
func dataSourceCompute() *schema.Resource { func dataSourceCompute() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceComputeRead, ReadContext: dataSourceComputeRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
@ -293,7 +302,7 @@ func dataSourceCompute() *schema.Resource {
"extra_disks": { "extra_disks": {
Type: schema.TypeSet, Type: schema.TypeSet,
Computed: true, Computed: true,
MaxItems: MaxExtraDisksPerCompute, MaxItems: constants.MaxExtraDisksPerCompute,
Elem: &schema.Schema{ Elem: &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
}, },
@ -314,7 +323,7 @@ func dataSourceCompute() *schema.Resource {
"network": { "network": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
MaxItems: MaxNetworksPerCompute, MaxItems: constants.MaxNetworksPerCompute,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: networkSubresourceSchemaMake(), Schema: networkSubresourceSchemaMake(),
}, },

@ -0,0 +1,190 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package kvmvm
type DiskRecord struct {
Acl map[string]interface{} `json:"acl"`
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
BootPartition int `json:"bootPartition"`
CreatedTime uint64 `json:"creationTime"`
ComputeID int `json:"computeId"`
ComputeName string `json:"computeName"`
DeletedTime uint64 `json:"deletionTime"`
DeviceName string `json:"devicename"`
Desc string `json:"desc"`
DestructionTime uint64 `json:"destructionTime"`
DiskPath string `json:"diskPath"`
GridID int `json:"gid"`
GUID int `json:"guid"`
ID uint `json:"id"`
ImageID int `json:"imageId"`
Images []int `json:"images"`
IOTune map[string]interface{} `json:"iotune"`
IQN string `json:"iqn"`
Login string `json:"login"`
Name string `json:"name"`
MachineId int `json:"machineId"`
MachineName string `json:"machineName"`
Milestones uint64 `json:"milestones"`
Order int `json:"order"`
Params string `json:"params"`
Passwd string `json:"passwd"`
ParentId int `json:"parentId"`
PciSlot int `json:"pciSlot"`
Pool string `json:"pool"`
PurgeTime uint64 `json:"purgeTime"`
PurgeAttempts uint64 `json:"purgeAttempts"`
RealityDeviceNumber int `json:"realityDeviceNumber"`
ReferenceId string `json:"referenceId"`
ResID string `json:"resId"`
ResName string `json:"resName"`
Role string `json:"role"`
SepType string `json:"sepType"`
SepID int `json:"sepId"` // NOTE: absent from compute/get output
SizeMax int `json:"sizeMax"`
SizeUsed int `json:"sizeUsed"` // sum over all snapshots of this disk to report total consumed space
Snapshots []SnapshotRecord `json:"snapshots"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
Type string `json:"type"`
UpdateBy uint64 `json:"updateBy"`
VMID int `json:"vmid"`
}
type InterfaceRecord struct {
ConnID int `json:"connId"` // This is VLAN ID or VxLAN ID, depending on ConnType
ConnType string `json:"connType"` // Either "VLAN" or "VXLAN" tag
DefaultGW string `json:"defGw"`
Guid string `json:"guid"`
IPAddress string `json:"ipAddress"` // without trailing network mask, i.e. "192.168.1.3"
MAC string `json:"mac"`
Name string `json:"name"`
NetID int `json:"netId"` // This is either ExtNet ID or ViNS ID, depending on NetType
NetMask int `json:"netMask"`
NetType string `json:"netType"` // Either "EXTNET" or "VINS" tag
PciSlot int `json:"pciSlot"`
Target string `json:"target"`
Type string `json:"type"`
VNFs []int `json:"vnfs"`
QOS InterfaceQosRecord `json:"qos"`
}
type InterfaceQosRecord struct {
ERate int `json:"eRate"`
Guid string `json:"guid"`
InBurst int `json:"inBurst"`
InRate int `json:"inRate"`
}
type SnapshotRecord struct {
Guid string `json:"guid"`
Label string `json:"label"`
ResId string `json:"resId"`
SnapSetGuid string `json:"snapSetGuid"`
SnapSetTime uint64 `json:"snapSetTime"`
TimeStamp uint64 `json:"timestamp"`
}
type SnapshotRecordList []SnapshotRecord
type ComputeGetResp struct {
// ACLs `json:"ACL"` - it is a dictionary, special parsing required
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
Arch string `json:"arch"`
BootDiskSize int `json:"bootdiskSize"`
CloneReference int `json:"cloneReference"`
Clones []int `json:"clones"`
Cpu int `json:"cpus"`
Desc string `json:"desc"`
Disks []DiskRecord `json:"disks"`
Driver string `json:"driver"`
GridID int `json:"gid"`
ID uint `json:"id"`
ImageID int `json:"imageId"`
ImageName string `json:"imageName"`
Interfaces []InterfaceRecord `json:"interfaces"`
LockStatus string `json:"lockStatus"`
ManagerID int `json:"managerId"`
ManagerType string `json:"manageType"`
Name string `json:"name"`
NatableVinsID int `json:"natableVinsId"`
NatableVinsIP string `json:"natableVinsIp"`
NatableVinsName string `json:"natableVinsName"`
NatableVinsNet string `json:"natableVinsNetwork"`
NatableVinsNetName string `json:"natableVinsNetworkName"`
OsUsers []OsUserRecord `json:"osUsers"`
Ram int `json:"ram"`
RgID int `json:"rgId"`
RgName string `json:"rgName"`
SnapSets []SnapSetRecord `json:"snapSets"`
Status string `json:"status"`
// Tags []string `json:"tags"` // Tags were reworked since DECORT 3.7.1
TechStatus string `json:"techStatus"`
TotalDiskSize int `json:"totalDiskSize"`
UpdatedBy string `json:"updatedBy"`
UpdateTime uint64 `json:"updateTime"`
UserManaged bool `json:"userManaged"`
Vgpus []int `json:"vgpus"`
VinsConnected int `json:"vinsConnected"`
VirtualImageID int `json:"virtualImageId"`
}
type OsUserRecord struct {
Guid string `json:"guid"`
Login string `json:"login"`
Password string `json:"password"`
PubKey string `json:"pubkey"`
}
type SnapSetRecord struct {
Disks []int `json:"disks"`
Guid string `json:"guid"`
Label string `json:"label"`
TimeStamp uint64 `json:"timestamp"`
}
type ComputeBriefRecord struct { // this is a brief compute specifiaction as returned by API rg/listComputes
// we do not even include here all fields as returned by this API, but only the most important that
// are really necessary to identify and distinguish computes
AccountID int `json:"accountId"`
AccountName string `json:"accountName"`
Name string `json:"name"`
ID uint `json:"id"`
RgID int `json:"rgId"`
RgName string `json:"rgName"`
Status string `json:"status"`
TechStatus string `json:"techStatus"`
}
type RgListComputesResp []ComputeBriefRecord

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,23 +17,31 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package decort /*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
import ( Source code: https://github.com/rudecs/terraform-provider-decort
// "encoding/json" Please see README.md to learn where to place source code so that it
// "fmt" builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package kvmvm
import (
"bytes" "bytes"
"hash/fnv" "hash/fnv"
"github.com/rudecs/terraform-provider-decort/internal/provider"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
// "net/url"
"sort" "sort"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
// "github.com/hashicorp/terraform-plugin-sdk/v2/internal/helper/hashcode"
) )
// This is subresource of compute resource used when creating/managing compute network connections // This is subresource of compute resource used when creating/managing compute network connections
@ -115,7 +125,7 @@ func networkSubresourceSchemaMake() map[string]*schema.Schema {
"net_type": { "net_type": {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
StateFunc: stateFuncToUpper, StateFunc: provider.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, false), // observe case while validating ValidateFunc: validation.StringInSlice([]string{"EXTNET", "VINS"}, false), // observe case while validating
Description: "Type of the network for this connection, either EXTNET or VINS.", Description: "Type of the network for this connection, either EXTNET or VINS.",
}, },

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -15,13 +17,24 @@ See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
*/ */
package decort /*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package kvmvm
import ( import (
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
) )
func parseOsUsers(logins []OsUserRecord) []interface{} { func parseOsUsers(logins []OsUserRecord) []interface{} {

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,24 +18,34 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package kvmvm
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
"github.com/rudecs/terraform-provider-decort/internal/provider"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
) )
func cloudInitDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool { func cloudInitDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) bool {
@ -49,7 +61,7 @@ func cloudInitDiffSupperss(key, oldVal, newVal string, d *schema.ResourceData) b
return true // suppress difference return true // suppress difference
} }
func resourceComputeCreate(d *schema.ResourceData, m interface{}) error { func resourceComputeCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// we assume all mandatory parameters it takes to create a comptue instance are properly // we assume all mandatory parameters it takes to create a comptue instance are properly
// specified - we rely on schema "Required" attributes to let Terraform validate them for us // specified - we rely on schema "Required" attributes to let Terraform validate them for us
@ -57,9 +69,7 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
// create basic Compute (i.e. without extra disks and network connections - those will be attached // create basic Compute (i.e. without extra disks and network connections - those will be attached
// by subsequent individual API calls). // by subsequent individual API calls).
// creating Compute is a multi-step workflow, which may fail at some step, so we use "partial" feature of Terraform c := m.(*controller.ControllerCfg)
d.Partial(true)
controller := m.(*ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("rgId", fmt.Sprintf("%d", d.Get("rg_id").(int))) urlValues.Add("rgId", fmt.Sprintf("%d", d.Get("rg_id").(int)))
urlValues.Add("name", d.Get("name").(string)) urlValues.Add("name", d.Get("name").(string))
@ -102,25 +112,14 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
} }
} }
apiResp, err := controller.decortAPICall("POST", computeCreateAPI, urlValues) apiResp, err := c.DecortAPICall("POST", computeCreateAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
// Compute create API returns ID of the new Compute instance on success // Compute create API returns ID of the new Compute instance on success
d.SetId(apiResp) // update ID of the resource to tell Terraform that the resource exists, albeit partially d.SetId(apiResp) // update ID of the resource to tell Terraform that the resource exists, albeit partially
compId, _ := strconv.Atoi(apiResp) compId, _ := strconv.Atoi(apiResp)
d.SetPartial("name")
d.SetPartial("description")
d.SetPartial("cpu")
d.SetPartial("ram")
d.SetPartial("image_id")
d.SetPartial("boot_disk_size")
/*
if sshKeysSet {
d.SetPartial("ssh_keys")
}
*/
log.Debugf("resourceComputeCreate: new simple Compute ID %d, name %s created", compId, d.Get("name").(string)) log.Debugf("resourceComputeCreate: new simple Compute ID %d, name %s created", compId, d.Get("name").(string))
@ -130,7 +129,7 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
if argSet && argVal.(*schema.Set).Len() > 0 { if argSet && argVal.(*schema.Set).Len() > 0 {
// urlValues.Add("desc", argVal.(string)) // urlValues.Add("desc", argVal.(string))
log.Debugf("resourceComputeCreate: calling utilityComputeExtraDisksConfigure to attach %d extra disk(s)", argVal.(*schema.Set).Len()) log.Debugf("resourceComputeCreate: calling utilityComputeExtraDisksConfigure to attach %d extra disk(s)", argVal.(*schema.Set).Len())
err = controller.utilityComputeExtraDisksConfigure(d, false) // do_delta=false, as we are working on a new compute err = utilityComputeExtraDisksConfigure(d, m, false) // do_delta=false, as we are working on a new compute
if err != nil { if err != nil {
log.Errorf("resourceComputeCreate: error when attaching extra disk(s) to a new Compute ID %d: %v", compId, err) log.Errorf("resourceComputeCreate: error when attaching extra disk(s) to a new Compute ID %d: %v", compId, err)
extraDisksOk = false extraDisksOk = false
@ -145,7 +144,7 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
argVal, argSet = d.GetOk("network") argVal, argSet = d.GetOk("network")
if argSet && argVal.(*schema.Set).Len() > 0 { if argSet && argVal.(*schema.Set).Len() > 0 {
log.Debugf("resourceComputeCreate: calling utilityComputeNetworksConfigure to attach %d network(s)", argVal.(*schema.Set).Len()) log.Debugf("resourceComputeCreate: calling utilityComputeNetworksConfigure to attach %d network(s)", argVal.(*schema.Set).Len())
err = controller.utilityComputeNetworksConfigure(d, false) // do_delta=false, as we are working on a new compute err = utilityComputeNetworksConfigure(d, m, false) // do_delta=false, as we are working on a new compute
if err != nil { if err != nil {
log.Errorf("resourceComputeCreate: error when attaching networks to a new Compute ID %d: %s", compId, err) log.Errorf("resourceComputeCreate: error when attaching networks to a new Compute ID %d: %s", compId, err)
netsOk = false netsOk = false
@ -167,8 +166,8 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
reqValues := &url.Values{} reqValues := &url.Values{}
reqValues.Add("computeId", fmt.Sprintf("%d", compId)) reqValues.Add("computeId", fmt.Sprintf("%d", compId))
log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", compId) log.Debugf("resourceComputeCreate: starting Compute ID %d after completing its resource configuration", compId)
if _, err := controller.decortAPICall("POST", ComputeStartAPI, reqValues); err != nil { if _, err := c.DecortAPICall("POST", ComputeStartAPI, reqValues); err != nil {
return err return diag.FromErr(err)
} }
} }
@ -178,24 +177,24 @@ func resourceComputeCreate(d *schema.ResourceData, m interface{}) error {
// between Compute resource and Compute data source schemas // between Compute resource and Compute data source schemas
// Compute read function will also update resource ID on success, so that Terraform // Compute read function will also update resource ID on success, so that Terraform
// will know the resource exists // will know the resource exists
return dataSourceComputeRead(d, m) return dataSourceComputeRead(ctx, d, m)
} }
func resourceComputeRead(d *schema.ResourceData, m interface{}) error { func resourceComputeRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d", log.Debugf("resourceComputeRead: called for Compute name %s, RG ID %d",
d.Get("name").(string), d.Get("rg_id").(int)) d.Get("name").(string), d.Get("rg_id").(int))
compFacts, err := utilityComputeCheckPresence(d, m) compFacts, err := utilityComputeCheckPresence(d, m)
if compFacts == "" { if compFacts == "" {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
// Compute with such name and RG ID was not found // Compute with such name and RG ID was not found
return nil return nil
} }
if err = flattenCompute(d, compFacts); err != nil { if err = flattenCompute(d, compFacts); err != nil {
return err return diag.FromErr(err)
} }
log.Debugf("resourceComputeRead: after flattenCompute: Compute ID %s, name %q, RG ID %d", log.Debugf("resourceComputeRead: after flattenCompute: Compute ID %s, name %q, RG ID %d",
@ -204,11 +203,11 @@ func resourceComputeRead(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourceComputeUpdate(d *schema.ResourceData, m interface{}) error { func resourceComputeUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourceComputeUpdate: called for Compute ID %s / name %s, RGID %d", log.Debugf("resourceComputeUpdate: called for Compute ID %s / name %s, RGID %d",
d.Id(), d.Get("name").(string), d.Get("rg_id").(int)) d.Id(), d.Get("name").(string), d.Get("rg_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
/* /*
1. Resize CPU/RAM 1. Resize CPU/RAM
@ -246,10 +245,11 @@ func resourceComputeUpdate(d *schema.ResourceData, m interface{}) error {
oldCpu.(int), newCpu.(int), oldCpu.(int), newCpu.(int),
oldRam.(int), newRam.(int)) oldRam.(int), newRam.(int))
params.Add("force", "true") params.Add("force", "true")
_, err := controller.decortAPICall("POST", ComputeResizeAPI, params) _, err := c.DecortAPICall("POST", ComputeResizeAPI, params)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetPartial("cpu") d.SetPartial("cpu")
d.SetPartial("ram") d.SetPartial("ram")
} }
@ -262,9 +262,9 @@ func resourceComputeUpdate(d *schema.ResourceData, m interface{}) error {
bdsParams.Add("size", fmt.Sprintf("%d", newSize.(int))) bdsParams.Add("size", fmt.Sprintf("%d", newSize.(int)))
log.Debugf("resourceComputeUpdate: compute ID %s, boot disk ID %d resize %d -> %d", log.Debugf("resourceComputeUpdate: compute ID %s, boot disk ID %d resize %d -> %d",
d.Id(), d.Get("boot_disk_id").(int), oldSize.(int), newSize.(int)) d.Id(), d.Get("boot_disk_id").(int), oldSize.(int), newSize.(int))
_, err := controller.decortAPICall("POST", DisksResizeAPI, bdsParams) _, err := c.DecortAPICall("POST", DisksResizeAPI, bdsParams)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetPartial("boot_disk_size") d.SetPartial("boot_disk_size")
} else if oldSize.(int) > newSize.(int) { } else if oldSize.(int) > newSize.(int) {
@ -272,44 +272,37 @@ func resourceComputeUpdate(d *schema.ResourceData, m interface{}) error {
} }
// 3. Calculate and apply changes to data disks // 3. Calculate and apply changes to data disks
err := controller.utilityComputeExtraDisksConfigure(d, true) // pass do_delta = true to apply changes, if any err := utilityComputeExtraDisksConfigure(d, m, true) // pass do_delta = true to apply changes, if any
if err != nil { if err != nil {
return err return diag.FromErr(err)
} else {
d.SetPartial("extra_disks")
} }
// 4. Calculate and apply changes to network connections // 4. Calculate and apply changes to network connections
err = controller.utilityComputeNetworksConfigure(d, true) // pass do_delta = true to apply changes, if any err = utilityComputeNetworksConfigure(d, m, true) // pass do_delta = true to apply changes, if any
if err != nil { if err != nil {
return err return diag.FromErr(err)
} else {
d.SetPartial("network")
} }
if d.HasChange("started") { if d.HasChange("started") {
params := &url.Values{} params := &url.Values{}
params.Add("computeId", d.Id()) params.Add("computeId", d.Id())
if d.Get("started").(bool) { if d.Get("started").(bool) {
if _, err := controller.decortAPICall("POST", ComputeStartAPI, params); err != nil { if _, err := c.DecortAPICall("POST", ComputeStartAPI, params); err != nil {
return err return diag.FromErr(err)
} }
} else { } else {
if _, err := controller.decortAPICall("POST", ComputeStopAPI, params); err != nil { if _, err := c.DecortAPICall("POST", ComputeStopAPI, params); err != nil {
return err return diag.FromErr(err)
} }
} }
d.SetPartial("started")
} }
d.Partial(false)
// we may reuse dataSourceComputeRead here as we maintain similarity // we may reuse dataSourceComputeRead here as we maintain similarity
// between Compute resource and Compute data source schemas // between Compute resource and Compute data source schemas
return dataSourceComputeRead(d, m) return dataSourceComputeRead(ctx, d, m)
} }
func resourceComputeDelete(d *schema.ResourceData, m interface{}) error { func resourceComputeDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
// NOTE: this function destroys target Compute instance "permanently", so // NOTE: this function destroys target Compute instance "permanently", so
// there is no way to restore it. // there is no way to restore it.
// If compute being destroyed has some extra disks attached, they are // If compute being destroyed has some extra disks attached, they are
@ -320,14 +313,14 @@ func resourceComputeDelete(d *schema.ResourceData, m interface{}) error {
compFacts, err := utilityComputeCheckPresence(d, m) compFacts, err := utilityComputeCheckPresence(d, m)
if compFacts == "" { if compFacts == "" {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
// the target Compute does not exist - in this case according to Terraform best practice // the target Compute does not exist - in this case according to Terraform best practice
// we exit from Destroy method without error // we exit from Destroy method without error
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
model := ComputeGetResp{} model := ComputeGetResp{}
log.Debugf("resourceComputeDelete: ready to unmarshal string %s", compFacts) log.Debugf("resourceComputeDelete: ready to unmarshal string %s", compFacts)
@ -347,7 +340,7 @@ func resourceComputeDelete(d *schema.ResourceData, m interface{}) error {
detachParams.Add("computeId", d.Id()) detachParams.Add("computeId", d.Id())
detachParams.Add("diskId", fmt.Sprintf("%d", diskFacts.ID)) detachParams.Add("diskId", fmt.Sprintf("%d", diskFacts.ID))
_, err = controller.decortAPICall("POST", ComputeDiskDetachAPI, detachParams) _, err = c.DecortAPICall("POST", ComputeDiskDetachAPI, detachParams)
if err != nil { if err != nil {
// We do not fail compute deletion on data disk detach errors // We do not fail compute deletion on data disk detach errors
log.Errorf("resourceComputeDelete: error when detaching Disk ID %d: %s", diskFacts.ID, err) log.Errorf("resourceComputeDelete: error when detaching Disk ID %d: %s", diskFacts.ID, err)
@ -360,9 +353,9 @@ func resourceComputeDelete(d *schema.ResourceData, m interface{}) error {
params.Add("permanently", "1") params.Add("permanently", "1")
// TODO: this is for the upcoming API update - params.Add("detachdisks", "1") // TODO: this is for the upcoming API update - params.Add("detachdisks", "1")
_, err = controller.decortAPICall("POST", ComputeDeleteAPI, params) _, err = c.DecortAPICall("POST", ComputeDeleteAPI, params)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
@ -383,26 +376,26 @@ func resourceComputeExists(d *schema.ResourceData, m interface{}) (bool, error)
return true, nil return true, nil
} }
func resourceCompute() *schema.Resource { func ResourceCompute() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourceComputeCreate, CreateContext: resourceComputeCreate,
Read: resourceComputeRead, ReadContext: resourceComputeRead,
Update: resourceComputeUpdate, UpdateContext: resourceComputeUpdate,
Delete: resourceComputeDelete, DeleteContext: resourceComputeDelete,
Exists: resourceComputeExists, Exists: resourceComputeExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout180s, Create: &constants.Timeout180s,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout180s, Update: &constants.Timeout180s,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
@ -423,7 +416,7 @@ func resourceCompute() *schema.Resource {
Type: schema.TypeString, Type: schema.TypeString,
Required: true, Required: true,
ForceNew: true, ForceNew: true,
StateFunc: stateFuncToUpper, StateFunc: provider.StateFuncToUpper,
ValidateFunc: validation.StringInSlice([]string{"KVM_X86", "KVM_PPC"}, false), // observe case while validating ValidateFunc: validation.StringInSlice([]string{"KVM_X86", "KVM_PPC"}, false), // observe case while validating
Description: "Hardware architecture of this compute instance.", Description: "Hardware architecture of this compute instance.",
}, },
@ -431,14 +424,14 @@ func resourceCompute() *schema.Resource {
"cpu": { "cpu": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ValidateFunc: validation.IntBetween(1, MaxCpusPerCompute), ValidateFunc: validation.IntBetween(1, constants.MaxCpusPerCompute),
Description: "Number of CPUs to allocate to this compute instance.", Description: "Number of CPUs to allocate to this compute instance.",
}, },
"ram": { "ram": {
Type: schema.TypeInt, Type: schema.TypeInt,
Required: true, Required: true,
ValidateFunc: validation.IntAtLeast(MinRamPerCompute), ValidateFunc: validation.IntAtLeast(constants.MinRamPerCompute),
Description: "Amount of RAM in MB to allocate to this compute instance.", Description: "Amount of RAM in MB to allocate to this compute instance.",
}, },
@ -459,7 +452,7 @@ func resourceCompute() *schema.Resource {
"extra_disks": { "extra_disks": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
MaxItems: MaxExtraDisksPerCompute, MaxItems: constants.MaxExtraDisksPerCompute,
Elem: &schema.Schema{ Elem: &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
}, },
@ -469,7 +462,7 @@ func resourceCompute() *schema.Resource {
"network": { "network": {
Type: schema.TypeSet, Type: schema.TypeSet,
Optional: true, Optional: true,
MaxItems: MaxNetworksPerCompute, MaxItems: constants.MaxNetworksPerCompute,
Elem: &schema.Resource{ Elem: &schema.Resource{
Schema: networkSubresourceSchemaMake(), Schema: networkSubresourceSchemaMake(),
}, },

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,13 +18,18 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package kvmvm
import ( import (
"encoding/json" "encoding/json"
@ -30,13 +37,13 @@ import (
"net/url" "net/url"
"strconv" "strconv"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation"
) )
func (ctrl *ControllerCfg) utilityComputeExtraDisksConfigure(d *schema.ResourceData, do_delta bool) error { func utilityComputeExtraDisksConfigure(d *schema.ResourceData, m interface{}, do_delta bool) error {
// d is filled with data according to computeResource schema, so extra disks config is retrieved via "extra_disks" key // d is filled with data according to computeResource schema, so extra disks config is retrieved via "extra_disks" key
// If do_delta is true, this function will identify changes between new and existing specs for extra disks and try to // If do_delta is true, this function will identify changes between new and existing specs for extra disks and try to
// update compute configuration accordingly // update compute configuration accordingly
@ -45,6 +52,8 @@ func (ctrl *ControllerCfg) utilityComputeExtraDisksConfigure(d *schema.ResourceD
// Note that this function will not abort on API errors, but will continue to configure (attach / detach) other individual // Note that this function will not abort on API errors, but will continue to configure (attach / detach) other individual
// disks via atomic API calls. However, it will not retry failed manipulation on the same disk. // disks via atomic API calls. However, it will not retry failed manipulation on the same disk.
c := m.(*controller.ControllerCfg)
log.Debugf("utilityComputeExtraDisksConfigure: called for Compute ID %s with do_delta = %t", d.Id(), do_delta) log.Debugf("utilityComputeExtraDisksConfigure: called for Compute ID %s with do_delta = %t", d.Id(), do_delta)
// NB: as of rc-1.25 "extra_disks" are TypeSet with the elem of TypeInt // NB: as of rc-1.25 "extra_disks" are TypeSet with the elem of TypeInt
@ -62,7 +71,7 @@ func (ctrl *ControllerCfg) utilityComputeExtraDisksConfigure(d *schema.ResourceD
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("computeId", d.Id()) urlValues.Add("computeId", d.Id())
urlValues.Add("diskId", fmt.Sprintf("%d", disk.(int))) urlValues.Add("diskId", fmt.Sprintf("%d", disk.(int)))
_, err := ctrl.decortAPICall("POST", ComputeDiskAttachAPI, urlValues) _, err := c.DecortAPICall("POST", ComputeDiskAttachAPI, urlValues)
if err != nil { if err != nil {
// failed to attach extra disk - partial resource update // failed to attach extra disk - partial resource update
apiErrCount++ apiErrCount++
@ -85,7 +94,7 @@ func (ctrl *ControllerCfg) utilityComputeExtraDisksConfigure(d *schema.ResourceD
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("computeId", d.Id()) urlValues.Add("computeId", d.Id())
urlValues.Add("diskId", fmt.Sprintf("%d", diskId.(int))) urlValues.Add("diskId", fmt.Sprintf("%d", diskId.(int)))
_, err := ctrl.decortAPICall("POST", ComputeDiskDetachAPI, urlValues) _, err := c.DecortAPICall("POST", ComputeDiskDetachAPI, urlValues)
if err != nil { if err != nil {
// failed to detach disk - there will be partial resource update // failed to detach disk - there will be partial resource update
log.Errorf("utilityComputeExtraDisksConfigure: failed to detach disk ID %d from Compute ID %s: %s", diskId.(int), d.Id(), err) log.Errorf("utilityComputeExtraDisksConfigure: failed to detach disk ID %d from Compute ID %s: %s", diskId.(int), d.Id(), err)
@ -100,7 +109,7 @@ func (ctrl *ControllerCfg) utilityComputeExtraDisksConfigure(d *schema.ResourceD
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("computeId", d.Id()) urlValues.Add("computeId", d.Id())
urlValues.Add("diskId", fmt.Sprintf("%d", diskId.(int))) urlValues.Add("diskId", fmt.Sprintf("%d", diskId.(int)))
_, err := ctrl.decortAPICall("POST", ComputeDiskAttachAPI, urlValues) _, err := c.DecortAPICall("POST", ComputeDiskAttachAPI, urlValues)
if err != nil { if err != nil {
// failed to attach disk - there will be partial resource update // failed to attach disk - there will be partial resource update
log.Errorf("utilityComputeExtraDisksConfigure: failed to attach disk ID %d to Compute ID %s: %s", diskId.(int), d.Id(), err) log.Errorf("utilityComputeExtraDisksConfigure: failed to attach disk ID %d to Compute ID %s: %s", diskId.(int), d.Id(), err)
@ -118,13 +127,15 @@ func (ctrl *ControllerCfg) utilityComputeExtraDisksConfigure(d *schema.ResourceD
return nil return nil
} }
func (ctrl *ControllerCfg) utilityComputeNetworksConfigure(d *schema.ResourceData, do_delta bool) error { func utilityComputeNetworksConfigure(d *schema.ResourceData, m interface{}, do_delta bool) error {
// "d" is filled with data according to computeResource schema, so extra networks config is retrieved via "network" key // "d" is filled with data according to computeResource schema, so extra networks config is retrieved via "network" key
// If do_delta is true, this function will identify changes between new and existing specs for network and try to // If do_delta is true, this function will identify changes between new and existing specs for network and try to
// update compute configuration accordingly // update compute configuration accordingly
// Otherwise it will apply whatever is found in the new set of "network" right away. // Otherwise it will apply whatever is found in the new set of "network" right away.
// Primary use of do_delta=false is when calling this function from compute Create handler. // Primary use of do_delta=false is when calling this function from compute Create handler.
c := m.(*controller.ControllerCfg)
old_set, new_set := d.GetChange("network") old_set, new_set := d.GetChange("network")
apiErrCount := 0 apiErrCount := 0
@ -145,7 +156,7 @@ func (ctrl *ControllerCfg) utilityComputeNetworksConfigure(d *schema.ResourceDat
if ipSet { if ipSet {
urlValues.Add("ipAddr", ipaddr.(string)) urlValues.Add("ipAddr", ipaddr.(string))
} }
_, err := ctrl.decortAPICall("POST", ComputeNetAttachAPI, urlValues) _, err := c.DecortAPICall("POST", ComputeNetAttachAPI, urlValues)
if err != nil { if err != nil {
// failed to attach network - partial resource update // failed to attach network - partial resource update
apiErrCount++ apiErrCount++
@ -169,7 +180,7 @@ func (ctrl *ControllerCfg) utilityComputeNetworksConfigure(d *schema.ResourceDat
urlValues.Add("computeId", d.Id()) urlValues.Add("computeId", d.Id())
urlValues.Add("ipAddr", net_data["ip_address"].(string)) urlValues.Add("ipAddr", net_data["ip_address"].(string))
urlValues.Add("mac", net_data["mac"].(string)) urlValues.Add("mac", net_data["mac"].(string))
_, err := ctrl.decortAPICall("POST", ComputeNetDetachAPI, urlValues) _, err := c.DecortAPICall("POST", ComputeNetDetachAPI, urlValues)
if err != nil { if err != nil {
// failed to detach this network - there will be partial resource update // failed to detach this network - there will be partial resource update
log.Errorf("utilityComputeNetworksConfigure: failed to detach net ID %d of type %s from Compute ID %s: %s", log.Errorf("utilityComputeNetworksConfigure: failed to detach net ID %d of type %s from Compute ID %s: %s",
@ -190,7 +201,7 @@ func (ctrl *ControllerCfg) utilityComputeNetworksConfigure(d *schema.ResourceDat
if net_data["ip_address"].(string) != "" { if net_data["ip_address"].(string) != "" {
urlValues.Add("ipAddr", net_data["ip_address"].(string)) urlValues.Add("ipAddr", net_data["ip_address"].(string))
} }
_, err := ctrl.decortAPICall("POST", ComputeNetAttachAPI, urlValues) _, err := c.DecortAPICall("POST", ComputeNetAttachAPI, urlValues)
if err != nil { if err != nil {
// failed to attach this network - there will be partial resource update // failed to attach this network - there will be partial resource update
log.Errorf("utilityComputeNetworksConfigure: failed to attach net ID %d of type %s to Compute ID %s: %s", log.Errorf("utilityComputeNetworksConfigure: failed to attach net ID %d of type %s to Compute ID %s: %s",
@ -223,7 +234,7 @@ func utilityComputeCheckPresence(d *schema.ResourceData, m interface{}) (string,
// method for resource's Exists method. // method for resource's Exists method.
// //
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
// make it possible to use "read" & "check presence" functions with compute ID set so // make it possible to use "read" & "check presence" functions with compute ID set so
@ -244,7 +255,7 @@ func utilityComputeCheckPresence(d *schema.ResourceData, m interface{}) (string,
// compute ID is specified, try to get compute instance straight by this ID // compute ID is specified, try to get compute instance straight by this ID
log.Debugf("utilityComputeCheckPresence: locating compute by its ID %d", theId) log.Debugf("utilityComputeCheckPresence: locating compute by its ID %d", theId)
urlValues.Add("computeId", fmt.Sprintf("%d", theId)) urlValues.Add("computeId", fmt.Sprintf("%d", theId))
computeFacts, err := controller.decortAPICall("POST", ComputeGetAPI, urlValues) computeFacts, err := c.DecortAPICall("POST", ComputeGetAPI, urlValues)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -264,7 +275,7 @@ func utilityComputeCheckPresence(d *schema.ResourceData, m interface{}) (string,
} }
urlValues.Add("rgId", fmt.Sprintf("%d", rgId)) urlValues.Add("rgId", fmt.Sprintf("%d", rgId))
apiResp, err := controller.decortAPICall("POST", RgListComputesAPI, urlValues) apiResp, err := c.DecortAPICall("POST", RgListComputesAPI, urlValues)
if err != nil { if err != nil {
return "", err return "", err
} }
@ -286,7 +297,7 @@ func utilityComputeCheckPresence(d *schema.ResourceData, m interface{}) (string,
// we found the Compute we need - now get detailed information via compute/get API // we found the Compute we need - now get detailed information via compute/get API
cgetValues := &url.Values{} cgetValues := &url.Values{}
cgetValues.Add("computeId", fmt.Sprintf("%d", item.ID)) cgetValues.Add("computeId", fmt.Sprintf("%d", item.ID))
apiResp, err = controller.decortAPICall("POST", ComputeGetAPI, cgetValues) apiResp, err = c.DecortAPICall("POST", ComputeGetAPI, cgetValues)
if err != nil { if err != nil {
return "", err return "", err
} }

@ -0,0 +1,36 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package pfw
const ComputePfwListAPI = "/restmachine/cloudapi/compute/pfwList"
const ComputePfwAddAPI = "/restmachine/cloudapi/compute/pfwAdd"
const ComputePfwDelAPI = "/restmachine/cloudapi/compute/pfwDel"

@ -0,0 +1,45 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package pfw
type PfwRecord struct {
ID int `json:"id"`
LocalIP string `json:"localIp"`
LocalPort int `json:"localPort"`
Protocol string `json:"protocol"`
PublicPortEnd int `json:"publicPortEnd"`
PublicPortStart int `json:"publicPortStart"`
ComputeID int `json:"vmId"`
}
type ComputePfwListResp []PfwRecord

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,28 +18,37 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package pfw
import ( import (
"context"
"fmt" "fmt"
"net/url" "net/url"
"strconv" "strconv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
"github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/validation"
"github.com/rudecs/terraform-provider-decort/internal/constants"
"github.com/rudecs/terraform-provider-decort/internal/controller"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )
func resourcePfwCreate(d *schema.ResourceData, m interface{}) error { func resourcePfwCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourcePfwCreate: called for compute %d", d.Get("compute_id").(int)) log.Debugf("resourcePfwCreate: called for compute %d", d.Get("compute_id").(int))
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
urlValues.Add("publicPortStart", strconv.Itoa(d.Get("public_port_start").(int))) urlValues.Add("publicPortStart", strconv.Itoa(d.Get("public_port_start").(int)))
@ -48,16 +59,16 @@ func resourcePfwCreate(d *schema.ResourceData, m interface{}) error {
urlValues.Add("publicPortEnd", strconv.Itoa(portEnd.(int))) urlValues.Add("publicPortEnd", strconv.Itoa(portEnd.(int)))
} }
pfwId, err := controller.decortAPICall("POST", ComputePfwAddAPI, urlValues) pfwId, err := c.DecortAPICall("POST", ComputePfwAddAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.SetId(fmt.Sprintf("%d-%s", d.Get("compute_id").(int), pfwId)) d.SetId(fmt.Sprintf("%d-%s", d.Get("compute_id").(int), pfwId))
pfw, err := utilityPfwCheckPresence(d, m) pfw, err := utilityPfwCheckPresence(d, m)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
d.Set("local_ip", pfw.LocalIP) d.Set("local_ip", pfw.LocalIP)
@ -68,13 +79,13 @@ func resourcePfwCreate(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourcePfwRead(d *schema.ResourceData, m interface{}) error { func resourcePfwRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourcePfwRead: called for compute %d, rule %s", d.Get("compute_id").(int), d.Id()) log.Debugf("resourcePfwRead: called for compute %d, rule %s", d.Get("compute_id").(int), d.Id())
pfw, err := utilityPfwCheckPresence(d, m) pfw, err := utilityPfwCheckPresence(d, m)
if pfw == nil { if pfw == nil {
d.SetId("") d.SetId("")
return err return diag.FromErr(err)
} }
d.Set("compute_id", pfw.ComputeID) d.Set("compute_id", pfw.ComputeID)
@ -87,25 +98,25 @@ func resourcePfwRead(d *schema.ResourceData, m interface{}) error {
return nil return nil
} }
func resourcePfwDelete(d *schema.ResourceData, m interface{}) error { func resourcePfwDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
log.Debugf("resourcePfwDelete: called for compute %d, rule %s", d.Get("compute_id").(int), d.Id()) log.Debugf("resourcePfwDelete: called for compute %d, rule %s", d.Get("compute_id").(int), d.Id())
pfw, err := utilityPfwCheckPresence(d, m) pfw, err := utilityPfwCheckPresence(d, m)
if pfw == nil { if pfw == nil {
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
} }
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
urlValues.Add("ruleId", strconv.Itoa(pfw.ID)) urlValues.Add("ruleId", strconv.Itoa(pfw.ID))
_, err = controller.decortAPICall("POST", ComputePfwDelAPI, urlValues) _, err = c.DecortAPICall("POST", ComputePfwDelAPI, urlValues)
if err != nil { if err != nil {
return err return diag.FromErr(err)
} }
return nil return nil
@ -175,25 +186,25 @@ func resourcePfwSchemaMake() map[string]*schema.Schema {
} }
} }
func resourcePfw() *schema.Resource { func ResourcePfw() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Create: resourcePfwCreate, CreateContext: resourcePfwCreate,
Read: resourcePfwRead, ReadContext: resourcePfwRead,
Delete: resourcePfwDelete, DeleteContext: resourcePfwDelete,
Exists: resourcePfwExists, Exists: resourcePfwExists,
Importer: &schema.ResourceImporter{ Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough, State: schema.ImportStatePassthrough,
}, },
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s, Create: &constants.Timeout60s,
Read: &Timeout30s, Read: &constants.Timeout30s,
Update: &Timeout60s, Update: &constants.Timeout60s,
Delete: &Timeout60s, Delete: &constants.Timeout60s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: resourcePfwSchemaMake(), Schema: resourcePfwSchemaMake(),

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Petr Krutov, <petr.krutov@digitalenergy.online> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,13 +18,18 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package pfw
import ( import (
"encoding/json" "encoding/json"
@ -30,15 +37,16 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/rudecs/terraform-provider-decort/internal/controller"
) )
func utilityPfwCheckPresence(d *schema.ResourceData, m interface{}) (*PfwRecord, error) { func utilityPfwCheckPresence(d *schema.ResourceData, m interface{}) (*PfwRecord, error) {
controller := m.(*ControllerCfg) c := m.(*controller.ControllerCfg)
urlValues := &url.Values{} urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int))) urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
resp, err := controller.decortAPICall("POST", ComputePfwListAPI, urlValues) resp, err := c.DecortAPICall("POST", ComputePfwListAPI, urlValues)
if err != nil { if err != nil {
return nil, err return nil, err
} }

@ -0,0 +1,39 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/*
Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Orchestration Technology) with Terraform by Hashicorp.
Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/
package rg
const ResgroupCreateAPI = "/restmachine/cloudapi/rg/create"
const ResgroupUpdateAPI = "/restmachine/cloudapi/rg/update"
const ResgroupListAPI = "/restmachine/cloudapi/rg/list"
const ResgroupGetAPI = "/restmachine/cloudapi/rg/get"
const ResgroupDeleteAPI = "/restmachine/cloudapi/rg/delete"
const RgListComputesAPI = "/restmachine/cloudapi/rg/listComputes"

@ -1,6 +1,8 @@
/* /*
Copyright (c) 2019-2021 Digital Energy Cloud Solutions LLC. All Rights Reserved. Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Sergey Shubin, <sergey.shubin@digitalenergy.online>, <svs1370@gmail.com> Authors:
Petr Krutov, <petr.krutov@digitalenergy.online>
Stanislav Solovev, <spsolovev@digitalenergy.online>
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -16,24 +18,31 @@ limitations under the License.
*/ */
/* /*
This file is part of Terraform (by Hashicorp) provider for Digital Energy Cloud Orchestration Terraform DECORT provider - manage resources provided by DECORT (Digital Energy Cloud
Technology platfom. Orchestration Technology) with Terraform by Hashicorp.
Visit https://github.com/rudecs/terraform-provider-decort for full source code package and updates. Source code: https://github.com/rudecs/terraform-provider-decort
Please see README.md to learn where to place source code so that it
builds seamlessly.
Documentation: https://github.com/rudecs/terraform-provider-decort/wiki
*/ */
package decort package rg
import ( import (
"context"
"encoding/json" "encoding/json"
"fmt" "fmt"
"github.com/rudecs/terraform-provider-decort/internal/constants"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
// "net/url" // "net/url"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema" "github.com/hashicorp/terraform-plugin-sdk/v2/diag"
// "github.com/hashicorp/terraform-plugin-sdk/helper/validation" "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
) )
func flattenResgroup(d *schema.ResourceData, rg_facts string) error { func flattenResgroup(d *schema.ResourceData, rg_facts string) error {
@ -61,8 +70,8 @@ func flattenResgroup(d *schema.ResourceData, rg_facts string) error {
d.Set("def_net_type", details.DefaultNetType) d.Set("def_net_type", details.DefaultNetType)
d.Set("def_net_id", details.DefaultNetID) d.Set("def_net_id", details.DefaultNetID)
/* /*
d.Set("vins", details.Vins) d.Set("vins", details.Vins)
d.Set("computes", details.Computes) d.Set("computes", details.Computes)
*/ */
log.Debugf("flattenResgroup: calling flattenQuota()") log.Debugf("flattenResgroup: calling flattenQuota()")
@ -73,27 +82,27 @@ func flattenResgroup(d *schema.ResourceData, rg_facts string) error {
return nil return nil
} }
func dataSourceResgroupRead(d *schema.ResourceData, m interface{}) error { func dataSourceResgroupRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
rg_facts, err := utilityResgroupCheckPresence(d, m) rg_facts, err := utilityResgroupCheckPresence(d, m)
if rg_facts == "" { if rg_facts == "" {
// if empty string is returned from utilityResgroupCheckPresence then there is no // if empty string is returned from utilityResgroupCheckPresence then there is no
// such resource group and err tells so - just return it to the calling party // such resource group and err tells so - just return it to the calling party
d.SetId("") // ensure ID is empty in this case d.SetId("") // ensure ID is empty in this case
return err return diag.FromErr(err)
} }
return flattenResgroup(d, rg_facts) return diag.FromErr(flattenResgroup(d, rg_facts))
} }
func dataSourceResgroup() *schema.Resource { func DataSourceResgroup() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
SchemaVersion: 1, SchemaVersion: 1,
Read: dataSourceResgroupRead, ReadContext: dataSourceResgroupRead,
Timeouts: &schema.ResourceTimeout{ Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s, Read: &constants.Timeout30s,
Default: &Timeout60s, Default: &constants.Timeout60s,
}, },
Schema: map[string]*schema.Schema{ Schema: map[string]*schema.Schema{
@ -158,30 +167,30 @@ func dataSourceResgroup() *schema.Resource {
}, },
/* /*
"status": { "status": {
Type: schema.TypeString, Type: schema.TypeString,
Computed: true, Computed: true,
Description: "Current status of this resource group.", Description: "Current status of this resource group.",
}, },
"vins": { "vins": {
Type: schema.TypeList, // this is a list of ints Type: schema.TypeList, // this is a list of ints
Computed: true, Computed: true,
MaxItems: LimitMaxVinsPerResgroup, MaxItems: LimitMaxVinsPerResgroup,
Elem: &schema.Schema{ Elem: &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
},
Description: "List of VINs deployed in this resource group.",
}, },
Description: "List of VINs deployed in this resource group.",
},
"computes": { "computes": {
Type: schema.TypeList, //t his is a list of ints Type: schema.TypeList, //t his is a list of ints
Computed: true, Computed: true,
Elem: &schema.Schema{ Elem: &schema.Schema{
Type: schema.TypeInt, Type: schema.TypeInt,
},
Description: "List of computes deployed in this resource group.",
}, },
Description: "List of computes deployed in this resource group.",
},
*/ */
}, },
} }

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save