| 86 | } |
| 87 | |
| 88 | func (c *BuildCommand) RunContext(buildCtx context.Context, cla *BuildArgs) int { |
| 89 | // Set the release only flag if specified as argument |
| 90 | // |
| 91 | // This deactivates the capacity for Packer to load development binaries. |
| 92 | c.CoreConfig.Components.PluginConfig.ReleasesOnly = cla.ReleaseOnly |
| 93 | |
| 94 | packerStarter, ret := c.GetConfig(&cla.MetaArgs) |
| 95 | if ret != 0 { |
| 96 | return ret |
| 97 | } |
| 98 | |
| 99 | diags := packerStarter.DetectPluginBinaries() |
| 100 | ret = writeDiags(c.Ui, nil, diags) |
| 101 | if ret != 0 { |
| 102 | return ret |
| 103 | } |
| 104 | |
| 105 | diags = packerStarter.Initialize(packer.InitializeOptions{ |
| 106 | UseSequential: cla.UseSequential, |
| 107 | }) |
| 108 | |
| 109 | if packer.PackerUseProto { |
| 110 | log.Printf("[TRACE] Using protobuf for communication with plugins") |
| 111 | } |
| 112 | |
| 113 | ret = writeDiags(c.Ui, nil, diags) |
| 114 | if ret != 0 { |
| 115 | return ret |
| 116 | } |
| 117 | |
| 118 | hcpRegistry, diags := registry.New(packerStarter, c.Ui) |
| 119 | ret = writeDiags(c.Ui, nil, diags) |
| 120 | if ret != 0 { |
| 121 | return ret |
| 122 | } |
| 123 | hcpRegistry.Metadata().Gather(GetCleanedBuildArgs(cla)) |
| 124 | |
| 125 | defer hcpRegistry.VersionStatusSummary() |
| 126 | |
| 127 | err := hcpRegistry.PopulateVersion(buildCtx) |
| 128 | if err != nil { |
| 129 | return writeDiags(c.Ui, nil, hcl.Diagnostics{ |
| 130 | &hcl.Diagnostic{ |
| 131 | Summary: "HCP: populating version failed", |
| 132 | Severity: hcl.DiagError, |
| 133 | Detail: err.Error(), |
| 134 | }, |
| 135 | }) |
| 136 | } |
| 137 | |
| 138 | builds, diags := packerStarter.GetBuilds(packer.GetBuildsOptions{ |
| 139 | Only: cla.Only, |
| 140 | Except: cla.Except, |
| 141 | Debug: cla.Debug, |
| 142 | Force: cla.Force, |
| 143 | OnError: cla.OnError, |
| 144 | }) |
| 145 | |