MCPcopy Index your code
hub / github.com/hashicorp/packer / GetConfigFromJSON

Method GetConfigFromJSON

command/meta.go:139–168  ·  view source on GitHub ↗
(cla *MetaArgs)

Source from the content-addressed store, hash-verified

137}
138
139func (m *Meta) GetConfigFromJSON(cla *MetaArgs) (packer.Handler, int) {
140 // Parse the template
141 var tpl *template.Template
142 var err error
143 if cla.Path == "" {
144 // here cla validation passed so this means we want a default builder
145 // and we probably are in the console command
146 tpl, err = template.Parse(TiniestBuilder)
147 } else {
148 tpl, err = template.ParseFile(cla.Path)
149 }
150
151 if err != nil {
152 m.Ui.Error(fmt.Sprintf("Failed to parse file as legacy JSON template: "+
153 "if you are using an HCL template, check your file extensions; they "+
154 "should be either *.pkr.hcl or *.pkr.json; see the docs for more "+
155 "details: https://www.packer.io/docs/templates/hcl_templates. \n"+
156 "Original error: %s", err))
157 return nil, 1
158 }
159
160 // Get the core
161 core, err := m.Core(tpl, cla)
162 ret := 0
163 if err != nil {
164 m.Ui.Error(err.Error())
165 ret = 1
166 }
167 return core, ret
168}

Callers 2

GetConfigMethod · 0.95
RunContextMethod · 0.80

Calls 3

CoreMethod · 0.95
ParseMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected