added functionality to trigger ansibles from cli

This commit is contained in:
2021-08-08 00:21:44 +04:00
parent af4b129bee
commit 5ff6702d9c
12 changed files with 354 additions and 17 deletions

View File

@@ -164,6 +164,23 @@ var CliAction = func(ctx *cli.Context) error {
client.PrettyPrint(trackedContainers)
}
//Executing plugin when the plugin flag is called
// --plugin
if ExecutePlugin != "" {
// The execute plugin requires the container ID provided when being executed
if ID != "" {
err := plugin.RunPluginCli(ExecutePlugin, ID)
if err != nil {
fmt.Println(err)
} else {
fmt.Println("Success")
}
} else {
fmt.Println("provide container ID")
}
}
return nil
}

View File

@@ -6,22 +6,23 @@ import (
// Variables declared for CLI
var (
AddServer string
ViewImages string
CreateVM string
ContainerName string
Ports string
Server bool
RemoveVM string
ID string
Specs string
GPU bool
UpdateServerList bool
ServerList bool
SetDefaultConfig bool
NetworkInterface bool
ViewPlugin bool
AddServer string
ViewImages string
CreateVM string
ContainerName string
Ports string
Server bool
RemoveVM string
ID string
Specs string
GPU bool
UpdateServerList bool
ServerList bool
SetDefaultConfig bool
NetworkInterface bool
ViewPlugin bool
TrackedContainers bool
ExecutePlugin string
)
var AppConfigFlags = []cli.Flag{
@@ -139,4 +140,11 @@ var AppConfigFlags = []cli.Flag{
EnvVars: []string{"TRACKED_CONTAINERS"},
Destination: &TrackedContainers,
},
&cli.StringFlag{
Name: "ExecutePlugin",
Aliases: []string{"plugin"},
Usage: "Plugin which needs to be executed",
EnvVars: []string{"EXECUTE_PLUGIN"},
Destination: &ExecutePlugin,
},
}