mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-01-23 22:01:14 -05: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"
|
"google.golang.org/grpc/credentials/insecure"
|
||||||
)
|
)
|
||||||
|
|
||||||
var deployCmd = &cobra.Command{
|
func newDeployCmd() *cobra.Command {
|
||||||
Use: "deploy",
|
deployCmd := &cobra.Command{
|
||||||
Short: "Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation",
|
Use: "deploy",
|
||||||
Long: `Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation.
|
Short: "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.
|
Long: `Deploys a self-compiled bootstrapper binary and SSH keys on the current constellation.
|
||||||
If required, you can override the IP addresses that are used for a deployment by specifying "--ips" and a list of IP addresses.
|
Uses config provided by --config and reads constellation config from its default location.
|
||||||
Specifying --bootstrapper will upload the bootstrapper from the specified path.`,
|
If required, you can override the IP addresses that are used for a deployment by specifying "--ips" and a list of IP addresses.
|
||||||
RunE: runDeploy,
|
Specifying --bootstrapper will upload the bootstrapper from the specified path.`,
|
||||||
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",
|
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 {
|
func runDeploy(cmd *cobra.Command, args []string) error {
|
||||||
@ -165,13 +170,6 @@ func deployOnEndpoint(ctx context.Context, in deployOnEndpointInput) error {
|
|||||||
return nil
|
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 {
|
type fileToStreamReader interface {
|
||||||
ReadStream(filename string, stream bootstrapper.WriteChunkStream, chunksize uint, showProgress bool) error
|
ReadStream(filename string, stream bootstrapper.WriteChunkStream, chunksize uint, showProgress bool) error
|
||||||
}
|
}
|
||||||
|
@ -7,21 +7,23 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
var rootCmd = &cobra.Command{
|
func newRootCmd() *cobra.Command {
|
||||||
Use: "cdbg",
|
cmd := &cobra.Command{
|
||||||
Short: "Constellation debugging client",
|
Use: "cdbg",
|
||||||
Long: `cdbg is the constellation debugging client.
|
Short: "Constellation debugging client",
|
||||||
It connects to CoreOS instances running debugd and deploys a self-compiled version of the bootstrapper.`,
|
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.
|
// Execute starts the CLI.
|
||||||
func Execute() {
|
func Execute() {
|
||||||
if err := rootCmd.Execute(); err != nil {
|
cmd := newRootCmd()
|
||||||
|
if err := cmd.Execute(); err != nil {
|
||||||
os.Exit(1)
|
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