Skip to content

Commit

Permalink
PackerForce is a top-level config
Browse files Browse the repository at this point in the history
Signed-off-by: Tom Duffield <[email protected]>
  • Loading branch information
tduffield committed Jan 29, 2021
1 parent f0a89ce commit 089a00b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions builder/ankavm/step_create_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (s *StepCreateVM) modifyVMProperties(describeResponse client.DescribeRespon
return err
}
err := s.client.Modify(showResponse.Name, "add", "port-forwarding", "--host-port", strconv.Itoa(wantedPortForwardingRule.PortForwardingHostPort), "--guest-port", strconv.Itoa(wantedPortForwardingRule.PortForwardingGuestPort), wantedPortForwardingRule.PortForwardingRuleName)
if !config.PackerConfig.PackerForce { // If force is enabled, just skip
if !config.PackerForce { // If force is enabled, just skip
if err != nil {
return err
}
Expand Down Expand Up @@ -248,7 +248,7 @@ func (s *StepCreateVM) Run(ctx context.Context, state multistep.StateBag) multis

// If the user forces the build (packer build --force), delete the existing VM that would fail the build
exists, err := s.client.Exists(clonedVMName)
if exists && config.PackerConfig.PackerForce {
if exists && config.PackerForce {
ui.Say(fmt.Sprintf("Deleting existing virtual machine %s", clonedVMName))
if err = s.client.Delete(client.DeleteParams{VMName: clonedVMName}); err != nil {
return onError(err)
Expand Down
5 changes: 3 additions & 2 deletions post-processor/ankaregistry/post-processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
"github.com/veertuinc/packer-builder-veertu-anka/client"
)

const BuilderIdImport = "packer.post-processor.veertu-anka-registry"
const BuilderIdRegistry = "packer.post-processor.veertu-anka-registry"

type Config struct {
common.PackerConfig `mapstructure:",squash"`
Expand Down Expand Up @@ -44,6 +44,7 @@ func (p *PostProcessor) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMap

func (p *PostProcessor) Configure(raws ...interface{}) error {
err := config.Decode(&p.config, &config.DecodeOpts{
PluginType: BuilderIdRegistry,
Interpolate: true,
InterpolateContext: &p.config.ctx,
InterpolateFilter: &interpolate.RenderFilter{
Expand Down Expand Up @@ -91,7 +92,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact
}

// If force is true, revert the template tag (if one exists) on the registry so we can push the VM without issue
if p.config.PackerConfig.PackerForce {
if p.config.PackerForce {
var id string

templates, err := ankaClient.RegistryList(registryParams)
Expand Down

0 comments on commit 089a00b

Please sign in to comment.