jpictl: add --domain/-D and --scan-dir/-d options
Signed-off-by: Alejandro Mery <amery@jpi.io>
This commit is contained in:
+15
-2
@@ -12,6 +12,14 @@ const (
|
|||||||
// DefaultConfigFile is read if -f/--config-file isn't specified.
|
// DefaultConfigFile is read if -f/--config-file isn't specified.
|
||||||
// If it doesn't exist, m/ will be scanned
|
// If it doesn't exist, m/ will be scanned
|
||||||
DefaultConfigFile = "cloud.yaml"
|
DefaultConfigFile = "cloud.yaml"
|
||||||
|
|
||||||
|
// DefaultClusterDir is the directory we will scan and write
|
||||||
|
// unless something else is indicated
|
||||||
|
DefaultClusterDir = "m"
|
||||||
|
|
||||||
|
// DefaultDomain indicates the domain to use unless
|
||||||
|
// something else is specified
|
||||||
|
DefaultDomain = "jpi.cloud"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config describes the repository
|
// Config describes the repository
|
||||||
@@ -25,8 +33,8 @@ type Config struct {
|
|||||||
var forceScan bool
|
var forceScan bool
|
||||||
|
|
||||||
var cfg = &Config{
|
var cfg = &Config{
|
||||||
Base: "m",
|
Base: DefaultClusterDir,
|
||||||
Domain: "jpi.cloud",
|
Domain: DefaultDomain,
|
||||||
}
|
}
|
||||||
|
|
||||||
// LoadZones loads all zones and machines in the config directory
|
// LoadZones loads all zones and machines in the config directory
|
||||||
@@ -62,8 +70,13 @@ func (cfg *Config) LoadZones(resolve bool) (*cluster.Cluster, error) {
|
|||||||
func init() {
|
func init() {
|
||||||
flags := rootCmd.PersistentFlags()
|
flags := rootCmd.PersistentFlags()
|
||||||
|
|
||||||
|
flags.StringVarP(&cfg.Base, "scan-dir", "d",
|
||||||
|
DefaultClusterDir, "directory to scan for cluster data")
|
||||||
|
flags.StringVarP(&cfg.Domain, "domain", "D",
|
||||||
|
DefaultDomain, "domain to use for scanned data")
|
||||||
flags.StringVarP(&cfg.ConfigFile, "config-file", "f",
|
flags.StringVarP(&cfg.ConfigFile, "config-file", "f",
|
||||||
DefaultConfigFile, "config file (JSON or YAML)")
|
DefaultConfigFile, "config file (JSON or YAML)")
|
||||||
|
|
||||||
flags.BoolVarP(&forceScan, "force-scan", "S",
|
flags.BoolVarP(&forceScan, "force-scan", "S",
|
||||||
false, "ignore config file and scan the directory instead")
|
false, "ignore config file and scan the directory instead")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user