Exemple #1
0
	Run: func(cmd *cobra.Command, args []string) {
		if (len(args) < 2 && defaultName == "") ||
			(len(args) < 1 && defaultName != "") {
			cmd.Usage()
			os.Exit(1)
		}
		var name, count string
		if len(args) == 1 {
			name = defaultName
			count = args[0]
		} else {
			name = args[0]
			count = args[1]
		}
		loadStdinUserdata()
		provider, err := providers.Get(providerName, true)
		fatal(err)
		existing := existingHosts(provider, name)
		desired := desiredHosts(name, count)
		hosts := append(strSet(existing, desired), namespace+name)
		finished := progressBar(".", 2)
		parallelWait(hosts, func(_ int, host string, wg *sync.WaitGroup) {
			defer wg.Done()
			if !strIn(host, desired) {
				fatal(provider.Destroy(host))
				return
			}
			if strIn(host, desired) && !strIn(host, existing) {
				fatal(provider.Create(newHost(host)))
				return
			}
Exemple #2
0
	"github.com/MattAitchison/env"
	"github.com/gliderlabs/hostctl/providers"
	"github.com/spf13/cobra"
)

var (
	exportMode  bool
	secretsMode bool
)

func init() {
	envCmd.Flags().BoolVarP(&exportMode,
		"export", "e", false, "export vars for sourcing later")
	envCmd.Flags().BoolVarP(&secretsMode,
		"secrets", "s", false, "show secrets or include in export")
	Hostctl.AddCommand(envCmd)
}

var envCmd = &cobra.Command{
	Use:   "env",
	Short: "Show relevant environment",
	Run: func(cmd *cobra.Command, args []string) {
		env.PrintEnv(os.Stdout, exportMode, secretsMode)
		provider, _ := providers.Get(providerName, false)
		if provider != nil && provider.Env() != nil {
			provider.Env().PrintEnv(os.Stdout, exportMode, secretsMode)
		}
	},
}