mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-10-01 01:36:09 -04:00
Use function for commands
instead of func init() and global var
This commit is contained in:
parent
54319e4324
commit
409f6fec65
@ -21,15 +21,20 @@ import (
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
)
|
||||
|
||||
var deployCmd = &cobra.Command{
|
||||
Use: "deploy",
|
||||
Short: "Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation",
|
||||
Long: `Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation.
|
||||
Uses config provided by --config and reads constellation config from its default location.
|
||||
If required, you can override the IP addresses that are used for a deployment by specifying "--ips" and a list of IP addresses.
|
||||
Specifying --bootstrapper will upload the bootstrapper from the specified path.`,
|
||||
RunE: runDeploy,
|
||||
Example: "cdbg deploy\ncdbg deploy --config /path/to/config\ncdbg deploy --bootstrapper /path/to/bootstrapper --ips 192.0.2.1,192.0.2.2,192.0.2.3 --config /path/to/config",
|
||||
func newDeployCmd() *cobra.Command {
|
||||
deployCmd := &cobra.Command{
|
||||
Use: "deploy",
|
||||
Short: "Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation",
|
||||
Long: `Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation.
|
||||
Uses config provided by --config and reads constellation config from its default location.
|
||||
If required, you can override the IP addresses that are used for a deployment by specifying "--ips" and a list of IP addresses.
|
||||
Specifying --bootstrapper will upload the bootstrapper from the specified path.`,
|
||||
RunE: runDeploy,
|
||||
Example: "cdbg deploy\ncdbg deploy --config /path/to/config\ncdbg deploy --bootstrapper /path/to/bootstrapper --ips 192.0.2.1,192.0.2.2,192.0.2.3 --config /path/to/config",
|
||||
}
|
||||
deployCmd.Flags().StringSlice("ips", nil, "override the ips that the bootstrapper will be uploaded to (defaults to ips from constellation config)")
|
||||
deployCmd.Flags().String("bootstrapper", "", "override the path to the bootstrapper binary uploaded to instances (defaults to path set in config)")
|
||||
return deployCmd
|
||||
}
|
||||
|
||||
func runDeploy(cmd *cobra.Command, args []string) error {
|
||||
@ -165,13 +170,6 @@ func deployOnEndpoint(ctx context.Context, in deployOnEndpointInput) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(deployCmd)
|
||||
|
||||
deployCmd.Flags().StringSlice("ips", nil, "override the ips that the bootstrapper will be uploaded to (defaults to ips from constellation config)")
|
||||
deployCmd.Flags().String("bootstrapper", "", "override the path to the bootstrapper binary uploaded to instances (defaults to path set in config)")
|
||||
}
|
||||
|
||||
type fileToStreamReader interface {
|
||||
ReadStream(filename string, stream bootstrapper.WriteChunkStream, chunksize uint, showProgress bool) error
|
||||
}
|
||||
|
@ -7,21 +7,23 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "cdbg",
|
||||
Short: "Constellation debugging client",
|
||||
Long: `cdbg is the constellation debugging client.
|
||||
It connects to CoreOS instances running debugd and deploys a self-compiled version of the bootstrapper.`,
|
||||
func newRootCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "cdbg",
|
||||
Short: "Constellation debugging client",
|
||||
Long: `cdbg is the constellation debugging client.
|
||||
It connects to CoreOS instances running debugd and deploys a self-compiled version of the bootstrapper.`,
|
||||
}
|
||||
cmd.PersistentFlags().String("config", constants.ConfigFilename, "Constellation config file")
|
||||
cmd.PersistentFlags().String("cdbg-config", constants.DebugdConfigFilename, "debugd config file")
|
||||
cmd.AddCommand(newDeployCmd())
|
||||
return cmd
|
||||
}
|
||||
|
||||
// Execute starts the CLI.
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
cmd := newRootCmd()
|
||||
if err := cmd.Execute(); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.PersistentFlags().String("config", constants.ConfigFilename, "Constellation config file")
|
||||
rootCmd.PersistentFlags().String("cdbg-config", constants.DebugdConfigFilename, "debugd config file")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user