Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d15af9259 |
37
.github/workflows/release.yml
vendored
Normal file
37
.github/workflows/release.yml
vendored
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
name: Release to registry
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- 'v*'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Fetch all tags
|
||||||
|
run: git fetch --force --tags
|
||||||
|
|
||||||
|
- name: Setup Go
|
||||||
|
uses: actions/setup-go@v2
|
||||||
|
with:
|
||||||
|
go-version: 1.17
|
||||||
|
|
||||||
|
- name: Import GPG key
|
||||||
|
id: import_gpg
|
||||||
|
uses: crazy-max/ghaction-import-gpg@v4
|
||||||
|
with:
|
||||||
|
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
|
||||||
|
passphrase: ${{ secrets.PASSPHRASE }}
|
||||||
|
|
||||||
|
- name: Run GoReleaser
|
||||||
|
uses: goreleaser/goreleaser-action@v2
|
||||||
|
with:
|
||||||
|
args: release --rm-dist --release-notes CHANGELOG.md
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
|
||||||
@@ -1,14 +1,8 @@
|
|||||||
# Visit https://goreleaser.com for documentation on how to customize this
|
|
||||||
# behavior.
|
|
||||||
before:
|
before:
|
||||||
hooks:
|
hooks:
|
||||||
# this is just an example and not a requirement for provider building/publishing
|
|
||||||
- go mod tidy
|
- go mod tidy
|
||||||
builds:
|
builds:
|
||||||
- env:
|
- env:
|
||||||
# goreleaser does not work with CGO, it could also complicate
|
|
||||||
# usage by users in CI/CD systems like Terraform Cloud where
|
|
||||||
# they are unable to install libraries.
|
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
mod_timestamp: '{{ .CommitTimestamp }}'
|
mod_timestamp: '{{ .CommitTimestamp }}'
|
||||||
flags:
|
flags:
|
||||||
@@ -37,11 +31,9 @@ checksum:
|
|||||||
signs:
|
signs:
|
||||||
- artifacts: checksum
|
- artifacts: checksum
|
||||||
args:
|
args:
|
||||||
# if you are using this in a GitHub action or some other automated pipeline, you
|
|
||||||
# need to pass the batch flag to indicate its not interactive.
|
|
||||||
- "--batch"
|
- "--batch"
|
||||||
- "--local-user"
|
- "--local-user"
|
||||||
- "{{ .Env.GPG_FINGERPRINT }}" # set this environment variable for your signing key
|
- "{{ .Env.GPG_FINGERPRINT }}"
|
||||||
- "--output"
|
- "--output"
|
||||||
- "${signature}"
|
- "${signature}"
|
||||||
- "--detach-sign"
|
- "--detach-sign"
|
||||||
@@ -50,7 +42,5 @@ release:
|
|||||||
extra_files:
|
extra_files:
|
||||||
- glob: 'terraform-registry-manifest.json'
|
- glob: 'terraform-registry-manifest.json'
|
||||||
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
|
name_template: '{{ .ProjectName }}_{{ .Version }}_manifest.json'
|
||||||
# If you want to manually examine the release before its live, uncomment this line:
|
|
||||||
# draft: true
|
|
||||||
changelog:
|
changelog:
|
||||||
skip: true
|
skip: false
|
||||||
|
|||||||
16
CHANGELOG.md
Normal file
16
CHANGELOG.md
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
## 2.0
|
||||||
|
|
||||||
|
### New data sources
|
||||||
|
- image
|
||||||
|
- image\_list
|
||||||
|
- grid
|
||||||
|
- grid\_list
|
||||||
|
- image\_list\_stacks
|
||||||
|
|
||||||
|
### New resources
|
||||||
|
- image
|
||||||
|
- virtual\_image
|
||||||
|
- cdrom\_image
|
||||||
|
- delete\_images
|
||||||
|
- k8s
|
||||||
|
- k8s\_wg
|
||||||
@@ -583,12 +583,16 @@ const VinsDeleteAPI = "/restmachine/cloudapi/vins/delete"
|
|||||||
|
|
||||||
//K8sNodeRecord represents a worker/master group
|
//K8sNodeRecord represents a worker/master group
|
||||||
type K8sNodeRecord struct {
|
type K8sNodeRecord struct {
|
||||||
ID int `json:"id"`
|
ID int `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Disk int `json:"disk"`
|
Disk int `json:"disk"`
|
||||||
Cpu int `json:"cpu"`
|
Cpu int `json:"cpu"`
|
||||||
Num int `json:"num"`
|
Num int `json:"num"`
|
||||||
Ram int `json:"ram"`
|
Ram int `json:"ram"`
|
||||||
|
DetailedInfo []struct {
|
||||||
|
ID int `json:"id"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
} `json:"detailedInfo"`
|
||||||
}
|
}
|
||||||
|
|
||||||
//K8sRecord represents k8s instance
|
//K8sRecord represents k8s instance
|
||||||
@@ -614,6 +618,9 @@ const K8sDeleteAPI = "/restmachine/cloudapi/k8s/delete"
|
|||||||
const K8sWgCreateAPI = "/restmachine/cloudapi/k8s/workersGroupAdd"
|
const K8sWgCreateAPI = "/restmachine/cloudapi/k8s/workersGroupAdd"
|
||||||
const K8sWgDeleteAPI = "/restmachine/cloudapi/k8s/workersGroupDelete"
|
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 K8sGetConfigAPI = "/restmachine/cloudapi/k8s/getConfig"
|
||||||
|
|
||||||
//Blasphemous workaround for parsing Result value
|
//Blasphemous workaround for parsing Result value
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ func nodeK8sSubresourceSchemaMake() map[string]*schema.Schema {
|
|||||||
"num": {
|
"num": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Required: true,
|
Required: true,
|
||||||
ForceNew: true,
|
|
||||||
Description: "Number of nodes to create.",
|
Description: "Number of nodes to create.",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -165,13 +165,46 @@ func resourceK8sUpdate(d *schema.ResourceData, m interface{}) error {
|
|||||||
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)
|
controller := m.(*ControllerCfg)
|
||||||
urlValues := &url.Values{}
|
|
||||||
urlValues.Add("k8sId", d.Id())
|
|
||||||
urlValues.Add("name", d.Get("name").(string))
|
|
||||||
|
|
||||||
_, err := controller.decortAPICall("POST", K8sUpdateAPI, urlValues)
|
if d.HasChange("name") {
|
||||||
if err != nil {
|
urlValues := &url.Values{}
|
||||||
return err
|
urlValues.Add("k8sId", d.Id())
|
||||||
|
urlValues.Add("name", d.Get("name").(string))
|
||||||
|
|
||||||
|
_, err := controller.decortAPICall("POST", K8sUpdateAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if d.HasChange("workers") {
|
||||||
|
k8s, err := utilityK8sCheckPresence(d, m)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
wg := k8s.Groups.Workers[0]
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("k8sId", d.Id())
|
||||||
|
urlValues.Add("workersGroupId", strconv.Itoa(wg.ID))
|
||||||
|
|
||||||
|
newWorkers := parseNode(d.Get("workers").([]interface{}))
|
||||||
|
|
||||||
|
if newWorkers.Num > wg.Num {
|
||||||
|
urlValues.Add("num", strconv.Itoa(newWorkers.Num-wg.Num))
|
||||||
|
_, err := controller.decortAPICall("POST", K8sWorkerAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i := wg.Num - 1; i >= newWorkers.Num; i-- {
|
||||||
|
urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID))
|
||||||
|
_, err := controller.decortAPICall("POST", K8sWorkerDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@@ -255,7 +288,6 @@ func resourceK8sSchemaMake() map[string]*schema.Schema {
|
|||||||
"workers": {
|
"workers": {
|
||||||
Type: schema.TypeList,
|
Type: schema.TypeList,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
|
||||||
MaxItems: 1,
|
MaxItems: 1,
|
||||||
Elem: &schema.Resource{
|
Elem: &schema.Resource{
|
||||||
Schema: nodeK8sSubresourceSchemaMake(),
|
Schema: nodeK8sSubresourceSchemaMake(),
|
||||||
@@ -316,7 +348,7 @@ func resourceK8s() *schema.Resource {
|
|||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &Timeout10m,
|
Create: &Timeout10m,
|
||||||
Read: &Timeout30s,
|
Read: &Timeout30s,
|
||||||
Update: &Timeout60s,
|
Update: &Timeout10m,
|
||||||
Delete: &Timeout60s,
|
Delete: &Timeout60s,
|
||||||
Default: &Timeout60s,
|
Default: &Timeout60s,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -101,6 +101,41 @@ func resourceK8sWgRead(d *schema.ResourceData, m interface{}) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func resourceK8sWgUpdate(d *schema.ResourceData, m interface{}) error {
|
||||||
|
log.Debugf("resourceK8sWgUpdate: called with k8s id %d", d.Get("k8s_id").(int))
|
||||||
|
|
||||||
|
controller := m.(*ControllerCfg)
|
||||||
|
|
||||||
|
wg, err := utilityK8sWgCheckPresence(d, m)
|
||||||
|
if err != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
urlValues := &url.Values{}
|
||||||
|
urlValues.Add("k8sId", strconv.Itoa(d.Get("k8s_id").(int)))
|
||||||
|
urlValues.Add("workersGroupId", d.Id())
|
||||||
|
|
||||||
|
newNum := d.Get("num").(int)
|
||||||
|
|
||||||
|
if newNum > wg.Num {
|
||||||
|
urlValues.Add("num", strconv.Itoa(newNum-wg.Num))
|
||||||
|
_, err := controller.decortAPICall("POST", K8sWorkerAddAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for i := wg.Num - 1; i >= newNum; i-- {
|
||||||
|
urlValues.Set("workerId", strconv.Itoa(wg.DetailedInfo[i].ID))
|
||||||
|
_, err := controller.decortAPICall("POST", K8sWorkerDeleteAPI, urlValues)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func resourceK8sWgDelete(d *schema.ResourceData, m interface{}) error {
|
func resourceK8sWgDelete(d *schema.ResourceData, m interface{}) error {
|
||||||
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))
|
||||||
|
|
||||||
@@ -158,7 +193,6 @@ func resourceK8sWgSchemaMake() map[string]*schema.Schema {
|
|||||||
"num": {
|
"num": {
|
||||||
Type: schema.TypeInt,
|
Type: schema.TypeInt,
|
||||||
Optional: true,
|
Optional: true,
|
||||||
ForceNew: true,
|
|
||||||
Default: 1,
|
Default: 1,
|
||||||
Description: "Number of worker nodes to create.",
|
Description: "Number of worker nodes to create.",
|
||||||
},
|
},
|
||||||
@@ -195,6 +229,7 @@ func resourceK8sWg() *schema.Resource {
|
|||||||
|
|
||||||
Create: resourceK8sWgCreate,
|
Create: resourceK8sWgCreate,
|
||||||
Read: resourceK8sWgRead,
|
Read: resourceK8sWgRead,
|
||||||
|
Update: resourceK8sWgUpdate,
|
||||||
Delete: resourceK8sWgDelete,
|
Delete: resourceK8sWgDelete,
|
||||||
Exists: resourceK8sWgExists,
|
Exists: resourceK8sWgExists,
|
||||||
|
|
||||||
@@ -205,6 +240,7 @@ func resourceK8sWg() *schema.Resource {
|
|||||||
Timeouts: &schema.ResourceTimeout{
|
Timeouts: &schema.ResourceTimeout{
|
||||||
Create: &Timeout10m,
|
Create: &Timeout10m,
|
||||||
Read: &Timeout30s,
|
Read: &Timeout30s,
|
||||||
|
Update: &Timeout10m,
|
||||||
Delete: &Timeout60s,
|
Delete: &Timeout60s,
|
||||||
Default: &Timeout60s,
|
Default: &Timeout60s,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -38,5 +38,6 @@ Optional:
|
|||||||
- **default** (String)
|
- **default** (String)
|
||||||
- **delete** (String)
|
- **delete** (String)
|
||||||
- **read** (String)
|
- **read** (String)
|
||||||
|
- **update** (String)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user