本文整理汇总了Golang中github.com/InnovaCo/serve/manifest.Manifest.FindPlugins方法的典型用法代码示例。如果您正苦于以下问题:Golang Manifest.FindPlugins方法的具体用法?Golang Manifest.FindPlugins怎么用?Golang Manifest.FindPlugins使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/InnovaCo/serve/manifest.Manifest
的用法示例。
在下文中一共展示了Manifest.FindPlugins方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
func main() {
manifestFile := kingpin.Flag("manifest", "Path to manifest.yml file.").Default("manifest.yml").String()
plugin := kingpin.Arg("plugin", "Plugin name for run.").String()
vars := *kingpin.Flag("var", "key=value pairs with manifest vars.").StringMap()
dryRun := kingpin.Flag("dry-run", "Show manifest section only").Bool()
noColor := kingpin.Flag("no-color", "Disable colored output").Bool()
pluginData := kingpin.Flag("plugin-data", "Data for plugin").String()
kingpin.Version(version)
kingpin.Parse()
var plugins []manifest.PluginData
var err error
var manifestData *manifest.Manifest
color.NoColor = *noColor
if *pluginData != "" {
manifestData = manifest.LoadJSON(*pluginData)
} else {
manifestData = manifest.Load(*manifestFile, vars)
}
if *plugin == "" && *dryRun {
fmt.Printf("%s\n%s\n%s\n",
color.GreenString(">>> manifest:"),
manifestData.String(),
color.GreenString("<<< manifest: OK\n"))
return
}
if *pluginData != "" {
plugins = []manifest.PluginData{manifestData.GetPluginWithData(*plugin)}
} else {
plugins, err = manifestData.FindPlugins(*plugin)
}
if err != nil {
log.Fatalln(color.RedString("Error find plugins for '%s': %v", *plugin, err))
}
for _, pair := range plugins {
log.Printf("%s\n%s\n\n", color.GreenString(">>> %s:", pair.PluginName), color.CyanString("%s", pair.Data))
if !*dryRun {
if err := pair.Plugin.Run(pair.Data); err != nil {
fmt.Println("")
log.Fatalln(color.RedString("Error on run plugin `%s`: %v", pair.PluginName, err))
} else {
log.Println(color.GreenString("<<< %s: OK", pair.PluginName))
}
}
}
}