(cla *MetaArgs)
| 99 | } |
| 100 | |
| 101 | func (m *Meta) GetConfig(cla *MetaArgs) (packer.Handler, int) { |
| 102 | cfgType, err := cla.GetConfigType() |
| 103 | if err != nil { |
| 104 | m.Ui.Error(fmt.Sprintf("%q: %s", cla.Path, err)) |
| 105 | return nil, 1 |
| 106 | } |
| 107 | |
| 108 | switch cfgType { |
| 109 | case ConfigTypeHCL2: |
| 110 | packer.CheckpointReporter.SetTemplateType(packer.HCL2Template) |
| 111 | // TODO(azr): allow to pass a slice of files here. |
| 112 | return m.GetConfigFromHCL(cla) |
| 113 | default: |
| 114 | packer.CheckpointReporter.SetTemplateType(packer.JSONTemplate) |
| 115 | // TODO: uncomment once we've polished HCL a bit more. |
| 116 | // c.Ui.Say(`Legacy JSON Configuration Will Be Used. |
| 117 | // The template will be parsed in the legacy configuration style. This style |
| 118 | // will continue to work but users are encouraged to move to the new style. |
| 119 | // See: https://packer.io/guides/hcl |
| 120 | // `) |
| 121 | return m.GetConfigFromJSON(cla) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func (m *Meta) GetConfigFromHCL(cla *MetaArgs) (*hcl2template.PackerConfig, int) { |
| 126 | parser := &hcl2template.Parser{ |
no test coverage detected