Compare commits

...

11 Commits
2.0 ... v2.1.0

Author SHA1 Message Date
kjubybot
8a716edac3 updated changelog 2022-04-04 12:33:50 +03:00
kjubybot
cda317f4db updated docs 2022-04-04 12:28:54 +03:00
kjubybot
299d606df0 added Jenkinsfile and sonar-project.properties for SAST analysis 2022-04-04 12:19:40 +03:00
stSolo
3cd8c2e618 Rename data_snapshot_list => data_source_snapshot_list 2022-03-30 20:01:31 +03:00
stSolo
efea1af92a Update readme files 2022-03-30 19:22:03 +03:00
Petr Krutov
77d8d2e921 Merge branch 'feature/k8s_extnet' into '2.1'
added extnet_id parameter to k8s; added read-only parameter lb_ip to k8s

See merge request rudecs/terraform-provider-decort!4
2022-03-30 17:20:54 +03:00
Petr Krutov
f1ec6d776a Merge branch 'feature/retry_on_fail' into '2.1'
controller: added request retry on 500

See merge request rudecs/terraform-provider-decort!3
2022-03-30 17:19:58 +03:00
Petr Krutov
ff64840b13 Merge branch 'features/snapshot' into '2.1'
Features/snapshot

See merge request rudecs/terraform-provider-decort!2
2022-03-30 17:13:16 +03:00
Stanislav Solovev
13e6849328 Features/snapshot 2022-03-30 17:13:16 +03:00
kjubybot
964e85c34a controller: added request retry on 500 2022-03-30 09:33:34 +03:00
kjubybot
92d96b13c6 added extnet_id parameter to k8s; added read-only parameter lb_ip to k8s 2022-03-29 17:58:58 +03:00
19 changed files with 808 additions and 42 deletions

View File

@@ -1,5 +1,4 @@
### Bug fixes
- k8s state import
### Minor changes
- increased k8s and k8s\_wg create/update timeouts
### New features
- snapshot\_list datasource
- snapshot resource
- k8s: extnet\_id parameter

50
Jenkinsfile-sast Normal file
View File

@@ -0,0 +1,50 @@
pipeline {
agent {
kubernetes {
yaml '''
apiVersion: v1
kind: Pod
spec:
containers:
- name: alpine
image: alpine:3.15
command:
- sleep
- infinity
'''
}
}
stages {
stage('Dependency check') {
environment {
DEPCHECKDB = credentials('depcheck-postgres')
}
steps {
container('alpine') {
sh 'apk update && apk add openjdk11 java-postgresql-jdbc'
dependencyCheck additionalArguments: '-f JSON -f HTML \
--dbDriverName org.postgresql.Driver \
--dbDriverPath /usr/share/java/postgresql-jdbc.jar \
--dbUser $DEPCHECKDB_USR \
--dbPassword $DEPCHECKDB_PSW \
--connectionString jdbc:postgresql://postgres-postgresql.postgres/depcheck', odcInstallation: 'depcheck'
}
}
}
stage('SonarQube analysis') {
environment {
SONARSCANNER_HOME = tool 'sonarscanner'
}
steps {
withSonarQubeEnv('sonarqube') {
sh '$SONARSCANNER_HOME/bin/sonar-scanner'
}
}
}
stage('SonarQube quality gate') {
steps {
waitForQualityGate webhookSecretId: 'sonar-webhook', abortPipeline: true
}
}
}
}

View File

