From 144612b5fe0d03c5f640c7eab17c59ca912c53e3 Mon Sep 17 00:00:00 2001 From: Gyu-Ho Lee Date: Mon, 21 Mar 2016 00:34:48 -0700 Subject: [PATCH] *: clean up flags --- agent/agent.go | 12 ++++++++++-- control/control.go | 14 +++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 03025e20..ecd1d151 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -44,6 +44,8 @@ type ( Monitor bool MonitorInterval time.Duration MonitorResultPath string + + StorageSecretKeyPath string } // ZookeeperConfig is zookeeper configuration. @@ -110,14 +112,16 @@ func init() { if len(shell) == 0 { shell = "sh" } - Command.PersistentFlags().StringVarP(&globalFlags.GRPCPort, "agent-port", "p", ":3500", "Port to server agent gRPC server.") - Command.PersistentFlags().StringVarP(&globalFlags.WorkingDir, "working-directory", "d", homeDir(), "Working directory to store data.") + Command.PersistentFlags().StringVar(&globalFlags.GRPCPort, "agent-port", ":3500", "Port to server agent gRPC server.") + Command.PersistentFlags().StringVar(&globalFlags.WorkingDir, "working-directory", homeDir(), "Working directory to store data.") Command.PersistentFlags().StringVar(&globalFlags.DatabaseLogPath, "database-log-path", "database.log", "Path to save database log.") Command.PersistentFlags().BoolVar(&globalFlags.Monitor, "monitor", false, "Periodically records resource usage.") Command.PersistentFlags().DurationVar(&globalFlags.MonitorInterval, "monitor-interval", time.Second, "Resource monitor interval.") Command.PersistentFlags().StringVar(&globalFlags.MonitorResultPath, "monitor-result-path", "monitor.csv", "File path to store monitor results.") + + Command.PersistentFlags().StringVar(&globalFlags.StorageSecretKeyPath, "storage-secret-key-path", "", "Key to use for uploading logs and data.") } func CommandFunc(cmd *cobra.Command, args []string) { @@ -136,6 +140,9 @@ func CommandFunc(cmd *cobra.Command, args []string) { if !filepath.HasPrefix(globalFlags.MonitorResultPath, globalFlags.WorkingDir) { globalFlags.MonitorResultPath = filepath.Join(globalFlags.WorkingDir, globalFlags.MonitorResultPath) } + if !filepath.HasPrefix(globalFlags.StorageSecretKeyPath, globalFlags.WorkingDir) { + globalFlags.StorageSecretKeyPath = filepath.Join(globalFlags.WorkingDir, globalFlags.StorageSecretKeyPath) + } log.Printf("gRPC has started serving at %s\n", globalFlags.GRPCPort) log.Printf("Database log path: %s\n", globalFlags.DatabaseLogPath) @@ -143,6 +150,7 @@ func CommandFunc(cmd *cobra.Command, args []string) { log.Printf("Zookeeper working directory: %s\n", zkWorkingDir) log.Printf("Zookeeper data directory: %s\n", zkDataDir) log.Printf("Monitor result path: %s\n", globalFlags.MonitorResultPath) + log.Printf("Storage key secret path: %s\n", globalFlags.StorageSecretKeyPath) // TODO: use this to upload to Google cloud storage var ( grpcServer = grpc.NewServer() diff --git a/control/control.go b/control/control.go index b9fd48a4..cd98bc89 100644 --- a/control/control.go +++ b/control/control.go @@ -55,14 +55,14 @@ var ( ) func init() { - StartCommand.PersistentFlags().StringVarP(&globalFlags.Database, "database", "d", "etcd", "'etcd' or 'zookeeper' (or 'zk').") - - StartCommand.PersistentFlags().StringSliceVarP(&globalFlags.AgentEndpoints, "agent-endpoints", "e", []string{""}, "Endpoints to send client requests to. Then the agent automatically configures the database.") - StopCommand.PersistentFlags().StringSliceVarP(&globalFlags.AgentEndpoints, "agent-endpoints", "e", []string{""}, "Endpoints to send client requests to. Then the agent automatically configures the database.") - RestartCommand.PersistentFlags().StringSliceVarP(&globalFlags.AgentEndpoints, "agent-endpoints", "e", []string{""}, "Endpoints to send client requests to. Then the agent automatically configures the database.") - + StartCommand.PersistentFlags().StringVar(&globalFlags.Database, "database", "", "etcd, zookeeper, zk, etcd2, consul.") + StartCommand.PersistentFlags().StringSliceVar(&globalFlags.AgentEndpoints, "agent-endpoints", []string{""}, "Endpoints to send client requests to, then it automatically configures.") StartCommand.PersistentFlags().Int64Var(&globalFlags.ZookeeperPreAllocSize, "zk-pre-alloc-size", 65536*1024, "Disk pre-allocation size in bytes.") - StartCommand.PersistentFlags().Int64Var(&globalFlags.ZookeeperMaxClientCnxns, "zk-max-client-conns", 5000, "Maximum number of concurrent zookeeper connection.") + StartCommand.PersistentFlags().Int64Var(&globalFlags.ZookeeperMaxClientCnxns, "zk-max-client-conns", 5000, "Maximum number of concurrent Zookeeper connection.") + + StopCommand.PersistentFlags().StringSliceVar(&globalFlags.AgentEndpoints, "agent-endpoints", []string{""}, "Endpoints to send client requests to, then it automatically configures.") + + RestartCommand.PersistentFlags().StringSliceVar(&globalFlags.AgentEndpoints, "agent-endpoints", []string{""}, "Endpoints to send client requests to, then it automatically configures.") } func CommandFunc(cmd *cobra.Command, args []string) {