MCPcopy
hub / github.com/hashicorp/packer / RunContext

Method RunContext

command/build.go:88–454  ·  view source on GitHub ↗
(buildCtx context.Context, cla *BuildArgs)

Source from the content-addressed store, hash-verified

86}
87
88func (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

Callers 2

RunMethod · 0.95

Calls 15

SayMethod · 0.95
ErrorMethod · 0.95
MachineMethod · 0.95
NewFunction · 0.92
writeDiagsFunction · 0.85
GetCleanedBuildArgsFunction · 0.85
GetConfigMethod · 0.80
DetectPluginBinariesMethod · 0.65
InitializeMethod · 0.65
GatherMethod · 0.65
MetadataMethod · 0.65
VersionStatusSummaryMethod · 0.65

Tested by 1