1
0
mirror of https://github.com/openshift/installer.git synced 2026-02-05 15:47:14 +01:00

cmd: exec to terraform plugins' run functions when os.Args[0] is set to plugins' name

If the os.Args[0] has the terraform plugin's name, we run the corresponding plugin's exec function.

By default we always run installer's main.
This commit is contained in:
Abhinav Dahiya
2018-12-14 17:22:24 -08:00
parent 8f49463104
commit 10b4cc733a

View File

@@ -3,11 +3,15 @@ package main
import (
"io/ioutil"
"os"
"path/filepath"
"strings"
"github.com/pkg/errors"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"golang.org/x/crypto/ssh/terminal"
"github.com/openshift/installer/pkg/terraform/exec/plugins"
)
var (
@@ -18,6 +22,19 @@ var (
)
func main() {
if len(os.Args) > 0 {
base := filepath.Base(os.Args[0])
cname := strings.TrimSuffix(base, filepath.Ext(base))
if pluginRunner, ok := plugins.KnownPlugins[cname]; ok {
pluginRunner()
return
}
}
installerMain()
}
func installerMain() {
rootCmd := newRootCmd()
for _, subCmd := range []*cobra.Command{