github.com/angdraug/packer@v1.3.2/builder/oracle/oci/step_instance_info.go (about)

     1  package oci
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"github.com/hashicorp/packer/helper/multistep"
     8  	"github.com/hashicorp/packer/packer"
     9  )
    10  
    11  type stepInstanceInfo struct{}
    12  
    13  func (s *stepInstanceInfo) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
    14  	var (
    15  		driver = state.Get("driver").(Driver)
    16  		ui     = state.Get("ui").(packer.Ui)
    17  		id     = state.Get("instance_id").(string)
    18  	)
    19  
    20  	ip, err := driver.GetInstanceIP(ctx, id)
    21  	if err != nil {
    22  		err = fmt.Errorf("Error getting instance's IP: %s", err)
    23  		ui.Error(err.Error())
    24  		state.Put("error", err)
    25  		return multistep.ActionHalt
    26  	}
    27  
    28  	state.Put("instance_ip", ip)
    29  
    30  	ui.Say(fmt.Sprintf("Instance has IP: %s.", ip))
    31  
    32  	return multistep.ActionContinue
    33  }
    34  
    35  func (s *stepInstanceInfo) Cleanup(state multistep.StateBag) {
    36  	// no cleanup
    37  }