(cla *MetaArgs)
| 137 | } |
| 138 | |
| 139 | func (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 | } |
no test coverage detected