@@ -10,12 +10,12 @@ Terraform provider для платформы Digital Energy Cloud Orchestration
- Работа с Compute instances,
- Работа с disks,
- Работа с k8s,
- Работа с virtual network segments,
- Работа с image,
- Работа с reource groups,
- Работа с VINS,
- Работа с pfw,
- Работа с accounts.
- Работа с accounts,
- Работа с snapshots.
Вики проекта: https://github.com/rudecs/terraform-provider-decort/wiki
@@ -65,7 +65,7 @@ Linux:
```
Windows:
```powershell
%APPDATA%\terraform.d\plugins\${host_name}/${namespace}/${type}/${version}/${target}
%APPDATA%\terraform.d\plugins\${host_name}\${namespace}\${type}\${version}\${target}
```
ВНИМАНИЕ: для ОС Windows `%APP_DATA%` является каталогом, в котором будут помещены будущие файлы terraform.
Где:

View File

@@ -9,12 +9,12 @@ NOTE: provider rc-1.25 is designed for DECORT API 3.7.x. For older API versions
- Work with Compute instances,
- Work with disks,
- Work with k8s,
- Work with virtual network segments,
- Work with image,
- Work with reource groups,
- Work with VINS,
- Work with pfw,
- Work with accounts.
- Work with accounts,
- Work with snapshots.
This provider supports Import operations on pre-existing resources.

View File

@@ -27,12 +27,14 @@ package decort
import (
"bytes"
"crypto/tls"
"errors"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strconv"
"strings"
"time"
// "time"
@@ -378,28 +380,31 @@ func (config *ControllerCfg) decortAPICall(method string, api_name string, url_v
req.Header.Set("Authorization", fmt.Sprintf("bearer %s", config.jwt))
}
resp, err := config.cc_client.Do(req)
if err != nil {
return "", err
}
defer resp.Body.Close()
for i := 0; i < 5; i++ {
resp, err := config.cc_client.Do(req)
if err != nil {
return "", err
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
log.Debugf("decortAPICall: %s %s\n %s", method, api_name, body)
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return "", err
}
resp.Body.Close()
log.Debugf("decortAPICall: %s %s\n %s", method, api_name, body)
if resp.StatusCode == http.StatusOK {
return string(body), nil
} else {
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
resp.StatusCode, req.URL, params_str, body)
}
/*
if resp.StatusCode == StatusServiceUnavailable {
return nil, fmt.Errorf("decortAPICall method called for incompatible authorization mode %q.", config.auth_mode_txt)
if resp.StatusCode == http.StatusOK {
return string(body), nil
} else {
if resp.StatusCode == http.StatusInternalServerError {
log.Warnf("got 500, retrying %d/5", i+1)
time.Sleep(time.Second * 5)
continue
}
*/
return "", fmt.Errorf("decortAPICall: unexpected status code %d when calling API %q with request Body %q. Respone:\n%s",
resp.StatusCode, req.URL, params_str, body)
}
}
return "", errors.New("number of retries exceeded")
}

View File

@@ -0,0 +1,120 @@
/*
Copyright (c) 2019-2022 Digital Energy Cloud Solutions LLC. All Rights Reserved.
Author: Stanislav Solovev, <spsolovev@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.
*/
/*
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 flattenSnapshotList(gl SnapshotList) []map[string]interface{} {
res := make([]map[string]interface{}, 0)
for _, item := range gl {
temp := map[string]interface{}{
"label": item.Label,
"guid": item.Guid,
"disks": item.Disks,
"timestamp": item.Timestamp,
}
res = append(res, temp)
}
return res
}
func dataSourceSnapshotListRead(d *schema.ResourceData, m interface{}) error {
snapshotList, err := utilitySnapshotListCheckPresence(d, m)
if err != nil {
return err
}
id := uuid.New()
d.SetId(id.String())
d.Set("items", flattenSnapshotList(snapshotList))
return nil
}
func dataSourceSnapshotListSchemaMake() map[string]*schema.Schema {
rets := map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: "ID of the compute instance to create snapshot for.",
},
"items": {
Type: schema.TypeList,
Computed: true,
Description: "snapshot list",
Elem: &schema.Resource{
Schema: dataSourceSnapshotSchemaMake(),
},
},
}
return rets
}
func dataSourceSnapshotSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"label": {
Type: schema.TypeString,
Computed: true,
Description: "text label for snapshot. Must be unique among this compute snapshots.",
},
"disks": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "guid of the snapshot",
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
Description: "timestamp",
},
}
}
func dataSourceSnapshotList() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Read: dataSourceSnapshotListRead,
Timeouts: &schema.ResourceTimeout{
Read: &Timeout30s,
Default: &Timeout60s,
},
Schema: dataSourceSnapshotListSchemaMake(),
}
}

View File

@@ -605,11 +605,27 @@ type K8sRecord 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"`
}
const K8sCreateAPI = "/restmachine/cloudapi/k8s/create"
const K8sGetAPI = "/restmachine/cloudapi/k8s/get"
const K8sUpdateAPI = "/restmachine/cloudapi/k8s/update"
@@ -623,6 +639,8 @@ const K8sWorkerDeleteAPI = "/restmachine/cloudapi/k8s/deleteWorkerFromGroup"
const K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
const LbGetAPI = "/restmachine/cloudapi/lb/get"
//Blasphemous workaround for parsing Result value
type TaskResult int
@@ -799,3 +817,21 @@ type Grid struct {
}
type GridList []Grid
/////////////////////
/// SNAPSHOT API ///
/////////////////////
const snapshotCreateAPI = "/restmachine/cloudapi/compute/snapshotCreate"
const snapshotDeleteAPI = "/restmachine/cloudapi/compute/snapshotDelete"
const snapshotRollbackAPI = "/restmachine/cloudapi/compute/snapshotRollback"
const snapshotListAPI = "/restmachine/cloudapi/compute/snapshotList"
type Snapshot struct {
Disks []int `json:"disks"`
Guid string `json:"guid"`
Label string `json:"label"`
Timestamp uint64 `json:"timestamp"`
}
type SnapshotList []Snapshot

View File

@@ -110,6 +110,7 @@ func Provider() *schema.Provider {
"decort_virtual_image": resourceVirtualImage(),
"decort_cdrom_image": resourceCDROMImage(),
"decort_delete_images": resourceDeleteImages(),
"decort_snapshot": resourceSnapshot(),
},
DataSourcesMap: map[string]*schema.Resource{
@@ -123,6 +124,7 @@ func Provider() *schema.Provider {
"decort_grid_list": dataSourceGridList(),
"decort_image_list": dataSourceImageList(),
"decort_image_list_stacks": dataSourceImageListStacks(),
"decort_snapshot_list": dataSourceSnapshotList(),
// "decort_pfw": dataSourcePfw(),
},

View File

@@ -73,10 +73,11 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
//}
urlValues.Add("withLB", strconv.FormatBool(true))
//if extNet, ok := d.GetOk("extnet_id"); ok {
//urlValues.Add("extnetId", strconv.Itoa(extNet.(int)))
//}
urlValues.Add("extnetId", strconv.Itoa(0))
if extNet, ok := d.GetOk("extnet_id"); ok {
urlValues.Add("extnetId", strconv.Itoa(extNet.(int)))
} else {
urlValues.Add("extnetId", "0")
}
//if desc, ok := d.GetOk("desc"); ok {
//urlValues.Add("desc", desc.(string))
@@ -121,6 +122,21 @@ func resourceK8sCreate(d *schema.ResourceData, m interface{}) error {
d.Set("default_wg_id", k8s.Groups.Workers[0].ID)
urlValues = &url.Values{}
urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
resp, err = controller.decortAPICall("POST", LbGetAPI, urlValues)
if err != nil {
return err
}
var lb LbRecord
if err := json.Unmarshal([]byte(resp), &lb); err != nil {
return err
}
d.Set("extnet_id", lb.ExtNetID)
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
urlValues = &url.Values{}
urlValues.Add("k8sId", d.Id())
kubeconfig, err := controller.decortAPICall("POST", K8sGetConfigAPI, urlValues)
@@ -151,6 +167,21 @@ func resourceK8sRead(d *schema.ResourceData, m interface{}) error {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("lbId", strconv.Itoa(k8s.LbID))
resp, err := controller.decortAPICall("POST", LbGetAPI, urlValues)
if err != nil {
return err
}
var lb LbRecord
if err := json.Unmarshal([]byte(resp), &lb); err != nil {
return err
}
d.Set("extnet_id", lb.ExtNetID)
d.Set("lb_ip", lb.PrimaryNode.FrontendIP)
urlValues = &url.Values{}
urlValues.Add("k8sId", d.Id())
kubeconfig, err := controller.decortAPICall("POST", K8sGetConfigAPI, urlValues)
if err != nil {
@@ -303,13 +334,13 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
//Description: "Create k8s with load balancer if true.",
//},
//"extnet_id": {
//Type: schema.TypeInt,
//Optional: true,
//ForceNew: true,
//Default: 0,
//Description: "ID of the external network to connect workers to.",
//},
"extnet_id": {
Type: schema.TypeInt,
Optional: true,
Computed: true,
ForceNew: true,
Description: "ID of the external network to connect workers to. If omitted network will be chosen by the platfom.",
},
//"desc": {
//Type: schema.TypeString,
@@ -317,6 +348,12 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
//Description: "Text description of this instance.",
//},
"lb_ip": {
Type: schema.TypeString,
Computed: true,
Description: "IP address of default load balancer.",
},
"default_wg_id": {
Type: schema.TypeInt,
Computed: true,

203
decort/resource_snapshot.go Normal file
View File

@@ -0,0 +1,203 @@
/*
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 (
"net/url"
"strconv"
"strings"
"github.com/hashicorp/terraform-plugin-sdk/helper/customdiff"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
log "github.com/sirupsen/logrus"
)
func resourceSnapshotCreate(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSnapshotCreate: called for snapshot %s", d.Get("label").(string))
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("label", d.Get("label").(string))
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
snapshotId, err := controller.decortAPICall("POST", snapshotCreateAPI, urlValues)
if err != nil {
return err
}
snapshotId = strings.ReplaceAll(snapshotId, "\"", "")
d.SetId(snapshotId)
d.Set("guid", snapshotId)
err = resourceSnapshotRead(d, m)
if err != nil {
return err
}
return nil
}
func resourceSnapshotRead(d *schema.ResourceData, m interface{}) error {
snapshot, err := utilitySnapshotCheckPresence(d, m)
if err != nil {
return err
}
d.Set("timestamp", snapshot.Timestamp)
d.Set("guid", snapshot.Guid)
d.Set("disks", snapshot.Disks)
d.Set("label", snapshot.Label)
return nil
}
func resourceSnapshotDelete(d *schema.ResourceData, m interface{}) error {
log.Debugf("resourceSnapshotDelete: called for %s, id: %s", d.Get("label").(string), d.Id())
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
urlValues.Add("label", d.Get("label").(string))
_, err := controller.decortAPICall("POST", snapshotDeleteAPI, urlValues)
if err != nil {
return err
}
d.SetId("")
return nil
}
func resourceSnapshotExists(d *schema.ResourceData, m interface{}) (bool, error) {
snapshot, err := utilitySnapshotCheckPresence(d, m)
if err != nil {
return false, err
}
if snapshot == nil {
return false, nil
}
return true, nil
}
func resourceSnapshotEdit(d *schema.ResourceData, m interface{}) error {
err := resourceSnapshotRead(d, m)
if err != nil {
return err
}
return nil
}
func resourceSnapshotRollback(d *schema.ResourceDiff, m interface{}) error {
c := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
urlValues.Add("label", d.Get("label").(string))
_, err := c.decortAPICall("POST", snapshotRollbackAPI, urlValues)
if err != nil {
return err
}
return nil
}
func resourceSnapshotSchemaMake() map[string]*schema.Schema {
return map[string]*schema.Schema{
"compute_id": {
Type: schema.TypeInt,
Required: true,
ForceNew: true,
Description: "ID of the compute instance to create snapshot for.",
},
"label": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
Description: "text label for snapshot. Must be unique among this compute snapshots.",
},
"rollback": {
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "is rollback the snapshot",
},
"disks": {
Type: schema.TypeList,
Computed: true,
Elem: &schema.Schema{
Type: schema.TypeInt,
},
},
"guid": {
Type: schema.TypeString,
Computed: true,
Description: "guid of the snapshot",
},
"timestamp": {
Type: schema.TypeInt,
Computed: true,
Description: "timestamp",
},
}
}
func resourceSnapshot() *schema.Resource {
return &schema.Resource{
SchemaVersion: 1,
Create: resourceSnapshotCreate,
Read: resourceSnapshotRead,
Update: resourceSnapshotEdit,
Delete: resourceSnapshotDelete,
Exists: resourceSnapshotExists,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Timeouts: &schema.ResourceTimeout{
Create: &Timeout60s,
Read: &Timeout30s,
Update: &Timeout60s,
Delete: &Timeout60s,
Default: &Timeout60s,
},
CustomizeDiff: customdiff.All(
customdiff.IfValueChange("rollback", func(old, new, meta interface{}) bool {
o := old.(bool)
if o != new.(bool) && o == false {
return true
}
return false
}, resourceSnapshotRollback),
),
Schema: resourceSnapshotSchemaMake(),
}
}

View File

@@ -0,0 +1,55 @@
/*
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 (
"errors"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySnapshotCheckPresence(d *schema.ResourceData, m interface{}) (*Snapshot, error) {
snapShotList, err := utilitySnapshotListCheckPresence(d, m)
if err != nil {
return nil, err
}
findId := ""
if (d.Get("guid").(string)) != "" {
findId = d.Get("guid").(string)
} else {
findId = d.Id()
}
for _, s := range snapShotList {
if s.Guid == findId {
return &s, nil
}
}
return nil, errors.New("snapshot not found")
}

View File

@@ -0,0 +1,56 @@
/*
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 (
"encoding/json"
"net/url"
"strconv"
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
)
func utilitySnapshotListCheckPresence(d *schema.ResourceData, m interface{}) (SnapshotList, error) {
controller := m.(*ControllerCfg)
urlValues := &url.Values{}
urlValues.Add("computeId", strconv.Itoa(d.Get("compute_id").(int)))
resp, err := controller.decortAPICall("POST", snapshotListAPI, urlValues)
if err != nil {
return nil, err
}
if resp == "" {
return nil, nil
}
snapshotList := SnapshotList{}
if err := json.Unmarshal([]byte(resp), &snapshotList); err != nil {
//return nil, errors.New(fmt.Sprint("Can not unmarshall data to snapshotList: ", resp, " ", snapshotList))
return nil, err
}
return snapshotList, nil
}

View File

@@ -0,0 +1,50 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "decort_snapshot_list Data Source - terraform-provider-decort"
subcategory: ""
description: |-
---
# decort_snapshot_list (Data Source)
<!-- schema generated by tfplugindocs -->
## Schema
### Required
- **compute_id** (Number) ID of the compute instance to create snapshot for.
### Optional
- **id** (String) The ID of this resource.
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
### Read-Only
- **items** (List of Object) snapshot list (see [below for nested schema](#nestedatt--items))
<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`
Optional:
- **default** (String)
- **read** (String)
<a id="nestedatt--items"></a>
### Nested Schema for `items`
Read-Only:
- **disks** (List of Number)
- **guid** (String)
- **label** (String)
- **timestamp** (Number)

View File

@@ -24,6 +24,7 @@ description: |-
### Optional
- **extnet_id** (Number) ID of the external network to connect workers to. If omitted network will be chosen by the platfom.
- **id** (String) The ID of this resource.
- **masters** (Block List, Max: 1) Master node(s) configuration. (see [below for nested schema](#nestedblock--masters))
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
@@ -33,6 +34,7 @@ description: |-
- **default_wg_id** (Number) ID of default workers group for this instace.
- **kubeconfig** (String) Kubeconfig for cluster access.
- **lb_ip** (String) IP address of default load balancer.
<a id="nestedblock--masters"></a>
### Nested Schema for `masters`

View File

@@ -0,0 +1,46 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "decort_snapshot Resource - terraform-provider-decort"
subcategory: ""
description: |-
---
# decort_snapshot (Resource)
<!-- schema generated by tfplugindocs -->
## Schema
### Required
- **compute_id** (Number) ID of the compute instance to create snapshot for.
- **label** (String) text label for snapshot. Must be unique among this compute snapshots.
### Optional
- **id** (String) The ID of this resource.
- **rollback** (Boolean) is rollback the snapshot
- **timeouts** (Block, Optional) (see [below for nested schema](#nestedblock--timeouts))
### Read-Only
- **disks** (List of Number)
- **guid** (String) guid of the snapshot
- **timestamp** (Number) timestamp
<a id="nestedblock--timeouts"></a>
### Nested Schema for `timeouts`
Optional:
- **create** (String)
- **default** (String)
- **delete** (String)
- **read** (String)
- **update** (String)

View File

@@ -8,6 +8,7 @@
- image
- image_list
- image_list_stacks
- snapshot_list
- resources:
- image
- virtual_image
@@ -15,6 +16,7 @@
- delete_images
- k8s
- k8s_wg
- snapshot
## Как пользоваться примерами
1. Установить terraform

View File

@@ -0,0 +1,40 @@
/*
Пример использования
Получение списка snapshot
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://mr4.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
data "decort_snapshot_list" "sl" {
#обязательный параметр
#id вычислительной мощности
#тип - число
compute_id = 24074
}
output "test" {
value = data.decort_snapshot_list.sl
}

View File

@@ -0,0 +1,56 @@
/*
Пример использования
Ресурса snapshot
Ресурс позволяет:
1. Создавать snapshot
2. Удалять snapshot
3. Откатывать snapshot
*/
#Расскомментируйте этот код,
#и внесите необходимые правки в версию и путь,
#чтобы работать с установленным вручную (не через hashicorp provider registry) провайдером
/*
terraform {
required_providers {
decort = {
version = "1.1"
source = "digitalenergy.online/decort/decort"
}
}
}
*/
provider "decort" {
authenticator = "oauth2"
#controller_url = <DECORT_CONTROLLER_URL>
controller_url = "https://mr4.digitalenergy.online"
#oauth2_url = <DECORT_SSO_URL>
oauth2_url = "https://sso.digitalenergy.online"
allow_unverified_ssl = true
}
resource "decort_snapshot" "s" {
#обязательный параметр
#id вычислительной мощности
#тип - число
compute_id = 24074
#обязательный параметр
#наименование snapshot
#тип - строка
label = "test_ssht_3"
#опциональный параметр
#флаг отката
#тип - булев тип
#по-уолчанию - false
#если флаг был измеен с false на true, то произойдет откат
#rollback = false
}
output "test" {
value = decort_snapshot.s
}

7
sonar-project.properties Normal file
View File

@@ -0,0 +1,7 @@
sonar.projectKey=terraform-provider-decort-sast
sonar.dependencyCheck.jsonReportPath=dependency-check-report.json
sonar.dependencyCheck.htmlReportPath=dependency-check-report.html
sonar.exclusions=dependency-check-report.*
sonar.language=go