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:
@@ -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{
|
||||
|
||||
Reference in New Issue
Block a user