Пример #1
1
func newConfig() *Conf {
	c := new(Conf)
	c.ldapViper = viper.New()
	c.ldapConfig = &LdapConfig{}
	c.notificationConfigs = []NotificationServiceConfig{}

	viper.SetConfigName("indispenso")
	viper.SetEnvPrefix("ind")

	// Defaults
	viper.SetDefault("Token", "")
	viper.SetDefault("Hostname", getDefaultHostName())
	viper.SetDefault("UseAutoTag", true)
	viper.SetDefault("ServerEnabled", false)
	viper.SetDefault("Home", defaultHomePath)
	viper.SetDefault("Debug", false)
	viper.SetDefault("ServerPort", 897)
	viper.SetDefault("EndpointURI", "")
	viper.SetDefault("SslCertFile", "cert.pem")
	viper.SetDefault("SslPrivateKeyFile", "key.pem")
	viper.SetDefault("AutoGenerateCert", true)
	viper.SetDefault("ClientPort", 898)
	viper.SetDefault("EnableLdap", false)
	viper.SetDefault("LdapConfigFile", "")

	//Flags
	c.confFlags = pflag.NewFlagSet(os.Args[0], pflag.ExitOnError)

	configFile := c.confFlags.StringP("config", "c", "", "Config file location default is /etc/indispenso/indispenso.{json,toml,yaml,yml,properties,props,prop}")
	c.confFlags.BoolP("serverEnabled", "s", false, "Define if server module should be started or not")
	c.confFlags.BoolP("debug", "d", false, "Enable debug mode")
	c.confFlags.StringP("home", "p", defaultHomePath, "Home directory where all config files are located")
	c.confFlags.StringP("endpointUri", "e", "", "URI of server interface, used by client")
	c.confFlags.StringP("token", "t", "", "Secret token")
	c.confFlags.StringP("hostname", "i", getDefaultHostName(), "Hostname that is use to identify itself")
	c.confFlags.BoolP("enableLdap", "l", false, "Enable LDAP authentication")
	c.confFlags.BoolP("help", "h", false, "Print help message")

	c.confFlags.Parse(os.Args[1:])
	if len(*configFile) > 2 {
		viper.SetConfigFile(*configFile)
	} else {
		legacyConfigFile := "/etc/indispenso/indispenso.conf"
		if _, err := os.Stat(legacyConfigFile); err == nil {
			viper.SetConfigFile(legacyConfigFile)
			viper.SetConfigType("yaml")
		}
	}
	viper.BindPFlags(c.confFlags)
	viper.AutomaticEnv()

	viper.ReadInConfig()

	c.setupHome(nil, viper.GetString("Home"))
	c.setupHome(c.ldapViper, viper.GetString("Home"))

	c.SetupNotificationConfig("slack", &SlackNotifyConfig{})
	c.Update()
	return c
}
Пример #2
0
func init() {
	RootCmd.PersistentFlags().Bool(showLibmachineLogs, false, "Whether or not to show logs from libmachine.")
	RootCmd.AddCommand(configCmd.ConfigCmd)
	pflag.CommandLine.AddGoFlagSet(goflag.CommandLine)
	viper.BindPFlags(RootCmd.PersistentFlags())
	cobra.OnInitialize(initConfig)
}
Пример #3
0
func init() {
	// root and persistent flags
	rootCmd.PersistentFlags().String("log-level", "info", "one of debug, info, warn, error, or fatal")
	rootCmd.PersistentFlags().String("log-format", "text", "specify output (text or json)")

	// build flags
	buildCmd.Flags().String("shell", "bash", "shell to use for executing build scripts")
	buildCmd.Flags().Int("concurrent-jobs", runtime.NumCPU(), "number of packages to build at once")
	buildCmd.Flags().String("stream-logs-for", "", "stream logs from a single package")

	cwd, err := os.Getwd()
	if err != nil {
		logrus.WithField("error", err).Warning("could not get working directory")
	}
	rootCmd.PersistentFlags().String("search", cwd, "where to look for package definitions")
	buildCmd.Flags().String("output", path.Join(cwd, "out"), "where to place output packages")
	buildCmd.Flags().String("logs", path.Join(cwd, "logs"), "where to place build logs")
	buildCmd.Flags().String("cache", path.Join(cwd, ".hammer-cache"), "where to cache downloads")
	buildCmd.Flags().Bool("skip-cleanup", false, "skip cleanup step")

	for _, flags := range []*pflag.FlagSet{rootCmd.PersistentFlags(), buildCmd.Flags()} {
		err := viper.BindPFlags(flags)
		if err != nil {
			logrus.WithField("error", err).Fatal("could not bind flags")
		}
	}
}
Пример #4
0
func init() {
	buildCmd.AddCommand(buildImagesCmd)

	buildImagesCmd.PersistentFlags().BoolP(
		"no-build",
		"N",
		false,
		"If specified, the Dockerfile and assets will be created, but the image won't be built.",
	)

	buildImagesCmd.PersistentFlags().BoolP(
		"force",
		"F",
		false,
		"If specified, image creation will proceed even when images already exist.",
	)

	buildImagesCmd.PersistentFlags().StringP(
		"patch-properties-release",
		"P",
		"",
		"Used to designate a \"patch-properties\" psuedo-job in a particular release.  Format: RELEASE/JOB.",
	)

	viper.BindPFlags(buildImagesCmd.PersistentFlags())
}
Пример #5
0
func setupConfig() {
	agentCmd.Flags().StringVar(&configFile, "config", "", "specify a configuration file")

	err := viper.BindPFlags(agentCmd.Flags())
	if err != nil {
		log.Errorf("Error binding pflags: %v", err)
	}
}
Пример #6
0
func setupBalancerCmdFlags(cmd *cobra.Command) {
	cmd.Flags().StringVar(&configFile, "config", "", "specify a configuration file")
	cmd.Flags().StringVar(&conf.LogLevel, "log-level", "", "specify a log level")
	cmd.Flags().BoolVarP(&conf.EnableHealthChecks, "enable-health-checks", "", true, "enables health checking on destinations")
	cmd.Flags().StringVarP(&conf.StorePrefix, "store-prefix", "", "fusis", "configures the prefix used by the store")
	cmd.Flags().StringVarP(&conf.StoreAddress, "store-address", "", "consul://localhost:8500", "configures the store address")

	err := viper.BindPFlags(cmd.Flags())
	if err != nil {
		log.Errorf("Error binding pflags: %v", err)
	}
}
Пример #7
0
func init() {
	docsCmd.AddCommand(docsMarkdownCmd)

	docsMarkdownCmd.PersistentFlags().StringP(
		"md-output-dir",
		"O",
		"./docs",
		"Specifies a location where markdown documentation will be generated.",
	)

	viper.BindPFlags(docsMarkdownCmd.PersistentFlags())
}
Пример #8
0
func init() {
	docsCmd.AddCommand(docsAutocompleteCmd)

	docsAutocompleteCmd.PersistentFlags().StringP(
		"output-file",
		"O",
		"./fissile-autocomplete.sh",
		"Specifies a file location where a bash autocomplete script will be generated.",
	)

	viper.BindPFlags(docsAutocompleteCmd.PersistentFlags())
}
Пример #9
0
func init() {
	docsCmd.AddCommand(docsManCmd)

	docsManCmd.PersistentFlags().StringP(
		"man-output-dir",
		"O",
		"./man",
		"Specifies a location where man pages will be generated.",
	)

	viper.BindPFlags(docsManCmd.PersistentFlags())
}
Пример #10
0
func init() {
	buildLayerCmd.AddCommand(buildLayerCompilationCmd)

	buildLayerCompilationCmd.PersistentFlags().BoolP(
		"debug",
		"D",
		false,
		"If specified, the docker container used to build the layer won't be destroyed on failure.",
	)

	viper.BindPFlags(buildLayerCompilationCmd.PersistentFlags())
}
Пример #11
0
func main() {
	rootCmd := &cobra.Command{
		Use:   "mantl-api",
		Short: "runs the mantl-api",
		Run: func(cmd *cobra.Command, args []string) {
			start()
		},
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
			readConfigFile()
			setupLogging()
		},
	}

	rootCmd.PersistentFlags().String("log-level", "info", "one of debug, info, warn, error, or fatal")
	rootCmd.PersistentFlags().String("log-format", "text", "specify output (text or json)")
	rootCmd.PersistentFlags().String("consul", "http://localhost:8500", "Consul Api address")
	rootCmd.PersistentFlags().String("marathon", "", "Marathon Api address")
	rootCmd.PersistentFlags().String("marathon-user", "", "Marathon Api user")
	rootCmd.PersistentFlags().String("marathon-password", "", "Marathon Api password")
	rootCmd.PersistentFlags().Bool("marathon-no-verify-ssl", false, "Marathon SSL verification")
	rootCmd.PersistentFlags().String("mesos", "", "Mesos Api address")
	rootCmd.PersistentFlags().String("mesos-principal", "", "Mesos principal for framework authentication")
	rootCmd.PersistentFlags().String("mesos-secret", "", "Mesos secret for framework authentication")
	rootCmd.PersistentFlags().Bool("mesos-no-verify-ssl", false, "Mesos SSL verification")
	rootCmd.PersistentFlags().String("listen", ":4001", "mantl-api listen address")
	rootCmd.PersistentFlags().String("zookeeper", "", "Comma-delimited list of zookeeper servers")
	rootCmd.PersistentFlags().Bool("force-sync", false, "Force a synchronization of all sources")
	rootCmd.PersistentFlags().String("config-file", "", "The path to a configuration file")

	for _, flags := range []*pflag.FlagSet{rootCmd.PersistentFlags()} {
		err := viper.BindPFlags(flags)
		if err != nil {
			log.WithField("error", err).Fatal("could not bind flags")
		}
	}

	viper.SetEnvPrefix("mantl_api")
	viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
	viper.AutomaticEnv()

	syncCommand := &cobra.Command{
		Use:   "sync",
		Short: "Synchronize universe repositories",
		Long:  "Forces a synchronization of all configured sources",
		Run: func(cmd *cobra.Command, args []string) {
			sync(nil, true)
		},
	}
	rootCmd.AddCommand(syncCommand)

	rootCmd.Execute()
}
Пример #12
0
func init() {
	cobra.OnInitialize(initConfig, initLogging, lockMemory)

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is /etc/sysconfig/vaultfs)")

	// logging flags
	RootCmd.PersistentFlags().String("log-level", "info", "log level (one of fatal, error, warn, info, or debug)")
	RootCmd.PersistentFlags().String("log-format", "text", "log level (one of text or json)")
	RootCmd.PersistentFlags().String("log-destination", "stdout:", "log destination (file:/your/output, stdout:, journald:, or syslog://tag@host:port#protocol)")

	if err := viper.BindPFlags(RootCmd.PersistentFlags()); err != nil {
		logrus.WithError(err).Fatal("could not bind flags")
	}
}
Пример #13
0
func init() {
	startCmd.Flags().String(isoURL, constants.DefaultIsoUrl, "Location of the minikube iso")
	startCmd.Flags().String(vmDriver, constants.DefaultVMDriver, fmt.Sprintf("VM driver is one of: %v", constants.SupportedVMDrivers))
	startCmd.Flags().Int(memory, constants.DefaultMemory, "Amount of RAM allocated to the minikube VM")
	startCmd.Flags().Int(cpus, constants.DefaultCPUS, "Number of CPUs allocated to the minikube VM")
	startCmd.Flags().String(humanReadableDiskSize, constants.DefaultDiskSize, "Disk size allocated to the minikube VM (format: <number>[<unit>], where unit = b, k, m or g)")
	startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minikube VM (only supported with Virtualbox driver)")
	startCmd.Flags().StringSliceVar(&dockerEnv, "docker-env", nil, "Environment variables to pass to the Docker daemon. (format: key=value)")
	startCmd.Flags().StringSliceVar(&insecureRegistry, "insecure-registry", nil, "Insecure Docker registries to pass to the Docker daemon")
	startCmd.Flags().StringSliceVar(&registryMirror, "registry-mirror", nil, "Registry mirrors to pass to the Docker daemon")
	startCmd.Flags().String(kubernetesVersion, constants.DefaultKubernetesVersion, "The kubernetes version that the minikube VM will (ex: v1.2.3) \n OR a URI which contains a localkube binary (ex: https://storage.googleapis.com/minikube/k8sReleases/v1.3.0/localkube-linux-amd64)")
	viper.BindPFlags(startCmd.Flags())
	RootCmd.AddCommand(startCmd)
}
Пример #14
0
func cli(flags *pflag.FlagSet, run func(cmd *cobra.Command, args []string)) *cobra.Command {
	// Create command
	cmd := &cobra.Command{
		Use:   "trainsporter",
		Short: "Trainspotter",
		Long:  "Trainspotter",
		Run:   run,
	}

	// Register flags with command
	cmd.Flags().AddFlagSet(flags)

	// Bind to viper
	viper.BindPFlags(flags)

	return cmd
}
Пример #15
0
func init() {
	startCmd.Flags().String(isoURL, constants.DefaultIsoUrl, "Location of the minishift iso")
	startCmd.Flags().String(vmDriver, constants.DefaultVMDriver, fmt.Sprintf("VM driver is one of: %v", constants.SupportedVMDrivers))
	startCmd.Flags().Int(memory, constants.DefaultMemory, "Amount of RAM allocated to the minishift VM")
	startCmd.Flags().Int(cpus, constants.DefaultCPUS, "Number of CPUs allocated to the minishift VM")
	startCmd.Flags().String(humanReadableDiskSize, constants.DefaultDiskSize, "Disk size allocated to the minishift VM (format: <number>[<unit>], where unit = b, k, m or g)")
	startCmd.Flags().String(hostOnlyCIDR, "192.168.99.1/24", "The CIDR to be used for the minishift VM (only supported with Virtualbox driver)")
	startCmd.Flags().StringSliceVar(&dockerEnv, "docker-env", nil, "Environment variables to pass to the Docker daemon. (format: key=value)")
	startCmd.Flags().StringSliceVar(&insecureRegistry, "insecure-registry", []string{"172.30.0.0/16"}, "Insecure Docker registries to pass to the Docker daemon")
	startCmd.Flags().StringSliceVar(&registryMirror, "registry-mirror", nil, "Registry mirrors to pass to the Docker daemon")
	startCmd.Flags().Bool(deployRegistry, true, "Should the OpenShift internal Docker registry be deployed?")
	startCmd.Flags().Bool(deployRouter, false, "Should the OpenShift router be deployed?")

	viper.BindPFlags(startCmd.Flags())

	RootCmd.AddCommand(startCmd)
}
Пример #16
0
func init() {
	RootCmd.AddCommand(serverCmd)
	serverInit()
	viper.BindPFlags(serverCmd.Flags())

	viper.SetDefault("units", map[string]string{
		"Temperature":  "C",
		"Pressure":     "hPa",
		"RainfallRate": "mm/h",
		"RainTotal":    "mm",
		"WindSpeed":    "m/s",
	})
	viper.SetDefault("temperature", []map[string]string{{"type": "Temperature", "label": "Temperature"}})
	viper.SetDefault("pressure", []map[string]string{{"type": "Pressure", "label": "Pressure"}})
	viper.SetDefault("humidity", []map[string]string{{"type": "Humidity", "label": "Humidity"}})
	viper.SetDefault("wind", []map[string]string{{"type": "AverageWind[avg]", "label": "Average Wind"}, {"type": "CurrentWind[max]", "label": "Gusts"}})
	viper.SetDefault("rain", []map[string]string{{"type": "RainRate", "label": "Rainfall Rate"}, {"type": "RainTotal", "label": "Total Rain"}})
}
Пример #17
0
func init() {
	showCmd.AddCommand(showImageCmd)

	showImageCmd.PersistentFlags().BoolP(
		"docker-only",
		"D",
		false,
		"If the flag is set, only show images that are available on docker",
	)

	showImageCmd.PersistentFlags().BoolP(
		"with-sizes",
		"S",
		false,
		"If the flag is set, also show image virtual sizes; only works if the --docker-only flag is set",
	)

	viper.BindPFlags(showImageCmd.PersistentFlags())
}
Пример #18
0
func initConfig(confFile string) {
	// Read in configuration from file
	// If a config file is not given try to read from default paths
	// If a config file was given, read in configration from that file.
	// If the file is not present panic.
	if confFile == "" {
		config.SetConfigName(defaultConfName)
		for _, p := range defaultConfPaths {
			config.AddConfigPath(p)
		}
	} else {
		config.SetConfigFile(confFile)
	}

	e := config.ReadInConfig()
	if e != nil {
		if confFile == "" {
			log.WithFields(log.Fields{
				"paths":  defaultConfPaths,
				"config": defaultConfName + ".(toml|yaml|json)",
				"error":  e,
			}).Debug("failed to read any config files, continuing with defaults")
		} else {
			log.WithFields(log.Fields{
				"config": confFile,
				"error":  e,
			}).Fatal("failed to read given config file")
		}
	} else {
		log.WithField("config", config.ConfigFileUsed()).Info("loaded configuration from file")
	}

	// Use config given by flags
	config.BindPFlags(flag.CommandLine)

	// Finally initialize missing config with defaults
	setDefaults()

	dumpConfigToLog()
}
Пример #19
0
func init() {
	cobra.OnInitialize(initConfig)

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default \"$HOME/.ttn.yml\")")

	RootCmd.PersistentFlags().Bool("no-cli-logs", false, "Disable CLI logs")
	RootCmd.PersistentFlags().String("log-file", "", "Location of the log file")
	RootCmd.PersistentFlags().String("elasticsearch", "", "Location of Elasticsearch server for logging")

	RootCmd.PersistentFlags().String("id", "", "The id of this component")
	RootCmd.PersistentFlags().String("description", "", "The description of this component")
	RootCmd.PersistentFlags().Bool("public", false, "Announce this component as part of The Things Network (public community network)")

	RootCmd.PersistentFlags().String("discovery-address", "discover.thethingsnetwork.org:1900", "The address of the Discovery server")
	RootCmd.PersistentFlags().String("auth-token", "", "The JWT token to be used for the discovery server")

	RootCmd.PersistentFlags().Int("health-port", 0, "The port number where the health server should be started")

	viper.SetDefault("auth-servers", map[string]string{
		"ttn-account-v2": "https://account.thethingsnetwork.org",
	})

	dir, err := homedir.Dir()
	if err == nil {
		dir, _ = homedir.Expand(dir)
	}
	if dir == "" {
		dir, err = os.Getwd()
		if err != nil {
			panic(err)
		}
	}

	RootCmd.PersistentFlags().Bool("tls", false, "Use TLS")
	RootCmd.PersistentFlags().String("key-dir", path.Clean(dir+"/.ttn/"), "The directory where public/private keys are stored")

	viper.BindPFlags(RootCmd.PersistentFlags())
}
Пример #20
0
func init() {
	cobra.OnInitialize(initConfig)

	// Here you will define your flags and configuration settings.
	// Cobra supports Persistent Flags, which, if defined here,
	// will be global for your application.

	RootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is gowx.yaml)")
	RootCmd.PersistentFlags().String("broker", "tcp://localhost:1883", "MQTT Server")
	RootCmd.PersistentFlags().String("database", "gowx.db", "Database")
	RootCmd.PersistentFlags().BoolVarP(&verbose, "verbose", "v", false, "Enable verbose output")

	dbdrivers := data.DBDrivers()
	if len(dbdrivers) > 1 {
		RootCmd.PersistentFlags().String("dbDriver", "sqlite3", "Database Driver, one of ["+strings.Join(dbdrivers, ", ")+"]")
	} else {
		viper.SetDefault("dbDriver", "sqlite3")
	}
	// Cobra also supports local flags, which will only run
	// when this action is called directly.
	// RootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
	viper.BindPFlags(RootCmd.PersistentFlags())
}
Пример #21
0
func init() {
	RootCmd.AddCommand(allCmd)

	// Here you will define your flags and configuration settings.

	// Cobra supports Persistent Flags which will work for this command
	// and all subcommands, e.g.:
	// allCmd.PersistentFlags().String("foo", "", "A help for foo")

	// Cobra supports local flags which will only run when this command
	// is called directly, e.g.:
	// allCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")

	parserInit()
	allCmd.Flags().AddFlagSet(parserCmd.Flags())

	aggregatorInit()
	allCmd.Flags().AddFlagSet(aggregatorCmd.Flags())

	serverInit()
	allCmd.Flags().AddFlagSet(serverCmd.Flags())

	viper.BindPFlags(allCmd.Flags())
}
Пример #22
0
// InitFlags normalizes and parses the command line flags
func (cnf *Config) InitFlags() {
	viper.BindPFlags(pflag.CommandLine)
	pflag.CommandLine.SetNormalizeFunc(wordSepNormalizeFunc)
	pflag.Parse()
}
Пример #23
0
func init() {
	RootCmd.AddCommand(parseCmd)
	parseCmd.Flags().StringP("input", "i", "data/JMdict_e.gz", "Path to the input JMDICT file")
	viper.BindPFlags(parseCmd.Flags())
}
Пример #24
0
func init() {
	RootCmd.AddCommand(fetchCmd)
	fetchCmd.Flags().StringP("url", "u", "ftp://ftp.monash.edu.au/pub/nihongo/JMdict_e.gz", "HTTP path to the JMDICT file")
	fetchCmd.Flags().StringP("outfile", "o", "data/JMdict_e.gz", "Location to save the dictionary")
	viper.BindPFlags(fetchCmd.Flags())
}
Пример #25
0
// Run runs our `remy` application.
func Run(cfg *wls.AdminServer) {
	// Base command for the application.
	var WlsRestCmd = &cobra.Command{
		Use:   "remy",
		Short: "Query a WebLogic Domain's REST Management Extention-enabled resources",
		Long:  "Query a WebLogic Domain's resources, including Datasources, Applications, Clusters, and Servers by using the WebLogic RESTful Management Extensions API",
	}

	// Request the Servers resource, optionally passing a specific [servername] instance to get that particular Server.
	var serversCmd = &cobra.Command{
		Use:   "servers [Server to query, blank for ALL]",
		Short: "Display Server information",
		Long:  "Show details on all servers under an AdminServer, or specify a specific one",
		Run:   Servers,
	}

	// Request the Clusters resource, optionally passing a specific [clustername] to get a specific Cluster.
	var clustersCmd = &cobra.Command{
		Use:   "clusters [cluster to query, blank for ALL]",
		Short: "Query clusters under AdminServer",
		Long:  "Query the AdminServer for specific clusters, or leave blank for all clusters that this server owns",
		Run:   Clusters,
	}

	// Datasource command, requesting all datasrouces.  Pass a secondary [datasourcename] to get a specific datasource.
	var datasourcesCmd = &cobra.Command{
		Use:   "datasources [datasources to query, blank for ALL]",
		Short: "Query datasources under AdminServer",
		Long:  "Query the AdminServer for specific datasources, or leave blank for all datasources that this server owns",
		Run:   DataSources,
	}

	// Application list command.  Pass an optional [applicationname] to get a specific application instance details.
	var applicationsCmd = &cobra.Command{
		Use:   "applications [application to query, blank for ALL]",
		Short: "Query applications deployed under AdminServer",
		Long:  "Query the AdminServer for specific applications, or leave blank for all applications that this server knows about",
		Run:   Applications,
	}

	// Generate a configuration setting file in your ~/ home or local directory.
	// When determined to be in the ~/home, it will be a ~/.wlsrest.toml file.
	// When a local file, it will be a wlsrest.toml file instead.
	var configureCmd = &cobra.Command{
		Use:   "config",
		Short: "Configure the credentials and server to default REST connections to",
		Long:  "Configure what Username, Password, and Admin Server:Port you want to send REST requests to when submitting calls on any of the other commands",
		Run:   Configure,
	}

	// Version command displays the version of the application.
	var versionCmd = &cobra.Command{
		Use:   "version",
		Short: "Show the version of this command",
		Long:  "Display the version of this command",
		Run: func(cmd *cobra.Command, args []string) {
			fmt.Printf("remy version %v\n", remyVersion)
		},
	}

	// Add option to pass --full-format for all responses.  Single server, application, etc., requests will always return
	// full responses, but group-related queries will return shortened versions
	WlsRestCmd.PersistentFlags().BoolVarP(&FullFormat, FullFormatFlag, "f", false, "Return full format from REST server")

	// Allow specific AdminServer URL to be passed in to override local config files
	WlsRestCmd.PersistentFlags().StringVarP(&cfg.AdminURL, AdminURLFlag, "s", "http://localhost:7001", "Url for the Admin Server")

	// Allow the Username property to be overridden locally on the command-line
	WlsRestCmd.PersistentFlags().StringVarP(&cfg.Username, UsernameFlag, "u", "weblogic", "Username with privileges to access AdminServer")

	// Allow the Password property to be overridden on the command-line
	WlsRestCmd.PersistentFlags().StringVarP(&cfg.Password, PasswordFlag, "p", "welcome1", "Password for the user")

	configureCmd.Flags().BoolVar(&FlagHomeConfig, HomeSetFlag, false, "Generate/Update the ~/$HOME config file")
	configureCmd.Flags().BoolVar(&FlagLocalConfig, LocalSetFlag, false, "Generate/Update the local directory's config file")

	viper.BindPFlags(WlsRestCmd.PersistentFlags())
	viper.BindPFlags(configureCmd.Flags())

	WlsRestCmd.AddCommand(applicationsCmd, configureCmd, clustersCmd, datasourcesCmd, serversCmd, versionCmd)
	WlsRestCmd.Execute()
}
Пример #26
0
func main() {
	rootCmd := &cobra.Command{
		Use:   "mantl-api",
		Short: "runs the mantl-api",
		Run: func(cmd *cobra.Command, args []string) {
			start()
		},
		PersistentPreRun: func(cmd *cobra.Command, args []string) {
			readConfigFile()
			setupLogging()
		},
	}

	rootCmd.PersistentFlags().String("config-file", "", "The path to a (optional) configuration file")
	rootCmd.PersistentFlags().String("consul-acl-token", "", "Consul ACL token for accessing mantl-install/apps path")
	rootCmd.PersistentFlags().Bool("consul-no-verify-ssl", false, "Disable Consul SSL verification")
	rootCmd.PersistentFlags().Int("consul-refresh-interval", 10, "The number of seconds after which to check consul for package requests")
	rootCmd.PersistentFlags().String("consul", "http://localhost:8500", "Consul API address")
	rootCmd.PersistentFlags().Bool("force-sync", false, "Force a synchronization of respository all sources at startup")
	rootCmd.PersistentFlags().String("listen", ":4001", "listen for connections on this address")
	rootCmd.PersistentFlags().String("log-format", "text", "specify output (text or json)")
	rootCmd.PersistentFlags().String("log-level", "info", "one of debug, info, warn, error, or fatal")
	rootCmd.PersistentFlags().String("marathon", "", "Marathon API address")
	rootCmd.PersistentFlags().Bool("marathon-no-verify-ssl", false, "Disable Marathon SSL verification")
	rootCmd.PersistentFlags().String("marathon-password", "", "Marathon API password")
	rootCmd.PersistentFlags().String("marathon-user", "", "Marathon API user")
	rootCmd.PersistentFlags().String("mesos", "", "Mesos API address")
	rootCmd.PersistentFlags().Bool("mesos-no-verify-ssl", false, "Disable Mesos SSL verification")
	rootCmd.PersistentFlags().String("mesos-principal", "", "Mesos principal for framework authentication")
	rootCmd.PersistentFlags().String("mesos-secret", "", "Deprecated. Use mesos-secret-path instead")
	rootCmd.PersistentFlags().String("mesos-secret-path", "/etc/sysconfig/mantl-api", "Path to a file on host sytem that contains the mesos secret for framework authentication")
	rootCmd.PersistentFlags().String("vault-cubbyhole-token", "", "token for retrieving token from vault")
	rootCmd.PersistentFlags().String("vault-token", "", "token for retrieving secrets from vault")
	rootCmd.PersistentFlags().String("zookeeper", "", "Comma-delimited list of zookeeper servers")

	for _, flags := range []*pflag.FlagSet{rootCmd.PersistentFlags()} {
		err := viper.BindPFlags(flags)
		if err != nil {
			log.WithField("error", err).Fatal("could not bind flags")
		}
	}

	viper.SetEnvPrefix("mantl_api")
	viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
	viper.AutomaticEnv()

	syncCommand := &cobra.Command{
		Use:   "sync",
		Short: "Synchronize universe repositories",
		Long:  "Forces a synchronization of all configured sources",
		Run: func(cmd *cobra.Command, args []string) {
			syncRepo(nil, true)
		},
	}
	rootCmd.AddCommand(syncCommand)

	versionCommand := &cobra.Command{
		Use:   "version",
		Short: fmt.Sprintf("Print the version number of %s", Name),
		Run: func(cmd *cobra.Command, args []string) {
			fmt.Printf("%s v%s\n", Name, Version)
		},
	}
	rootCmd.AddCommand(versionCommand)

	rootCmd.Execute()
}
Пример #27
0
	"github.com/Sirupsen/logrus"
	"github.com/asteris-llc/vaultfs/fs"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

