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

Method RunContext

command/plugins_installed.go:43–80  ·  view source on GitHub ↗
(buildCtx context.Context)

Source from the content-addressed store, hash-verified

41}
42
43func (c *PluginsInstalledCommand) RunContext(buildCtx context.Context) int {
44
45 opts := plugingetter.ListInstallationsOptions{
46 PluginDirectory: c.Meta.CoreConfig.Components.PluginConfig.PluginDirectory,
47 BinaryInstallationOptions: plugingetter.BinaryInstallationOptions{
48 OS: runtime.GOOS,
49 ARCH: runtime.GOARCH,
50 Checksummers: []plugingetter.Checksummer{
51 {Type: "sha256", Hash: sha256.New()},
52 },
53 },
54 }
55
56 if runtime.GOOS == "windows" && opts.Ext == "" {
57 opts.BinaryInstallationOptions.Ext = ".exe"
58 }
59
60 log.Printf("[TRACE] init: %#v", opts)
61
62 // a plugin requirement that matches them all
63 allPlugins := plugingetter.Requirement{
64 Accessor: "",
65 VersionConstraints: nil,
66 Identifier: nil,
67 }
68
69 installations, err := allPlugins.ListInstallations(opts)
70 if err != nil {
71 c.Ui.Error(err.Error())
72 return 1
73 }
74
75 for _, installation := range installations {
76 c.Ui.Message(installation.BinaryPath)
77 }
78
79 return 0
80}

Callers 1

RunMethod · 0.95

Calls 3

ListInstallationsMethod · 0.95
ErrorMethod · 0.65
MessageMethod · 0.45

Tested by

no test coverage detected