cmd

package
v0.0.0-...-5169047 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2019 License: Apache-2.0 Imports: 20 Imported by: 1

Documentation

Overview

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Copyright Jetstack Ltd. See LICENSE for details.

Index

Constants

This section is empty.

Variables

View Source
var AppName string = "vault-helper"
View Source
var CertCmd = &cobra.Command{
	Use: "cert [cert role] [common name] [destination path]",

	Short: "Create local key to generate a CSR. Call vault with CSR for specified cert role.",
	Run: func(cmd *cobra.Command, args []string) {
		log, err := LogLevel(cmd)
		if err != nil {
			Must(err)
		}

		i, err := newInstanceToken(cmd)
		if err != nil {
			Must(err)
		}

		if err := i.TokenRenewRun(); err != nil {
			Must(err)
		}

		c := cert.New(log, i)
		if len(args) != 3 {
			Must(fmt.Errorf("wrong number of arguments given. Usage: vault-helper cert [cert role] [common name] [destination path]"))
		}
		if err := setFlagsCert(c, cmd, args); err != nil {
			Must(err)
		}

		if err := c.RunCert(); err != nil {
			Must(err)
		}
	},
}

initCmd represents the init command

View Source
var Must = func(err error) {
	if err != nil {
		logrus.Fatal(err)
	}
}
View Source
var RootCmd = &cobra.Command{
	Use:   "vault-helper",
	Short: "Automates PKI tasks using Hashicorp's Vault as a backend.",
}

RootCmd represents the base command when called without any subcommands

View Source
var SetupCmd = &cobra.Command{
	Use:   "setup [cluster ID]",
	Short: "Setup kubernetes on a running vault server.",
	Run: func(cmd *cobra.Command, args []string) {
		log, err := LogLevel(cmd)
		if err != nil {
			Must(err)
		}

		v, err := vault.NewClient(nil)
		if err != nil {
			Must(err)
		}

		k := kubernetes.New(v, log)
		if err != nil {
			Must(err)
		}

		if len(args) > 0 {
			k.SetClusterID(args[0])
		} else {
			Must(errors.New("no cluster id was given"))
		}

		if err := setFlagsKubernetes(k, cmd); err != nil {
			Must(err)
		}

		if err := k.Ensure(); err != nil {
			Must(err)
		}

		for n, t := range k.InitTokens() {
			log.Infof(n + "-init_token := " + t)
		}
	},
}

initCmd represents the init command

View Source
var Version struct {
	Version   string
	BuildDate string
	Commit    string
}

Functions

func Execute

func Execute()

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func InitCertCmdFlags

func InitCertCmdFlags(cmd *cobra.Command)

func InitSetupFlags

func InitSetupFlags()

func LogLevel

func LogLevel(cmd *cobra.Command) (*logrus.Entry, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL