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

Method LoadExternalComponentsFromConfig

config.go:37–67  ·  view source on GitHub ↗

LoadExternalComponentsFromConfig loads plugins defined in RawBuilders, RawProvisioners, and RawPostProcessors.

()

Source from the content-addressed store, hash-verified

35
36// LoadExternalComponentsFromConfig loads plugins defined in RawBuilders, RawProvisioners, and RawPostProcessors.
37func (c *config) LoadExternalComponentsFromConfig() error {
38 // helper to build up list of plugin paths
39 extractPaths := func(m map[string]string) []string {
40 paths := make([]string, 0, len(m))
41 for _, v := range m {
42 paths = append(paths, v)
43 }
44
45 return paths
46 }
47
48 var pluginPaths []string
49 pluginPaths = append(pluginPaths, extractPaths(c.RawProvisioners)...)
50 pluginPaths = append(pluginPaths, extractPaths(c.RawBuilders)...)
51 pluginPaths = append(pluginPaths, extractPaths(c.RawPostProcessors)...)
52
53 if len(pluginPaths) == 0 {
54 return nil
55 }
56
57 componentList := &strings.Builder{}
58 for _, path := range pluginPaths {
59 fmt.Fprintf(componentList, "- %s\n", path)
60 }
61
62 return fmt.Errorf("Your configuration file describes some legacy components: \n%s"+
63 "Packer does not support these mono-component plugins anymore.\n"+
64 "Please refer to our Installing Plugins docs for an overview of how to manage installation of local plugins:\n"+
65 "https://developer.hashicorp.com/packer/docs/plugins/install-plugins",
66 componentList.String())
67}
68
69// This is a proper packer.BuilderFunc that can be used to load packersdk.Builder
70// implementations from the defined plugins.

Callers 1

loadConfigFunction · 0.95

Calls 2

StringMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected