Use const for statebag key
This commit is contained in:
parent
f3703a775f
commit
cfe37057bd
|
@ -0,0 +1,5 @@
|
|||
package chroot
|
||||
|
||||
const (
|
||||
stateBagKey_OSDiskResourceID = "os_disk_resource_id"
|
||||
)
|
|
@ -20,7 +20,7 @@ type StepAttachDisk struct {
|
|||
func (s *StepAttachDisk) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
azcli := state.Get("azureclient").(client.AzureClientSet)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
diskResourceID := state.Get("os_disk_resource_id").(string)
|
||||
diskResourceID := state.Get(stateBagKey_OSDiskResourceID).(string)
|
||||
|
||||
ui.Say(fmt.Sprintf("Attaching disk '%s'", diskResourceID))
|
||||
|
||||
|
@ -67,7 +67,7 @@ func (s *StepAttachDisk) CleanupFunc(state multistep.StateBag) error {
|
|||
if s.attached {
|
||||
azcli := state.Get("azureclient").(client.AzureClientSet)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
diskResourceID := state.Get("os_disk_resource_id").(string)
|
||||
diskResourceID := state.Get(stateBagKey_OSDiskResourceID).(string)
|
||||
|
||||
ui.Say(fmt.Sprintf("Detaching disk '%s'", diskResourceID))
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ func TestStepAttachDisk_Run(t *testing.T) {
|
|||
state := new(multistep.BasicStateBag)
|
||||
state.Put("azureclient", &client.AzureClientSetMock{})
|
||||
state.Put("ui", ui)
|
||||
state.Put("os_disk_resource_id", "/subscriptions/12345/resourceGroups/group1/providers/Microsoft.Compute/disks/disk1")
|
||||
state.Put(stateBagKey_OSDiskResourceID, "/subscriptions/12345/resourceGroups/group1/providers/Microsoft.Compute/disks/disk1")
|
||||
|
||||
got := s.Run(context.TODO(), state)
|
||||
if !reflect.DeepEqual(got, tt.want) {
|
||||
|
|
|
@ -28,7 +28,7 @@ type StepCreateImage struct {
|
|||
func (s *StepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
azcli := state.Get("azureclient").(client.AzureClientSet)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
diskResourceID := state.Get("os_disk_resource_id").(string)
|
||||
diskResourceID := state.Get(stateBagKey_OSDiskResourceID).(string)
|
||||
|
||||
ui.Say(fmt.Sprintf("Creating image %s\n using %s for os disk.",
|
||||
s.ImageResourceID,
|
||||
|
|
Loading…
Reference in New Issue