ncloud breakout (#10937)

This commit is contained in:
Adrien Delorme 2021-04-20 15:09:11 +02:00 committed by GitHub
parent 9eaad88ac0
commit d22ba61ae0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
213 changed files with 1163 additions and 1597 deletions

View File

@ -43,9 +43,6 @@
/builder/triton/ @sean-
/website/pages/docs/builders/triton* @sean-
/builder/ncloud/ @YuSungDuk
/website/pages/docs/builders/ncloud* @YuSungDuk
/builder/proxmox/ @carlpett
/website/pages/docs/builders/proxmox* @carlpett

View File

@ -1,150 +0,0 @@
package ncloud
import (
"strings"
"testing"
)
func testConfig() map[string]interface{} {
return map[string]interface{}{
"access_key": "access_key",
"secret_key": "secret_key",
"server_image_product_code": "SPSW0WINNT000016",
"server_product_code": "SPSVRSSD00000011",
"server_image_name": "packer-test {{timestamp}}",
"server_image_description": "server description",
"block_storage_size": 100,
"user_data": "#!/bin/sh\nyum install -y httpd\ntouch /var/www/html/index.html\nchkconfig --level 2345 httpd on",
"region": "Korea",
"access_control_group_configuration_no": "33",
"communicator": "ssh",
"ssh_username": "root",
}
}
func testConfigForMemberServerImage() map[string]interface{} {
return map[string]interface{}{
"access_key": "access_key",
"secret_key": "secret_key",
"server_product_code": "SPSVRSSD00000011",
"member_server_image_no": "2440",
"server_image_name": "packer-test {{timestamp}}",
"server_image_description": "server description",
"block_storage_size": 100,
"user_data": "#!/bin/sh\nyum install -y httpd\ntouch /var/www/html/index.html\nchkconfig --level 2345 httpd on",
"region": "Korea",
"access_control_group_configuration_no": "33",
"communicator": "ssh",
"ssh_username": "root",
}
}
func TestConfigWithServerImageProductCode(t *testing.T) {
raw := testConfig()
var c Config
c.Prepare(raw)
if c.AccessKey != "access_key" {
t.Errorf("Expected 'access_key' to be set to '%s', but got '%s'.", raw["access_key"], c.AccessKey)
}
if c.SecretKey != "secret_key" {
t.Errorf("Expected 'secret_key' to be set to '%s', but got '%s'.", raw["secret_key"], c.SecretKey)
}
if c.ServerImageProductCode != "SPSW0WINNT000016" {
t.Errorf("Expected 'server_image_product_code' to be set to '%s', but got '%s'.", raw["server_image_product_code"], c.ServerImageProductCode)
}
if c.ServerProductCode != "SPSVRSSD00000011" {
t.Errorf("Expected 'server_product_code' to be set to '%s', but got '%s'.", raw["server_product_code"], c.ServerProductCode)
}
if c.BlockStorageSize != 100 {
t.Errorf("Expected 'block_storage_size' to be set to '%d', but got '%d'.", raw["block_storage_size"], c.BlockStorageSize)
}
if c.ServerImageDescription != "server description" {
t.Errorf("Expected 'server_image_description_key' to be set to '%s', but got '%s'.", raw["server_image_description"], c.ServerImageDescription)
}
if c.Region != "Korea" {
t.Errorf("Expected 'region' to be set to '%s', but got '%s'.", raw["server_image_description"], c.Region)
}
}
func TestConfigWithMemberServerImageCode(t *testing.T) {
raw := testConfigForMemberServerImage()
var c Config
c.Prepare(raw)
if c.AccessKey != "access_key" {
t.Errorf("Expected 'access_key' to be set to '%s', but got '%s'.", raw["access_key"], c.AccessKey)
}
if c.SecretKey != "secret_key" {
t.Errorf("Expected 'secret_key' to be set to '%s', but got '%s'.", raw["secret_key"], c.SecretKey)
}
if c.MemberServerImageNo != "2440" {
t.Errorf("Expected 'member_server_image_no' to be set to '%s', but got '%s'.", raw["member_server_image_no"], c.MemberServerImageNo)
}
if c.ServerProductCode != "SPSVRSSD00000011" {
t.Errorf("Expected 'server_product_code' to be set to '%s', but got '%s'.", raw["server_product_code"], c.ServerProductCode)
}
if c.BlockStorageSize != 100 {
t.Errorf("Expected 'block_storage_size' to be set to '%d', but got '%d'.", raw["block_storage_size"], c.BlockStorageSize)
}
if c.ServerImageDescription != "server description" {
t.Errorf("Expected 'server_image_description_key' to be set to '%s', but got '%s'.", raw["server_image_description"], c.ServerImageDescription)
}
if c.Region != "Korea" {
t.Errorf("Expected 'region' to be set to '%s', but got '%s'.", raw["server_image_description"], c.Region)
}
}
func TestEmptyConfig(t *testing.T) {
raw := new(map[string]interface{})
var c Config
_, err := c.Prepare(raw)
if err == nil {
t.Error("Expected Config to require 'access_key', 'secret_key' and some mandatory fields, but it did not")
}
if strings.Contains(err.Error(), "access_key is required") {
t.Error("Expected Config to require 'access_key', but it did not")
}
if strings.Contains(err.Error(), "secret_key is required") {
t.Error("Expected Config to require 'secret_key', but it did not")
}
if strings.Contains(err.Error(), "server_image_product_code or member_server_image_no is required") {
t.Error("Expected Config to require 'server_image_product_code' or 'member_server_image_no', but it did not")
}
}
func TestExistsBothServerImageProductCodeAndMemberServerImageNoConfig(t *testing.T) {
raw := map[string]interface{}{
"access_key": "access_key",
"secret_key": "secret_key",
"server_image_product_code": "SPSW0WINNT000016",
"server_product_code": "SPSVRSSD00000011",
"member_server_image_no": "2440",
}
var c Config
_, err := c.Prepare(raw)
if strings.Contains(err.Error(), "Only one of server_image_product_code and member_server_image_no can be set") {
t.Error("Expected Config to require Only one of 'server_image_product_code' and 'member_server_image_no' can be set, but it did not")
}
}

View File

@ -1,66 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreateAccessControlGroupShouldFailIfOperationCreateAccessControlGroupFails(t *testing.T) {
var testSubject = &StepCreateAccessControlGroup{
CreateAccessControlGroup: func() (string, error) { return "", fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{
Region: "Korea",
SupportVPC: true,
},
}
stateBag := createTestStateBagStepCreateAccessControlGroup()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreateAccessControlGroupShouldPassIfOperationCreateAccessControlGroupPasses(t *testing.T) {
var testSubject = &StepCreateAccessControlGroup{
CreateAccessControlGroup: func() (string, error) { return "123", nil },
AddAccessControlGroupRule: func(acgNo string) error {
return nil
},
Say: func(message string) {},
Error: func(error) {},
Config: &Config{
Region: "Korea",
SupportVPC: true,
},
}
stateBag := createTestStateBagStepCreateAccessControlGroup()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreateAccessControlGroup() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
return stateBag
}

View File

@ -1,65 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreateBlockStorageInstanceShouldFailIfOperationCreateBlockStorageInstanceFails(t *testing.T) {
var testSubject = &StepCreateBlockStorage{
CreateBlockStorage: func(serverInstanceNo string) (*string, error) { return nil, fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
Config: new(Config),
}
testSubject.Config.BlockStorageSize = 10
stateBag := createTestStateBagStepCreateBlockStorageInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreateBlockStorageInstanceShouldPassIfOperationCreateBlockStorageInstancePasses(t *testing.T) {
var instanceNo = "a"
var testSubject = &StepCreateBlockStorage{
CreateBlockStorage: func(serverInstanceNo string) (*string, error) { return &instanceNo, nil },
Say: func(message string) {},
Error: func(e error) {},
Config: new(Config),
}
testSubject.Config.BlockStorageSize = 10
stateBag := createTestStateBagStepCreateBlockStorageInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreateBlockStorageInstance() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("instance_no", "a")
return stateBag
}

View File

@ -1,64 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreateInitScriptShouldFailIfOperationCreateInitScriptFails(t *testing.T) {
var testSubject = &StepCreateInitScript{
CreateInitScript: func() (string, error) { return "", fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{
Region: "Korea",
SupportVPC: true,
UserData: "test",
},
}
stateBag := createTestStateBagStepCreateInitScript()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreateInitScriptShouldPassIfOperationCreateInitScriptPasses(t *testing.T) {
var testSubject = &StepCreateInitScript{
CreateInitScript: func() (string, error) { return "123", nil },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{
Region: "Korea",
SupportVPC: true,
},
}
stateBag := createTestStateBagStepCreateInitScript()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreateInitScript() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
return stateBag
}

View File

@ -1,55 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreateLoginKeyShouldFailIfOperationCreateLoginKeyFails(t *testing.T) {
var testSubject = &StepCreateLoginKey{
CreateLoginKey: func() (*LoginKey, error) { return nil, fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateLoginKey()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreateLoginKeyShouldPassIfOperationCreateLoginKeyPasses(t *testing.T) {
var testSubject = &StepCreateLoginKey{
CreateLoginKey: func() (*LoginKey, error) { return &LoginKey{"a", "b"}, nil },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateLoginKey()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreateLoginKey() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
return stateBag
}

View File

@ -1,69 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/NaverCloudPlatform/ncloud-sdk-go-v2/ncloud"
"github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreatePublicIPInstanceShouldFailIfOperationCreatePublicIPInstanceFails(t *testing.T) {
var testSubject = &StepCreatePublicIP{
CreatePublicIP: func(serverInstanceNo string) (*server.PublicIpInstance, error) {
return nil, fmt.Errorf("!! Unit Test FAIL !!")
},
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateServerImage()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreatePublicIPInstanceShouldPassIfOperationCreatePublicIPInstancePasses(t *testing.T) {
c := new(Config)
c.Comm.Prepare(nil)
c.Comm.Type = "ssh"
var testSubject = &StepCreatePublicIP{
CreatePublicIP: func(serverInstanceNo string) (*server.PublicIpInstance, error) {
return &server.PublicIpInstance{PublicIpInstanceNo: ncloud.String("a"), PublicIp: ncloud.String("b")}, nil
},
Say: func(message string) {},
Error: func(e error) {},
Config: c,
}
stateBag := createTestStateBagStepCreatePublicIPInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreatePublicIPInstance() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("instance_no", "a")
return stateBag
}

View File

@ -1,60 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreateServerImageShouldFailIfOperationCreateServerImageFails(t *testing.T) {
var testSubject = &StepCreateServerImage{
CreateServerImage: func(serverInstanceNo string) (*server.MemberServerImage, error) {
return nil, fmt.Errorf("!! Unit Test FAIL !!")
},
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateServerImage()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreateServerImageShouldPassIfOperationCreateServerImagePasses(t *testing.T) {
var testSubject = &StepCreateServerImage{
CreateServerImage: func(serverInstanceNo string) (*server.MemberServerImage, error) { return nil, nil },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateServerImage()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreateServerImage() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("instance_no", "a")
return stateBag
}

View File

@ -1,62 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepCreateServerInstanceShouldFailIfOperationCreateFails(t *testing.T) {
var testSubject = &StepCreateServerInstance{
CreateServerInstance: func(loginKeyName string, feeSystemTypeCode string, state multistep.StateBag) (string, error) {
return "", fmt.Errorf("!! Unit Test FAIL !!")
},
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateServerInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepCreateServerInstanceShouldPassIfOperationCreatePasses(t *testing.T) {
var testSubject = &StepCreateServerInstance{
CreateServerInstance: func(loginKeyName string, feeSystemTypeCode string, state multistep.StateBag) (string, error) {
return "", nil
},
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepCreateServerInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepCreateServerInstance() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("login_key", &LoginKey{"a", "b"})
stateBag.Put("zone_no", "1")
return stateBag
}

View File

@ -1,59 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepDeleteBlockStorageInstanceShouldFailIfOperationDeleteBlockStorageInstanceFails(t *testing.T) {
var testSubject = &StepDeleteBlockStorage{
DeleteBlockStorage: func(blockStorageNo string) error { return fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{BlockStorageSize: 10},
}
stateBag := createTestStateBagStepDeleteBlockStorageInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepDeleteBlockStorageInstanceShouldPassIfOperationDeleteBlockStorageInstancePasses(t *testing.T) {
var testSubject = &StepDeleteBlockStorage{
DeleteBlockStorage: func(blockStorageNo string) error { return nil },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{BlockStorageSize: 10},
}
stateBag := createTestStateBagStepDeleteBlockStorageInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepDeleteBlockStorageInstance() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("instance_no", "1")
return stateBag
}

View File

@ -1,60 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepGetRootPasswordShouldFailIfOperationGetRootPasswordFails(t *testing.T) {
var testSubject = &StepGetRootPassword{
GetRootPassword: func(string, string) (string, error) { return "", fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{},
}
stateBag := DeleteTestStateBagStepGetRootPassword()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepGetRootPasswordShouldPassIfOperationGetRootPasswordPasses(t *testing.T) {
var testSubject = &StepGetRootPassword{
GetRootPassword: func(string, string) (string, error) { return "a", nil },
Say: func(message string) {},
Error: func(e error) {},
Config: &Config{},
}
stateBag := DeleteTestStateBagStepGetRootPassword()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func DeleteTestStateBagStepGetRootPassword() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("login_key", &LoginKey{"a", "b"})
stateBag.Put("instance_no", "a")
return stateBag
}

View File

@ -1,56 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepStopServerInstanceShouldFailIfOperationStopFails(t *testing.T) {
var testSubject = &StepStopServerInstance{
StopServerInstance: func(serverInstanceNo string) error { return fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepStopServerInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepStopServerInstanceShouldPassIfOperationStopPasses(t *testing.T) {
var testSubject = &StepStopServerInstance{
StopServerInstance: func(serverInstanceNo string) error { return nil },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepStopServerInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepStopServerInstance() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("instance_no", "a")
return stateBag
}

View File

@ -1,56 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepTerminateServerInstanceShouldFailIfOperationTerminationFails(t *testing.T) {
var testSubject = &StepTerminateServerInstance{
TerminateServerInstance: func(serverInstanceNo string) error { return fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepTerminateServerInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepTerminateServerInstanceShouldPassIfOperationTerminationPasses(t *testing.T) {
var testSubject = &StepTerminateServerInstance{
TerminateServerInstance: func(serverInstanceNo string) error { return nil },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepTerminateServerInstance()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepTerminateServerInstance() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
stateBag.Put("instance_no", "a")
return stateBag
}

View File

@ -1,55 +0,0 @@
package ncloud
import (
"context"
"fmt"
"testing"
"github.com/hashicorp/packer-plugin-sdk/multistep"
)
func TestStepValidateTemplateShouldFailIfValidateFails(t *testing.T) {
var testSubject = &StepValidateTemplate{
Validate: func() error { return fmt.Errorf("!! Unit Test FAIL !!") },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepValidateTemplate()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionHalt {
t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == false {
t.Fatal("Expected the step to set stateBag['Error'], but it was not.")
}
}
func TestStepValidateTemplateShouldPassIfValidatePasses(t *testing.T) {
var testSubject = &StepValidateTemplate{
Validate: func() error { return nil },
Say: func(message string) {},
Error: func(e error) {},
}
stateBag := createTestStateBagStepValidateTemplate()
var result = testSubject.Run(context.Background(), stateBag)
if result != multistep.ActionContinue {
t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result)
}
if _, ok := stateBag.GetOk("error"); ok == true {
t.Fatalf("Expected the step to not set stateBag['Error'], but it was.")
}
}
func createTestStateBagStepValidateTemplate() multistep.StateBag {
stateBag := new(multistep.BasicStateBag)
return stateBag
}

View File

@ -1,13 +0,0 @@
package version
import (
"github.com/hashicorp/packer-plugin-sdk/version"
packerVersion "github.com/hashicorp/packer/version"
)
var NCloudPluginVersion *version.PluginVersion
func init() {
NCloudPluginVersion = version.InitializePluginVersion(
packerVersion.Version, packerVersion.VersionPrerelease)
}

View File

@ -28,7 +28,6 @@ import (
linodebuilder "github.com/hashicorp/packer/builder/linode"
lxcbuilder "github.com/hashicorp/packer/builder/lxc"
lxdbuilder "github.com/hashicorp/packer/builder/lxd"
ncloudbuilder "github.com/hashicorp/packer/builder/ncloud"
nullbuilder "github.com/hashicorp/packer/builder/null"
oneandonebuilder "github.com/hashicorp/packer/builder/oneandone"
openstackbuilder "github.com/hashicorp/packer/builder/openstack"
@ -97,7 +96,6 @@ var Builders = map[string]packersdk.Builder{
"linode": new(linodebuilder.Builder),
"lxc": new(lxcbuilder.Builder),
"lxd": new(lxdbuilder.Builder),
"ncloud": new(ncloudbuilder.Builder),
"null": new(nullbuilder.Builder),
"oneandone": new(oneandonebuilder.Builder),
"openstack": new(openstackbuilder.Builder),

View File

@ -25,6 +25,7 @@ import (
googlecomputebuilder "github.com/hashicorp/packer-plugin-googlecompute/builder/googlecompute"
googlecomputeexportpostprocessor "github.com/hashicorp/packer-plugin-googlecompute/post-processor/googlecompute-export"
googlecomputeimportpostprocessor "github.com/hashicorp/packer-plugin-googlecompute/post-processor/googlecompute-import"
ncloudbuilder "github.com/hashicorp/packer-plugin-ncloud/builder/ncloud"
proxmoxclone "github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/clone"
proxmoxiso "github.com/hashicorp/packer-plugin-proxmox/builder/proxmox/iso"
qemubuilder "github.com/hashicorp/packer-plugin-qemu/builder/qemu"
@ -56,6 +57,7 @@ var VendoredBuilders = map[string]packersdk.Builder{
"amazon-instance": new(amazoninstancebuilder.Builder),
"docker": new(dockerbuilder.Builder),
"googlecompute": new(googlecomputebuilder.Builder),
"ncloud": new(ncloudbuilder.Builder),
"proxmox": new(proxmoxiso.Builder),
"proxmox-iso": new(proxmoxiso.Builder),
"proxmox-clone": new(proxmoxclone.Builder),

3
go.mod
View File

@ -10,7 +10,6 @@ require (
github.com/Azure/go-autorest/autorest/date v0.2.0
github.com/Azure/go-autorest/autorest/to v0.3.0
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.1.7
github.com/aliyun/alibaba-cloud-sdk-go v0.0.0-20190418113227-25233c783f4e
github.com/aliyun/aliyun-oss-go-sdk v0.0.0-20170113022742-e6dbea820a9f
github.com/antihax/optional v1.0.0
@ -48,6 +47,7 @@ require (
github.com/hashicorp/packer-plugin-ansible v0.0.2
github.com/hashicorp/packer-plugin-docker v0.0.7
github.com/hashicorp/packer-plugin-googlecompute v0.0.1
github.com/hashicorp/packer-plugin-ncloud v0.0.2
github.com/hashicorp/packer-plugin-proxmox v0.0.1
github.com/hashicorp/packer-plugin-qemu v0.0.1
github.com/hashicorp/packer-plugin-sdk v0.2.0
@ -68,7 +68,6 @@ require (
github.com/mitchellh/panicwrap v1.0.0
github.com/mitchellh/prefixedio v0.0.0-20151214002211-6e6954073784
github.com/mitchellh/reflectwalk v1.0.0
github.com/olekukonko/tablewriter v0.0.0-20180105111133-96aac992fc8b
github.com/oracle/oci-go-sdk/v36 v36.2.0
github.com/outscale/osc-sdk-go/osc v0.0.0-20200722135656-d654809d0699
github.com/pierrec/lz4 v2.0.5+incompatible

10
go.sum
View File

@ -83,8 +83,8 @@ github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022 h1:y8Gs8CzNf
github.com/ChrisTrenkamp/goxpath v0.0.0-20170922090931-c385f95c6022/go.mod h1:nuWgzSkT5PnyOd+272uUmV0dnAnAn42Mk7PiQC5VzN4=
github.com/DataDog/datadog-go v2.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.1.0/go.mod h1:P+3VS0ETiQPyWOx3vB/oeC8J3qd7jnVZLYAFwWgGRt8=
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.1.7 h1:Kpnbe19WkzVPpLLdAus4LkpNJ+pzLpfAViOUuvPcCqA=
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.1.7/go.mod h1:P+3VS0ETiQPyWOx3vB/oeC8J3qd7jnVZLYAFwWgGRt8=
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.2.0 h1:c7GgSBfMt51UGM4SI1F7IFOokOVZO+uxNcJL3Xsmkp4=
github.com/NaverCloudPlatform/ncloud-sdk-go-v2 v1.2.0/go.mod h1:P+3VS0ETiQPyWOx3vB/oeC8J3qd7jnVZLYAFwWgGRt8=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/Telmate/proxmox-api-go v0.0.0-20200715182505-ec97c70ba887/go.mod h1:OGWyIMJ87/k/GCz8CGiWB2HOXsOVDM6Lpe/nFPkC4IQ=
@ -463,6 +463,8 @@ github.com/hashicorp/packer-plugin-docker v0.0.7 h1:hMTrH7vrkFIjphtbbtpuzffTzSjM
github.com/hashicorp/packer-plugin-docker v0.0.7/go.mod h1:IpeKlwOSy2kdgQcysqd3gCsoqjME9jtmpFoKxn7RRNI=
github.com/hashicorp/packer-plugin-googlecompute v0.0.1 h1:Shjio88MraB+ocj0VI5+M65r4UBKbYI4eCqLNyPXKEo=
github.com/hashicorp/packer-plugin-googlecompute v0.0.1/go.mod h1:MfV898IrEMpKH6wVnvOI5Tkhxm2snf3QxwVqV4k3bNI=
github.com/hashicorp/packer-plugin-ncloud v0.0.2 h1:MGvGkOVfzeosqOSs5dteghLwv9VRcRxTuLoLX1ssUag=
github.com/hashicorp/packer-plugin-ncloud v0.0.2/go.mod h1:Hud2R1pkky96TQy3TPTTrr9Kej4b/4dqC/v+uEE0VDY=
github.com/hashicorp/packer-plugin-proxmox v0.0.1 h1:nwfQtfcfV4Gx4aiX1OQD/FoZvWCt2L4qaRYY7zTJ8L0=
github.com/hashicorp/packer-plugin-proxmox v0.0.1/go.mod h1:3URutEWX1yy10qcHNJncS4OMpZknA1FyvlrfL+5usYk=
github.com/hashicorp/packer-plugin-qemu v0.0.1 h1:yGnmWf4Z+ZmOJXJF6w23V2KChtTCiPHsFnfg7+LRu74=
@ -586,6 +588,7 @@ github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOA
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
github.com/mattn/go-runewidth v0.0.10 h1:CoZ3S2P7pvtP45xOtBw+/mDL2z0RKI576gSkzRRpdGg=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-tty v0.0.0-20191112051231-74040eebce08 h1:8YAWbq7rJqfbc6IaAvA2eCQuOQvf6Bs4vHKcOyWw//E=
@ -636,8 +639,9 @@ github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3Rllmb
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d h1:VhgPp6v9qf9Agr/56bj7Y/xa04UccTW04VP0Qed4vnQ=
github.com/nu7hatch/gouuid v0.0.0-20131221200532-179d4d0c4d8d/go.mod h1:YUTz3bUH2ZwIWBy3CJBeOBEugqcmXREj14T+iG/4k4U=
github.com/oklog/run v1.0.0/go.mod h1:dlhp/R75TPv97u0XWUtDeV/lRKWPKSdTuV0TZvrmrQA=
github.com/olekukonko/tablewriter v0.0.0-20180105111133-96aac992fc8b h1:LGItPaClbzopugAomw5VFKnG3h1dUr9QW5KOU+m8gu0=
github.com/olekukonko/tablewriter v0.0.0-20180105111133-96aac992fc8b/go.mod h1:vsDQFd/mU46D+Z4whnwzcISnGGzXWMclvtLoiIKAKIo=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/oracle/oci-go-sdk v18.0.0+incompatible h1:FLV4KixsVfF3rwyVTMI6Ryp/Q+OSb9sR5TawbfjFLN4=
github.com/oracle/oci-go-sdk v18.0.0+incompatible/go.mod h1:VQb79nF8Z2cwLkLS35ukwStZIg5F66tcBccjip/j888=

View File

@ -5,8 +5,8 @@
## Overview
This API client was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the [swagger-spec](https://github.com/swagger-api/swagger-spec) from a remote server, you can easily generate an API client.
- API version: 2020-11-18T09:44:01Z
- Package version: 1.1.3
- API version: 2019-10-17T10:28:43Z
- Package version: 1.1.1
- Build package: io.swagger.codegen.languages.NcpGoForNcloudClientCodegen
## Installation
@ -26,7 +26,6 @@ Class | Method | HTTP request | Description
*V2Api* | [**AssociatePublicIpWithServerInstance**](docs/V2Api.md#associatepublicipwithserverinstance) | **Post** /associatePublicIpWithServerInstance |
*V2Api* | [**AttachBlockStorageInstance**](docs/V2Api.md#attachblockstorageinstance) | **Post** /attachBlockStorageInstance |
*V2Api* | [**AttachNetworkInterface**](docs/V2Api.md#attachnetworkinterface) | **Post** /attachNetworkInterface |
*V2Api* | [**ChangeBlockStorageVolumeSize**](docs/V2Api.md#changeblockstoragevolumesize) | **Post** /changeBlockStorageVolumeSize |
*V2Api* | [**ChangeNasVolumeSize**](docs/V2Api.md#changenasvolumesize) | **Post** /changeNasVolumeSize |
*V2Api* | [**ChangeServerInstanceSpec**](docs/V2Api.md#changeserverinstancespec) | **Post** /changeServerInstanceSpec |
*V2Api* | [**CreateBlockStorageInstance**](docs/V2Api.md#createblockstorageinstance) | **Post** /createBlockStorageInstance |
@ -101,8 +100,6 @@ Class | Method | HTTP request | Description
- [AttachNetworkInterfaceResponse](docs/AttachNetworkInterfaceResponse.md)
- [BlockStorageInstance](docs/BlockStorageInstance.md)
- [BlockStorageSnapshotInstance](docs/BlockStorageSnapshotInstance.md)
- [ChangeBlockStorageVolumeSizeRequest](docs/ChangeBlockStorageVolumeSizeRequest.md)
- [ChangeBlockStorageVolumeSizeResponse](docs/ChangeBlockStorageVolumeSizeResponse.md)
- [ChangeNasVolumeSizeRequest](docs/ChangeNasVolumeSizeRequest.md)
- [ChangeNasVolumeSizeResponse](docs/ChangeNasVolumeSizeResponse.md)
- [ChangeServerInstanceSpecRequest](docs/ChangeServerInstanceSpecRequest.md)

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
@ -36,7 +37,7 @@ var (
xmlCheck = regexp.MustCompile("(?i:[application|text]/xml)")
)
// APIClient manages communication with the server API v2020-11-18T09:44:01Z
// APIClient manages communication with the server API v2019-10-17T10:28:43Z
// In most cases there should be only one, shared, APIClient.
type APIClient struct {
cfg *ncloud.Configuration
@ -314,67 +315,90 @@ func setBody(body interface{}, contentType string) (bodyBuf *bytes.Buffer, err e
bodyBuf = &bytes.Buffer{}
}
bodyBuf.WriteString("responseFormatType=json")
result := "responseFormatType=json"
s := reflect.ValueOf(body).Elem()
bodyBuf.WriteString(buildQueryString(s, ""))
typeOfT := s.Type()
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
if !f.IsNil() {
key := toLowerFirstChar(typeOfT.Field(i).Name)
if f.Kind() == reflect.Ptr {
switch f.Type().String() {
case "*string":
result += fmt.Sprintf("&%s=%s", key, url.QueryEscape(ncloud.StringValue(f.Interface().(*string))))
case "*bool":
result += fmt.Sprintf("&%s=%t", key, ncloud.BoolValue(f.Interface().(*bool)))
case "*int":
result += fmt.Sprintf("&%s=%d", key, ncloud.IntValue(f.Interface().(*int)))
case "*int32":
result += fmt.Sprintf("&%s=%d", key, ncloud.Int32Value(f.Interface().(*int32)))
case "*int64":
result += fmt.Sprintf("&%s=%d", key, ncloud.Int64Value(f.Interface().(*int64)))
case "*float32":
result += fmt.Sprintf("&%s=%f", key, ncloud.Float32Value(f.Interface().(*float32)))
}
} else if f.Kind() == reflect.Slice {
for i := 0; i < f.Len(); i++ {
item := f.Index(i)
if item.Elem().Kind() == reflect.Struct {
item := item.Elem()
typeOfSubItem := item.Type()
for j := 0; j < item.NumField(); j++ {
subItem := item.Field(j)
subKey := toLowerFirstChar(typeOfSubItem.Field(j).Name)
switch subItem.Type().String() {
case "*string":
result += fmt.Sprintf("&%s.%d.%s=%s", key, i+1, subKey, url.QueryEscape(ncloud.StringValue(subItem.Interface().(*string))))
case "*bool":
result += fmt.Sprintf("&%s.%d.%s=%t", key, i+1, subKey, ncloud.BoolValue(subItem.Interface().(*bool)))
case "*int":
result += fmt.Sprintf("&%s.%d.%s=%d", key, i+1, subKey, ncloud.IntValue(subItem.Interface().(*int)))
case "*int32":
result += fmt.Sprintf("&%s.%d.%s=%d", key, i+1, subKey, ncloud.Int32Value(subItem.Interface().(*int32)))
case "*int64":
result += fmt.Sprintf("&%s.%d.%s=%d", key, i+1, subKey, ncloud.Int64Value(subItem.Interface().(*int64)))
case "*float32":
result += fmt.Sprintf("&%s.%d.%s=%f", key, i+1, subKey, ncloud.Float32Value(subItem.Interface().(*float32)))
}
}
} else {
switch item.Type().String() {
case "*string":
result += fmt.Sprintf("&%s.%d=%s", key, i+1, url.QueryEscape(*item.Interface().(*string)))
case "*bool":
result += fmt.Sprintf("&%s.%d.%s=%t", key, i+1, ncloud.BoolValue(item.Interface().(*bool)))
case "*int":
result += fmt.Sprintf("&%s.%d.%s=%d", key, i+1, item.Interface().(*int))
case "*int32":
result += fmt.Sprintf("&%s.%d.%s=%d", key, i+1, item.Interface().(*int32))
case "*int64":
result += fmt.Sprintf("&%s.%d.%s=%d", key, i+1, item.Interface().(*int64))
case "*float32":
result += fmt.Sprintf("&%s.%d.%s=%f", key, i+1, item.Interface().(*float32))
}
}
}
}
}
}
if err != nil {
return nil, err
}
bodyBuf.WriteString(result)
if bodyBuf.Len() == 0 {
err = fmt.Errorf("invalid body type %s", contentType)
err = fmt.Errorf("Invalid body type %s", contentType)
return nil, err
}
return bodyBuf, nil
}
func buildQueryString(s reflect.Value, prefix string) string {
bodyBuf := &bytes.Buffer{}
if s.Kind() == reflect.Struct {
for i := 0; i < s.NumField(); i++ {
f := s.Field(i)
if !f.IsNil() {
name := toLowerFirstChar(s.Type().Field(i).Name)
if len(prefix) > 0 {
bodyBuf.WriteString(buildQueryString(f, fmt.Sprintf("%s.%s", prefix, name)))
} else {
bodyBuf.WriteString(buildQueryString(f, name))
}
}
}
} else if s.Kind() == reflect.Slice {
for i := 0; i < s.Len(); i++ {
item := s.Index(i)
bodyBuf.WriteString(buildQueryString(item.Elem(), fmt.Sprintf("%s.%d", prefix, i+1)))
}
} else if s.Kind() == reflect.Ptr {
bodyBuf.WriteString(fmt.Sprintf("&%s=%s", prefix, convertToString(s)))
} else if s.Kind() == reflect.String {
bodyBuf.WriteString(fmt.Sprintf("&%s=%s", prefix, s.Interface()))
}
return bodyBuf.String()
}
func convertToString(f reflect.Value) string {
switch f.Type().String() {
case "*string":
return url.QueryEscape(ncloud.StringValue(f.Interface().(*string)))
case "*bool":
return fmt.Sprintf("%t", *f.Interface().(*bool))
case "*int":
return fmt.Sprintf("%d", *f.Interface().(*int))
case "*int32":
return fmt.Sprintf("%d", *f.Interface().(*int32))
case "*int64":
return fmt.Sprintf("%d", *f.Interface().(*int64))
case "*float32":
return fmt.Sprintf("%f", *f.Interface().(*float32))
}
return ""
}
// detectContentType method is used to figure out `Request.Body` content type for request header
func detectContentType(body interface{}) string {
contentType := "text/plain; charset=utf-8"

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -1,18 +0,0 @@
/*
* server
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package server
type ChangeBlockStorageVolumeSizeRequest struct {
// 블록스토리지인스턴스번호
BlockStorageInstanceNo *string `json:"blockStorageInstanceNo"`
// 블록스토리지사이즈
BlockStorageSize *int64 `json:"blockStorageSize"`
}

View File

@ -1,22 +0,0 @@
/*
* server
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
package server
type ChangeBlockStorageVolumeSizeResponse struct {
RequestId *string `json:"requestId,omitempty"`
ReturnCode *string `json:"returnCode,omitempty"`
ReturnMessage *string `json:"returnMessage,omitempty"`
TotalRows *int32 `json:"totalRows,omitempty"`
BlockStorageInstanceList []*BlockStorageInstance `json:"blockStorageInstanceList,omitempty"`
}

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/
@ -27,7 +28,7 @@ func NewConfiguration(apiKey *ncloud.APIKey) *ncloud.Configuration {
cfg := &ncloud.Configuration{
BasePath: "https://ncloud.apigw.ntruss.com/server/v2",
DefaultHeader: make(map[string]string),
UserAgent: "server/1.1.3/go",
UserAgent: "server/1.1.1/go",
APIKey: apiKey,
}
if os.Getenv("NCLOUD_API_GW") != "" {

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

View File

@ -3,6 +3,7 @@
*
* <br/>https://ncloud.apigw.ntruss.com/server/v2
*
* API version: 2019-10-17T10:28:43Z
* Generated by: Swagger Codegen (https://github.com/swagger-api/swagger-codegen.git)
*/

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