// mountCmd represents the mount command
var mountCmd = &cobra.Command{
	Use:   "mount {mountpoint}",
	Short: "mount a vault FS at the specified mountpoint",
	PreRunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("expected exactly one argument")
		}

		if err := viper.BindPFlags(cmd.Flags()); err != nil {
			logrus.WithError(err).Fatal("could not bind flags")
		}

		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		config := fs.NewConfig(viper.GetString("address"), viper.GetBool("insecure"))

		logrus.WithField("address", viper.GetString("address")).Info("creating FUSE client for Vault")

		fs, err := fs.New(config, args[0], viper.GetString("token"), viper.GetString("root"))
		if err != nil {
			logrus.WithError(err).Fatal("error creatinging fs")
		}
Пример #28
0
func init() {
	viper.SetDefault("port", 8000)
	viper.SetDefault("autopump", false)

	viper.BindEnv("port", "PORT")
	viper.BindEnv("autopump", "AUTOPUMP")
	viper.BindEnv("db-url", "DATABASE_URL")
	viper.BindEnv("stellar-core-db-url", "STELLAR_CORE_DATABASE_URL")
	viper.BindEnv("stellar-core-url", "STELLAR_CORE_URL")
	viper.BindEnv("friendbot-secret", "FRIENDBOT_SECRET")
	viper.BindEnv("per-hour-rate-limit", "PER_HOUR_RATE_LIMIT")
	viper.BindEnv("redis-url", "REDIS_URL")
	viper.BindEnv("ruby-horizon-url", "RUBY_HORIZON_URL")
	viper.BindEnv("log-level", "LOG_LEVEL")
	viper.BindEnv("sentry-dsn", "SENTRY_DSN")
	viper.BindEnv("loggly-token", "LOGGLY_TOKEN")
	viper.BindEnv("loggly-host", "LOGGLY_HOST")

	rootCmd = &cobra.Command{
		Use:   "horizon",
		Short: "client-facing api server for the stellar network",
		Long:  "client-facing api server for the stellar network",
		Run:   run,
	}

	rootCmd.Flags().String(
		"db-url",
		"",
		"horizon postgres database to connect with",
	)

	rootCmd.Flags().String(
		"stellar-core-db-url",
		"",
		"stellar-core postgres database to connect with",
	)

	rootCmd.Flags().String(
		"stellar-core-url",
		"",
		"stellar-core to connect with (for http commands)",
	)

	rootCmd.Flags().Int(
		"port",
		8000,
		"tcp port to listen on for http requests",
	)

	rootCmd.Flags().Bool(
		"autopump",
		false,
		"pump streams every second, instead of once per ledger close",
	)

	rootCmd.Flags().Int(
		"per-hour-rate-limit",
		3600,
		"max count of requests allowed in a one hour period, by remote ip address",
	)

	rootCmd.Flags().String(
		"redis-url",
		"",
		"redis to connect with, for rate limiting",
	)

	rootCmd.Flags().String(
		"ruby-horizon-url",
		"",
		"proxy yet-to-be-implemented actions through to ruby horizon server",
	)

	rootCmd.Flags().String(
		"log-level",
		"info",
		"Minimum log severity (debug, info, warn, error) to log",
	)

	rootCmd.Flags().String(
		"sentry-dsn",
		"",
		"Sentry URL to which panics and errors should be reported",
	)

	rootCmd.Flags().String(
		"loggly-token",
		"",
		"Loggly token, used to configure log forwarding to loggly",
	)

	rootCmd.Flags().String(
		"loggly-host",
		"",
		"Hostname to be added to every loggly log event",
	)

	rootCmd.Flags().String(
		"friendbot-secret",
		"",
		"Secret seed for friendbot functionality. When empty, friendbot will be disabled",
	)

	viper.BindPFlags(rootCmd.Flags())
}
Пример #29
0
func init() {
	RootCmd.AddCommand(aggregatorCmd)
	aggregatorInit()
	viper.BindPFlags(aggregatorCmd.Flags())
}
Пример #30
0
func init() {
	showCmd.AddCommand(showLayerCmd)
	viper.BindPFlags(showLayerCmd.PersistentFlags())
}