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

Method GetConfig

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

Source from the content-addressed store, hash-verified

99}
100
101func (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
125func (m *Meta) GetConfigFromHCL(cla *MetaArgs) (*hcl2template.PackerConfig, int) {
126 parser := &hcl2template.Parser{

Callers 6

RunContextMethod · 0.80
RunContextMethod · 0.80
RunContextMethod · 0.80
RunContextMethod · 0.80
RunContextMethod · 0.80
RunContextMethod · 0.80

Calls 5

GetConfigFromHCLMethod · 0.95
GetConfigFromJSONMethod · 0.95
GetConfigTypeMethod · 0.80
SetTemplateTypeMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected