Use 'github.com/hashicorp/packer/helper/multistep'
This commit is contained in:
parent
5714108ef9
commit
175dd2730f
|
@ -5,7 +5,7 @@ import (
|
|||
"github.com/hashicorp/packer/common"
|
||||
"github.com/hashicorp/packer/helper/communicator"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
// Builder assume this implements packer.Builder
|
||||
|
|
|
@ -2,7 +2,7 @@ package ncloud
|
|||
|
||||
import (
|
||||
packerssh "github.com/hashicorp/packer/communicator/ssh"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"golang.org/x/crypto/ssh"
|
||||
)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func processStepResult(err error, sayError func(error), state multistep.StateBag) multistep.StepAction {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
// StepCreateBlockStorageInstance struct is for making extra block storage
|
||||
|
@ -54,7 +55,7 @@ func (s *StepCreateBlockStorageInstance) createBlockStorageInstance(serverInstan
|
|||
return blockStorageInstanceList.BlockStorageInstance[0].BlockStorageInstanceNo, nil
|
||||
}
|
||||
|
||||
func (s *StepCreateBlockStorageInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepCreateBlockStorageInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
if s.Config.BlockStorageSize == 0 {
|
||||
return processStepResult(nil, s.Error, state)
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepCreateBlockStorageInstanceShouldFailIfOperationCreateBlockStorageInstanceFails(t *testing.T) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type LoginKey struct {
|
||||
|
@ -44,7 +45,7 @@ func (s *StepCreateLoginKey) createLoginKey() (*LoginKey, error) {
|
|||
return &LoginKey{KeyName, privateKey.PrivateKey}, nil
|
||||
}
|
||||
|
||||
func (s *StepCreateLoginKey) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepCreateLoginKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Create Login Key")
|
||||
|
||||
loginKey, err := s.CreateLoginKey()
|
||||
|
|
|
@ -2,8 +2,9 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepCreateLoginKeyShouldFailIfOperationCreateLoginKeyFails(t *testing.T) {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepCreatePublicIPInstance struct {
|
||||
|
@ -84,7 +85,7 @@ func (s *StepCreatePublicIPInstance) createPublicIPInstance(serverInstanceNo str
|
|||
return &publicIPInstance, nil
|
||||
}
|
||||
|
||||
func (s *StepCreatePublicIPInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepCreatePublicIPInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Create Public IP Instance")
|
||||
|
||||
serverInstanceNo := state.Get("InstanceNo").(string)
|
||||
|
|
|
@ -2,10 +2,11 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepCreatePublicIPInstanceShouldFailIfOperationCreatePublicIPInstanceFails(t *testing.T) {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepCreateServerImage struct {
|
||||
|
@ -60,7 +61,7 @@ func (s *StepCreateServerImage) createServerImage(serverInstanceNo string) (*ncl
|
|||
return &serverImage, nil
|
||||
}
|
||||
|
||||
func (s *StepCreateServerImage) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepCreateServerImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Create Server Image")
|
||||
|
||||
serverInstanceNo := state.Get("InstanceNo").(string)
|
||||
|
|
|
@ -2,10 +2,11 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepCreateServerImageShouldFailIfOperationCreateServerImageFails(t *testing.T) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
@ -8,8 +9,8 @@ import (
|
|||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepCreateServerInstance struct {
|
||||
|
@ -81,7 +82,7 @@ func (s *StepCreateServerInstance) createServerInstance(loginKeyName string, zon
|
|||
return s.serverInstanceNo, nil
|
||||
}
|
||||
|
||||
func (s *StepCreateServerInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepCreateServerInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Create Server Instance")
|
||||
|
||||
var loginKey = state.Get("LoginKey").(*LoginKey)
|
||||
|
|
|
@ -2,8 +2,9 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepCreateServerInstanceShouldFailIfOperationCreateFails(t *testing.T) {
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepDeleteBlockStorageInstance struct {
|
||||
|
@ -77,7 +78,7 @@ func (s *StepDeleteBlockStorageInstance) deleteBlockStorageInstance(serverInstan
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *StepDeleteBlockStorageInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepDeleteBlockStorageInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
if s.Config.BlockStorageSize == 0 {
|
||||
return processStepResult(nil, s.Error, state)
|
||||
}
|
||||
|
|
|
@ -2,8 +2,9 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepDeleteBlockStorageInstanceShouldFailIfOperationDeleteBlockStorageInstanceFails(t *testing.T) {
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepGetRootPassword struct {
|
||||
|
@ -42,7 +43,7 @@ func (s *StepGetRootPassword) getRootPassword(serverInstanceNo string, privateKe
|
|||
return rootPassword.RootPassword, nil
|
||||
}
|
||||
|
||||
func (s *StepGetRootPassword) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepGetRootPassword) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Get Root Password")
|
||||
|
||||
serverInstanceNo := state.Get("InstanceNo").(string)
|
||||
|
|
|
@ -2,8 +2,9 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepGetRootPasswordShouldFailIfOperationGetRootPasswordFails(t *testing.T) {
|
||||
|
|
|
@ -1,13 +1,14 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepStopServerInstance struct {
|
||||
|
@ -50,7 +51,7 @@ func (s *StepStopServerInstance) stopServerInstance(serverInstanceNo string) err
|
|||
return nil
|
||||
}
|
||||
|
||||
func (s *StepStopServerInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepStopServerInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Stop Server Instance")
|
||||
|
||||
var serverInstanceNo = state.Get("InstanceNo").(string)
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepStopServerInstanceShouldFailIfOperationStopFails(t *testing.T) {
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package ncloud
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
)
|
||||
|
||||
type StepTerminateServerInstance struct {
|
||||
|
@ -66,7 +67,7 @@ func (s *StepTerminateServerInstance) terminateServerInstance(serverInstanceNo s
|
|||
}
|
||||
}
|
||||
|
||||
func (s *StepTerminateServerInstance) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepTerminateServerInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Terminate Server Instance")
|
||||
|
||||
var serverInstanceNo = state.Get("InstanceNo").(string)
|
||||
|
|
|
@ -2,8 +2,9 @@ package ncloud
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mitchellh/multistep"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepTerminateServerInstanceShouldFailIfOperationTerminationFails(t *testing.T) {
|
||||
|
|
|
@ -2,13 +2,14 @@ package ncloud
|
|||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
ncloud "github.com/NaverCloudPlatform/ncloud-sdk-go/sdk"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
"github.com/hashicorp/packer/packer"
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/olekukonko/tablewriter"
|
||||
)
|
||||
|
||||
|
@ -249,7 +250,7 @@ func (s *StepValidateTemplate) validateTemplate() error {
|
|||
}
|
||||
|
||||
// Run : main funciton for validation a template
|
||||
func (s *StepValidateTemplate) Run(state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepValidateTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
s.Say("Validating deployment template ...")
|
||||
|
||||
err := s.Validate()
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/mitchellh/multistep"
|
||||
"github.com/hashicorp/packer/helper/multistep"
|
||||
)
|
||||
|
||||
func TestStepValidateTemplateShouldFailIfValidateFails(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue