Ejemplo n.º 1
0
// Init initializes the crypto layer. It load from viper the security level
// and the logging setting.
func Init() (err error) {
	// Init security level
	securityLevel := 256
	if viper.IsSet("security.level") {
		ovveride := viper.GetInt("security.level")
		if ovveride != 0 {
			securityLevel = ovveride
		}
	}

	hashAlgorithm := "SHA3"
	if viper.IsSet("security.hashAlgorithm") {
		ovveride := viper.GetString("security.hashAlgorithm")
		if ovveride != "" {
			hashAlgorithm = ovveride
		}
	}

	log.Debugf("Working at security level [%d]", securityLevel)
	if err = primitives.InitSecurityLevel(hashAlgorithm, securityLevel); err != nil {
		log.Errorf("Failed setting security level: [%s]", err)

		return
	}

	return
}
Ejemplo n.º 2
0
func parseDefaultPygmentsOpts() (map[string]string, error) {

	options := make(map[string]string)
	err := parseOptions(options, viper.GetString("PygmentsOptions"))
	if err != nil {
		return nil, err
	}

	if viper.IsSet("PygmentsStyle") {
		options["style"] = viper.GetString("PygmentsStyle")
	}

	if viper.IsSet("PygmentsUseClasses") {
		if viper.GetBool("PygmentsUseClasses") {
			options["noclasses"] = "false"
		} else {
			options["noclasses"] = "true"
		}

	}

	if _, ok := options["encoding"]; !ok {
		options["encoding"] = "utf8"
	}

	return options, nil
}
Ejemplo n.º 3
0
func getLdflags(info ProjectInfo) string {
	if viper.IsSet("build.ldflags") {
		var (
			tmplOutput = new(bytes.Buffer)
			fnMap      = template.FuncMap{
				"date":      time.Now().UTC().Format,
				"host":      os.Hostname,
				"user":      UserFunc,
				"goversion": runtime.Version,
				"repoPath":  RepoPathFunc,
			}
			ldflags = viper.GetString("build.ldflags")
		)

		tmpl, err := template.New("ldflags").Funcs(fnMap).Parse(ldflags)
		fatalMsg(err, "Failed to parse ldflags text/template :")

		err = tmpl.Execute(tmplOutput, info)
		fatalMsg(err, "Failed to execute ldflags text/template :")

		if goos != "darwin" {
			tmplOutput.WriteString("-extldflags \"-static\"")
		}

		return tmplOutput.String()
	}

	return fmt.Sprintf("-X main.Version %s", info.Version)
}
Ejemplo n.º 4
0
func watch() {
	if !viper.IsSet("raven_dev") {
		log.Fatal("Please specify a Raven device to connect to")
	}

	raven, err := goraven.Connect(viper.GetString("raven_dev"))
	if err != nil {
		log.Fatal(err)
	}

	defer raven.Close()

	for {
		notify, err := raven.Receive()
		if err != nil {
			log.Println(err)
		}

		switch t := notify.(type) {
		case *goraven.ConnectionStatus:
			log.Printf("Connection Status: %s", t.Status)
		case *goraven.CurrentSummationDelivered:
			pushCurrentSummationDelivered(t)
		case *goraven.InstantaneousDemand:
			pushInstantaneousDemand(t)
		default:
		}
	}
}
Ejemplo n.º 5
0
// Init initializes the crypto layer. It load from viper the security level
// and the logging setting.
func Init() (err error) {
	// Init log
	log.ExtraCalldepth++

	level, err := logging.LogLevel(viper.GetString("logging.crypto"))
	if err == nil {
		// No error, use the setting
		logging.SetLevel(level, "crypto")
		log.Info("Log level recognized '%s', set to %s", viper.GetString("logging.crypto"),
			logging.GetLevel("crypto"))
	} else {
		log.Warning("Log level not recognized '%s', defaulting to %s: %s", viper.GetString("logging.crypto"),
			logging.GetLevel("crypto"), err)
	}

	// Init security level

	securityLevel := 256
	if viper.IsSet("security.level") {
		ovveride := viper.GetInt("security.level")
		if ovveride != 0 {
			securityLevel = ovveride
		}
	}
	log.Debug("Working at security level [%d]", securityLevel)
	if err = conf.InitSecurityLevel(securityLevel); err != nil {
		log.Debug("Failed setting security level: [%s]", err)

		return
	}

	return
}
Ejemplo n.º 6
0
func (m *conduitServerService) Execute(args []string, r <-chan svc.ChangeRequest, changes chan<- svc.Status) (ssec bool, errno uint32) {
	const cmdsAccepted = svc.AcceptStop | svc.AcceptShutdown | svc.AcceptPauseAndContinue
	changes <- svc.Status{State: svc.StartPending}
	changes <- svc.Status{State: svc.Running, Accepts: cmdsAccepted}
	if viper.IsSet("enable_long_polling") {
		server.EnableLongPolling = viper.GetBool("enable_long_polling")
	}
	err := server.Start(viper.GetString("host"))
	fmt.Println("Could not start server:", err)
loop:
	for {
		select {
		case c := <-r:
			switch c.Cmd {
			case svc.Interrogate:
				changes <- c.CurrentStatus
				time.Sleep(100 * time.Millisecond)
				changes <- c.CurrentStatus
			case svc.Stop, svc.Shutdown:
				break loop
			default:
			}
		}
	}
	changes <- svc.Status{State: svc.StopPending}
	return
}
Ejemplo n.º 7
0
// overwriteFlagsWithViperConfig finds and writes values to flags using viper as input.
func overwriteFlagsWithViperConfig() {
	viperFlagSetter := func(f *flag.Flag) {
		if viper.IsSet(f.Name) {
			f.Value.Set(viper.GetString(f.Name))
		}
	}
	flag.VisitAll(viperFlagSetter)
}
Ejemplo n.º 8
0
func validityPeriodUpdateEnabled() bool {
	// If the update of the validity period is enabled in the configuration file return the configured value
	if viper.IsSet("pki.validity-period.update") {
		return viper.GetBool("pki.validity-period.update")
	}

	// Validity period update is enabled by default if no configuration was specified.
	return true
}
func validityPeriodVerificationEnabled() bool {
	// If the verification of the validity period is enabled in the configuration file return the configured value
	if viper.IsSet("peer.validator.validity-period.verification") {
		return viper.GetBool("peer.validator.validity-period.verification")
	}

	// Validity period verification is enabled by default if no configuration was specified.
	return true
}
Ejemplo n.º 10
0
func deploySystemChaincodeEnabled() bool {
	// If the deployment of system chaincode is enabled in the configuration file return the configured value
	if viper.IsSet("ledger.blockchain.deploy-system-chaincode") {
		return viper.GetBool("ledger.blockchain.deploy-system-chaincode")
	}

	// Deployment of system chaincode is enabled by default if no configuration was specified.
	return true
}
Ejemplo n.º 11
0
//TestViper try to use viper
func TestViper() {
	viper.AddConfigPath("/home/xiaoju/goworkspace/goplayground/")
	viper.SetConfigName("test")
	viper.SetConfigType("toml")

	err := viper.ReadInConfig()
	if err != nil {
		fmt.Println("read viper configure", err)
	}
	//

	var x int
	if viper.IsSet("logger.meta.other.xo") {
		x = viper.GetInt("logger.meta.other.xo")
	} else {
		x = 8
	}

	if viper.IsSet("logger.meta.input") {
		metaInput := viper.GetStringMap("logger.meta.input")
		for k, v := range metaInput {
			// if viper.IsSet("logger.meta.input." + k) {
			// 	kv := viper.GetStringMapString("logger.meta.input." + k)
			// 	for x, y := range kv {
			// 		fmt.Println(x, y)
			// 	}
			// }
			fmt.Println(k, v)

			if value, ok := v.(map[string]string); ok {
				for x, y := range value {
					fmt.Println(x, y)
				}
			} else {
				fmt.Println(ok)
			}
		}
	}
	// for k, v := range logConf["meta"]["input"] {
	// 	fmt.Println(k, v)
	// }
	fmt.Println(x)
}
Ejemplo n.º 12
0
Archivo: govm.go Proyecto: arbrix/govm
func NewApp(cnfFileName string) *App {
	log.Printf("httpapi init, read config from: %s\n", cnfFileName)

	app := &App{}
	app.router = echo.New()
	app.router.Use(middleware.Logger(), middleware.Recover())
	app.router.Use(echoJsonCheckErrorMW())
	app.router.Get("/vms", app.handleListVm)
	app.router.Post("/vms/:alias", app.handleDownloadVm)

	viper.SetConfigFile(cnfFileName)
	err := viper.ReadInConfig()
	//if config file exists and configs have been read successfully
	if err == nil {
		for _, cnfAlias := range []string{
			"GOVC_URL",
			"GOVC_USERNAME",
			"GOVC_PASSWORD",
			"GOVC_CERTIFICATE",
			"GOVC_PRIVATE_KEY",
			"GOVC_INSECURE",
			"GOVC_PERSIST_SESSION",
			"GOVC_MIN_API_VERSION",
		} {
			//rewrite only if not set in env scope
			if viper.IsSet(cnfAlias) && os.Getenv(cnfAlias) == "" {
				//log.Printf("write to env: %s=%s\n", cnfAlias, viper.GetString(cnfAlias))
				os.Setenv(cnfAlias, viper.GetString(cnfAlias))
			}
		}
		if viper.IsSet("vm-path") {
			app.vmPath = viper.GetString("vm-path")
			//log.Printf("vm path for host: %s\n", app.vmPath)
		}
	} else {
		log.Fatalf("%s\nThis application need config.json with vm-path key and path to VM on host machine\n", err)
	}

	return app
}
Ejemplo n.º 13
0
// InitializeConfig loads our configuration using Viper package.
func InitializeConfig() {
	// Set config file
	viper.SetConfigName("config")

	// Add config path
	viper.AddConfigPath("$HOME/.sharptv")

	// Read in the config
	err := viper.ReadInConfig() // Find and read the config file
	if err != nil {             // Handle errors reading the config file
		panic(fmt.Errorf("Fatal error config file: %s \n", err))
	}

	// Load default settings
	viper.SetDefault("debug", false)

	viper.SetEnvPrefix("gosharptv") // will be uppercased automatically
	viper.BindEnv("debug")
	viper.BindEnv("ip")
	viper.BindEnv("port")

	// Do some flag handling and any complicated config logic
	if !viper.IsSet("ip") || !viper.IsSet("port") {
		fmt.Println("Configuration error.  Both IP and PORT must be set via either config, environment, or flags.")
		os.Exit(1)
	}

	// TODO --implement the use of this data in the input command

	inputLabelMap = make(map[string]int)

	inputNames := []string{"input1", "input2", "input3", "input4", "input5", "input6", "input7", "input8"}
	for i, v := range inputNames {
		if viper.IsSet(v) {
			inputname := viper.GetString(v)
			inputLabelMap[inputname] = i + 1
		}
	}
}
Ejemplo n.º 14
0
func whichLicense() string {
	// if explicitly flagged, use that
	if userLicense != "" {
		return matchLicense(userLicense)
	}

	// if already present in the project, use that
	// TODO: Inspect project for existing license

	// default to viper's setting

	if viper.IsSet("license.header") || viper.IsSet("license.text") {
		if custom, ok := Licenses["custom"]; ok {
			custom.Header = viper.GetString("license.header")
			custom.Text = viper.GetString("license.text")
			Licenses["custom"] = custom
			return "custom"
		}
	}

	return matchLicense(viper.GetString("license"))
}
Ejemplo n.º 15
0
func setupLogging() {
	logLevel, ok := logger.LevelMatches[strings.ToUpper(viper.GetString("log_level"))]
	if !ok {
		logLevel = logger.LevelInfo
	}
	logger.SetLogThreshold(logLevel)
	logger.SetStdoutThreshold(logLevel)

	if viper.IsSet("log_file") && viper.GetString("log_file") != "" {
		logger.SetLogFile(viper.GetString("log_file"))
		// do not log into stdout when log file provided
		logger.SetStdoutThreshold(logger.LevelNone)
	}
}
Ejemplo n.º 16
0
func loadConfigs() {
	genesisLogger.Info("Loading configurations...")
	genesis = viper.GetStringMap("ledger.blockchain.genesisBlock")
	mode = viper.GetString("chaincode.chaincoderunmode")
	genesisLogger.Info("Configurations loaded: genesis=%s, mode=[%s], deploySystemChaincodeEnabled=[%t]",
		genesis, mode, deploySystemChaincodeEnabled)
	if viper.IsSet("ledger.blockchain.deploy-system-chaincode") {
		// If the deployment of system chaincode is enabled in the configuration file return the configured value
		deploySystemChaincodeEnabled = viper.GetBool("ledger.blockchain.deploy-system-chaincode")
	} else {
		// Deployment of system chaincode is enabled by default if no configuration was specified.
		deploySystemChaincodeEnabled = true
	}
}
Ejemplo n.º 17
0
func getGlobalProject(v *viper.Viper) (*libcentrifugo.Project, bool) {
	p := &libcentrifugo.Project{}

	// TODO: the same as for structureFromConfig function
	if v == nil {
		if !viper.IsSet("project_name") || viper.GetString("project_name") == "" {
			return nil, false
		}
		p.Name = libcentrifugo.ProjectKey(viper.GetString("project_name"))
		p.Secret = viper.GetString("project_secret")
		p.ConnLifetime = int64(viper.GetInt("project_connection_lifetime"))
		p.Anonymous = viper.GetBool("project_anonymous")
		p.Watch = viper.GetBool("project_watch")
		p.Publish = viper.GetBool("project_publish")
		p.JoinLeave = viper.GetBool("project_join_leave")
		p.Presence = viper.GetBool("project_presence")
		p.HistorySize = int64(viper.GetInt("project_history_size"))
		p.HistoryLifetime = int64(viper.GetInt("project_history_lifetime"))
	} else {
		if !v.IsSet("project_name") || v.GetString("project_name") == "" {
			return nil, false
		}
		p.Name = libcentrifugo.ProjectKey(v.GetString("project_name"))
		p.Secret = v.GetString("project_secret")
		p.ConnLifetime = int64(v.GetInt("project_connection_lifetime"))
		p.Anonymous = v.GetBool("project_anonymous")
		p.Watch = v.GetBool("project_watch")
		p.Publish = v.GetBool("project_publish")
		p.JoinLeave = v.GetBool("project_join_leave")
		p.Presence = v.GetBool("project_presence")
		p.HistorySize = int64(v.GetInt("project_history_size"))
		p.HistoryLifetime = int64(v.GetInt("project_history_lifetime"))
	}

	var nl []libcentrifugo.Namespace
	if v == nil {
		viper.MarshalKey("project_namespaces", &nl)
	} else {
		v.MarshalKey("project_namespaces", &nl)
	}
	p.Namespaces = nl

	return p, true
}
Ejemplo n.º 18
0
func (conf *configuration) init() error {
	conf.configurationPathProperty = "peer.fileSystemPath"
	conf.ecaPAddressProperty = "peer.pki.eca.paddr"
	conf.tcaPAddressProperty = "peer.pki.tca.paddr"
	conf.tlscaPAddressProperty = "peer.pki.tlsca.paddr"

	// Check mandatory fields
	if err := conf.checkProperty(conf.configurationPathProperty); err != nil {
		return err
	}
	if err := conf.checkProperty(conf.ecaPAddressProperty); err != nil {
		return err
	}
	if err := conf.checkProperty(conf.tcaPAddressProperty); err != nil {
		return err
	}
	if err := conf.checkProperty(conf.tlscaPAddressProperty); err != nil {
		return err
	}

	// Set configuration path
	conf.configurationPath = filepath.Join(
		viper.GetString(conf.configurationPathProperty),
		"crypto", conf.prefix, conf.name,
	)

	// Set ks path
	conf.keystorePath = filepath.Join(conf.configurationPath, "ks")

	// Set raws path
	conf.rawsPath = filepath.Join(conf.keystorePath, "raw")

	// Set TLS host override
	conf.tlsServerName = "tlsca"
	if viper.IsSet("peer.pki.tls.server-host-override") {
		ovveride := viper.GetString("peer.pki.tls.server-host-override")
		if ovveride != "" {
			conf.tlsServerName = ovveride
		}
	}

	return nil
}
Ejemplo n.º 19
0
func init() {
	viper.SetDefault("port", 8080)
	viper.SetDefault("min_passwd_len", 8)
	viper.SetDefault("pgp_sign", false)
	viper.SetDefault("smtp_host", "localhost")
	viper.SetDefault("smtp_port", 25)
	viper.SetDefault("email_link_base", "http://localhost")
	viper.SetDefault("email_from", "*****@*****.**")
	viper.SetDefault("email_prefix", "mokey")
	viper.SetDefault("setup_max_age", 86400)
	viper.SetDefault("reset_max_age", 3600)
	viper.SetDefault("max_attempts", 10)
	viper.SetDefault("bind", "")
	viper.SetDefault("secret_key", "change-me")
	viper.SetDefault("driver", "mysql")
	viper.SetDefault("dsn", "/mokey?parseTime=true")
	viper.SetDefault("rate_limit", false)
	viper.SetDefault("redis", ":6379")
	viper.SetDefault("max_requests", 15)
	viper.SetDefault("rate_limit_expire", 3600)

	gob.Register(&ipa.UserRecord{})
	gob.Register(&ipa.IpaDateTime{})

	if !viper.IsSet("ipahost") {
		cfg, err := ini.Load("/etc/ipa/default.conf")
		if err != nil {
			viper.SetDefault("ipahost", "localhost")
			return
		}

		ipaServer, err := cfg.Section("global").GetKey("server")
		if err != nil {
			viper.SetDefault("ipahost", "localhost")
			return
		}

		viper.SetDefault("ipahost", ipaServer)
	}
}
Ejemplo n.º 20
0
func configureTargets() io.Writer {
	if viper.IsSet("log.targets") {
		var (
			writers    []io.Writer
			logTargets []logTarget
		)
		if err := mapstructure.Decode(viper.Get("log.targets"), &logTargets); err != nil {
			panic(fmt.Errorf("Failed to process log targets: %s", err))
		}
		for _, target := range logTargets {
			switch target.Type {
			case "os":
				if target.Target == "stdout" {
					writers = append(writers, output.Stdout())
				} else if target.Target == "stderr" {
					writers = append(writers, output.Stderr())
				}
			case "file":
				file, err := os.OpenFile(target.Target, os.O_APPEND|os.O_WRONLY, os.ModeAppend)
				if err != nil {
					if os.IsNotExist(err) {
						file, err = os.Create(target.Target)
						if err != nil {
							panic(fmt.Errorf("Failed creating a file log target: %s", err))
						}
					} else {
						panic(err)
					}
				}
				writers = append(writers, file)
			}
		}

		return io.MultiWriter(writers...)
	}

	return output.Stdout()
}
Ejemplo n.º 21
0
func (f Funcs) CallFactory(keyPrefix string, namespace string, defaultFactory string) *reflect.Value { //, error) {
	key := fmt.Sprintf("%s.%s.factory", keyPrefix, namespace)
	var factory string
	if !viper.IsSet(key) {
		//TODO: warn
		println("key is not set: ", key)
		factory = defaultFactory
	} else {
		println("key is set: ", key)
		factory = viper.GetString(key)
	}
	fmt.Printf("factory '%s'\n", factory)
	results, err := f.Call(factory)

	fmt.Errorf("error in CallFactory. key: %s, factory: %s\n%s", key, factory, err) //TODO deal with err

	if len(results) != 1 {
		return nil //, errors.New("Wrong number of loadbalancer results " + strconv.Itoa(len(results)))
	}

	result := results[0]
	return &result
}
Ejemplo n.º 22
0
// Enable viper configuration management of flags.
func ViperizeFlags() {
	// Add viper in a minimal way.
	// Flag interop isnt possible, since 'go test' coupling to flag.Parse.
	viper.SetConfigName("e2e")
	viper.AddConfigPath(".")
	viper.ReadInConfig()

	// TODO @jayunit100: Maybe a more elegant viper-flag integration for the future?
	// For now, we layer it on top, because 'flag' deps of 'go test' make pflag wrappers
	// fragile, seeming to force 'flag' to have deep awareness of pflag params.
	RegisterCommonFlags()
	RegisterClusterFlags()
	flag.Parse()

	viperFlagSetter := func(f *flag.Flag) {
		if viper.IsSet(f.Name) {
			glog.V(4).Infof("[viper config] Overwriting, found a settting for %v %v", f.Name, f.Value)
			f.Value.Set(viper.GetString(f.Name))
		}
	}
	// Each flag that we've declared can be set via viper.
	flag.VisitAll(viperFlagSetter)
}
Ejemplo n.º 23
0
/*
 * POST /projects
 */
func PostProjects(w http.ResponseWriter, r *http.Request) {
	var project models.ProjectRequest
	//Extract github repo url
	body, err := ioutil.ReadAll(io.LimitReader(r.Body, 1048576))
	if err != nil {
		panic(err)
	}
	if err := r.Body.Close(); err != nil {
		panic(err)
	}
	if err := json.Unmarshal(body, &project); err != nil {
		w.Header().Set("Content-Type", "application/json; charset=UTF-8")
		w.WriteHeader(422) // unprocessable entity
		if err := json.NewEncoder(w).Encode(err); err != nil {
			panic(err)
		}
	}
	log.Println("Creating a docker")
	//local docker
	var dockerClient *externals.DockerInteractor
	if viper.IsSet("dockerRemote") {
		dockerClient = externals.NewRemoteInteractor(viper.GetString("dockerRemote.ip"), viper.GetString("dockerRemote.port"))
	} else {
		dockerClient = externals.NewLocalInteractor("unix:///var/run/docker.sock")
	}
	config := externals.Config{
		User:    "******",
		Project: "project1",
	}
	dockerClient.RunContainer(config)

	log.Println("Retrieving github " + project.Github + " from docker")
	//Call inside the executed docker the set up server

	fmt.Fprintln(w, "ok")
}
Ejemplo n.º 24
0
// InitializeConfig initializes a config file with sensible default configuration flags.
func InitializeConfig() {
	viper.SetConfigFile(CfgFile)
	viper.AddConfigPath(Source)
	err := viper.ReadInConfig()
	if err != nil {
		jww.ERROR.Println("Unable to locate Config file. Perhaps you need to create a new site. Run `hugo help new` for details")
	}

	viper.RegisterAlias("indexes", "taxonomies")

	LoadDefaultSettings()

	if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed {
		viper.Set("BuildDrafts", Draft)
	}

	if hugoCmdV.PersistentFlags().Lookup("buildFuture").Changed {
		viper.Set("BuildFuture", Future)
	}

	if hugoCmdV.PersistentFlags().Lookup("uglyUrls").Changed {
		viper.Set("UglyURLs", UglyURLs)
	}

	if hugoCmdV.PersistentFlags().Lookup("disableRSS").Changed {
		viper.Set("DisableRSS", DisableRSS)
	}

	if hugoCmdV.PersistentFlags().Lookup("disableSitemap").Changed {
		viper.Set("DisableSitemap", DisableSitemap)
	}

	if hugoCmdV.PersistentFlags().Lookup("verbose").Changed {
		viper.Set("Verbose", Verbose)
	}

	if hugoCmdV.PersistentFlags().Lookup("pluralizeListTitles").Changed {
		viper.Set("PluralizeListTitles", PluralizeListTitles)
	}

	if hugoCmdV.PersistentFlags().Lookup("preserveTaxonomyNames").Changed {
		viper.Set("PreserveTaxonomyNames", PreserveTaxonomyNames)
	}

	if hugoCmdV.PersistentFlags().Lookup("editor").Changed {
		viper.Set("NewContentEditor", Editor)
	}

	if hugoCmdV.PersistentFlags().Lookup("logFile").Changed {
		viper.Set("LogFile", LogFile)
	}
	if BaseURL != "" {
		if !strings.HasSuffix(BaseURL, "/") {
			BaseURL = BaseURL + "/"
		}
		viper.Set("BaseURL", BaseURL)
	}

	if !viper.GetBool("RelativeURLs") && viper.GetString("BaseURL") == "" {
		jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
	}

	if Theme != "" {
		viper.Set("theme", Theme)
	}

	if Destination != "" {
		viper.Set("PublishDir", Destination)
	}

	if Source != "" {
		viper.Set("WorkingDir", Source)
	} else {
		dir, _ := os.Getwd()
		viper.Set("WorkingDir", dir)
	}

	if hugoCmdV.PersistentFlags().Lookup("ignoreCache").Changed {
		viper.Set("IgnoreCache", IgnoreCache)
	}

	if CacheDir != "" {
		if helpers.FilePathSeparator != CacheDir[len(CacheDir)-1:] {
			CacheDir = CacheDir + helpers.FilePathSeparator
		}
		isDir, err := helpers.DirExists(CacheDir, hugofs.SourceFs)
		utils.CheckErr(err)
		if isDir == false {
			mkdir(CacheDir)
		}
		viper.Set("CacheDir", CacheDir)
	} else {
		viper.Set("CacheDir", helpers.GetTempDir("hugo_cache", hugofs.SourceFs))
	}

	if VerboseLog || Logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
		if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
			jww.SetLogFile(viper.GetString("LogFile"))
		} else {
			jww.UseTempLogFile("hugo")
		}
	} else {
		jww.DiscardLogging()
	}

	if viper.GetBool("verbose") {
		jww.SetStdoutThreshold(jww.LevelInfo)
	}

	if VerboseLog {
		jww.SetLogThreshold(jww.LevelInfo)
	}

	jww.INFO.Println("Using config file:", viper.ConfigFileUsed())

	themeDir := helpers.GetThemeDir()
	if themeDir != "" {
		if _, err := os.Stat(themeDir); os.IsNotExist(err) {
			jww.FATAL.Fatalln("Unable to find theme Directory:", themeDir)
		}
	}

	themeVersionMismatch, minVersion := helpers.IsThemeVsHugoVersionMismatch()

	if themeVersionMismatch {
		jww.ERROR.Printf("Current theme does not support Hugo version %s. Minimum version required is %s\n",
			helpers.HugoReleaseVersion(), minVersion)
	}
}
Ejemplo n.º 25
0
func mainCommand(cmd *cobra.Command, args []string) {
	err := viper.Unmarshal(&c)
	if err != nil {
		log.Fatalf("Unable to marshal configuration: %v", err)
	}
	if !viper.IsSet("dbpath") {
		log.Fatalf("Please set the dbpath configuration option or EVEINDY_DBPATH " +
			"environment variable to the database's path.")
	}

	if !(viper.IsSet("CookieDomain") && viper.IsSet("CookiePath")) {
		log.Fatalf("Please set the CookieDomain and CookiePath configuration options.")
	}

	if !(viper.IsSet("ClientID") && viper.IsSet("ClientSecret") &&
		viper.IsSet("RedirectURL")) {
		log.Fatalf("Please set the ClientID, ClientSecret, and RedirectURL configuration " +
			"options as registered with CCP.")
	}
	// workaround for viper bug
	// c.Dev = viper.GetBool("Dev")

	sde := dbaccess.SQLDatabase(c.DbDriver, c.DbPath)
	var myCache evego.Cache
	switch c.Cache {
	case "inproc":
		myCache = server.InMemCache()
	case "redis":
		if c.RedisPassword != "" {
			myCache = cache.RedisCache(c.RedisHost, c.RedisPassword)
		} else {
			myCache = cache.RedisCache(c.RedisHost)
		}
	default:
		log.Fatalf(
			"The Cache configuration option must be set to \"inproc\" (default) or \"redis\".")
	}

	xmlAPI := eveapi.XML(c.XMLAPIEndpoint, sde, myCache)
	localdb, err := db.Interface(c.DbDriver, c.DbPath, xmlAPI)
	if err != nil {
		log.Fatalf("Unable to connect to local database: %v", err)
	}
	var router evego.Router

	switch c.Router {
	case "evecentral":
		router = routing.EveCentralRouter(
			"http://api.eve-central.com/api/route", myCache)
	case "sql":
		router = routing.SQLRouter(c.DbDriver, c.DbPath, myCache)
	default:
		log.Fatalf(
			"The Router configuration option must be set to \"evecentral\" (default) or \"sql\".")
	}

	eveCentralMarket := market.EveCentral(sde, router, xmlAPI,
		"http://api.eve-central.com/api/quicklook", myCache)

	sessionizer := server.GetSessionizer(c.CookieDomain, c.CookiePath, !c.Dev, localdb)

	mux := newMux()
	setRoutes(mux, sde, localdb, xmlAPI, eveCentralMarket, sessionizer, myCache)

	// Set up internal bits.

	// Start background jobs.
	server.StartJobs(localdb)

	serve(mux, c.BindProtocol, c.Bind)
}
Ejemplo n.º 26
0
Archivo: hugo.go Proyecto: tubo028/hugo
// InitializeConfig initializes a config file with sensible default configuration flags.
func InitializeConfig(subCmdVs ...*cobra.Command) error {
	if err := hugolib.LoadGlobalConfig(source, cfgFile); err != nil {
		return err
	}

	for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) {

		if flagChanged(cmdV.PersistentFlags(), "verbose") {
			viper.Set("verbose", verbose)
		}
		if flagChanged(cmdV.PersistentFlags(), "logFile") {
			viper.Set("logFile", logFile)
		}
		if flagChanged(cmdV.Flags(), "cleanDestinationDir") {
			viper.Set("cleanDestinationDir", cleanDestination)
		}
		if flagChanged(cmdV.Flags(), "buildDrafts") {
			viper.Set("buildDrafts", draft)
		}
		if flagChanged(cmdV.Flags(), "buildFuture") {
			viper.Set("buildFuture", future)
		}
		if flagChanged(cmdV.Flags(), "buildExpired") {
			viper.Set("buildExpired", expired)
		}
		if flagChanged(cmdV.Flags(), "uglyURLs") {
			viper.Set("uglyURLs", uglyURLs)
		}
		if flagChanged(cmdV.Flags(), "canonifyURLs") {
			viper.Set("canonifyURLs", canonifyURLs)
		}
		if flagChanged(cmdV.Flags(), "disable404") {
			viper.Set("disable404", disable404)
		}
		if flagChanged(cmdV.Flags(), "disableRSS") {
			viper.Set("disableRSS", disableRSS)
		}
		if flagChanged(cmdV.Flags(), "disableSitemap") {
			viper.Set("disableSitemap", disableSitemap)
		}
		if flagChanged(cmdV.Flags(), "enableRobotsTXT") {
			viper.Set("enableRobotsTXT", enableRobotsTXT)
		}
		if flagChanged(cmdV.Flags(), "pluralizeListTitles") {
			viper.Set("pluralizeListTitles", pluralizeListTitles)
		}
		if flagChanged(cmdV.Flags(), "preserveTaxonomyNames") {
			viper.Set("preserveTaxonomyNames", preserveTaxonomyNames)
		}
		if flagChanged(cmdV.Flags(), "ignoreCache") {
			viper.Set("ignoreCache", ignoreCache)
		}
		if flagChanged(cmdV.Flags(), "forceSyncStatic") {
			viper.Set("forceSyncStatic", forceSync)
		}
		if flagChanged(cmdV.Flags(), "noTimes") {
			viper.Set("noTimes", noTimes)
		}

	}

	if baseURL != "" {
		if !strings.HasSuffix(baseURL, "/") {
			baseURL = baseURL + "/"
		}
		viper.Set("baseURL", baseURL)
	}

	if !viper.GetBool("relativeURLs") && viper.GetString("baseURL") == "" {
		jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
	}

	if theme != "" {
		viper.Set("theme", theme)
	}

	if destination != "" {
		viper.Set("publishDir", destination)
	}

	var dir string
	if source != "" {
		dir, _ = filepath.Abs(source)
	} else {
		dir, _ = os.Getwd()
	}
	viper.Set("workingDir", dir)

	if contentDir != "" {
		viper.Set("contentDir", contentDir)
	}

	if layoutDir != "" {
		viper.Set("layoutDir", layoutDir)
	}

	if cacheDir != "" {
		viper.Set("cacheDir", cacheDir)
	}

	cacheDir = viper.GetString("cacheDir")
	if cacheDir != "" {
		if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] {
			cacheDir = cacheDir + helpers.FilePathSeparator
		}
		isDir, err := helpers.DirExists(cacheDir, hugofs.Source())
		utils.CheckErr(err)
		if isDir == false {
			mkdir(cacheDir)
		}
		viper.Set("cacheDir", cacheDir)
	} else {
		viper.Set("cacheDir", helpers.GetTempDir("hugo_cache", hugofs.Source()))
	}

	if verboseLog || logging || (viper.IsSet("logFile") && viper.GetString("logFile") != "") {
		if viper.IsSet("logFile") && viper.GetString("logFile") != "" {
			jww.SetLogFile(viper.GetString("logFile"))
		} else {
			jww.UseTempLogFile("hugo")
		}
	} else {
		jww.DiscardLogging()
	}

	if quiet {
		jww.SetStdoutThreshold(jww.LevelError)
	} else if viper.GetBool("verbose") {
		jww.SetStdoutThreshold(jww.LevelInfo)
	}

	if verboseLog {
		jww.SetLogThreshold(jww.LevelInfo)
	}

	jww.INFO.Println("Using config file:", viper.ConfigFileUsed())

	// Init file systems. This may be changed at a later point.
	hugofs.InitDefaultFs()

	themeDir := helpers.GetThemeDir()
	if themeDir != "" {
		if _, err := hugofs.Source().Stat(themeDir); os.IsNotExist(err) {
			return newSystemError("Unable to find theme Directory:", themeDir)
		}
	}

	themeVersionMismatch, minVersion := isThemeVsHugoVersionMismatch()

	if themeVersionMismatch {
		jww.ERROR.Printf("Current theme does not support Hugo version %s. Minimum version required is %s\n",
			helpers.HugoReleaseVersion(), minVersion)
	}

	return nil

}
Ejemplo n.º 27
0
// InitializeConfig initializes a config file with sensible default configuration flags.
func InitializeConfig() {
	viper.SetConfigFile(CfgFile)
	viper.AddConfigPath(Source)
	err := viper.ReadInConfig()
	if err != nil {
		jww.ERROR.Println("Unable to locate Config file. Perhaps you need to create a new site. Run `hugo help new` for details")
	}

	viper.RegisterAlias("indexes", "taxonomies")

	viper.SetDefault("Watch", false)
	viper.SetDefault("MetaDataFormat", "toml")
	viper.SetDefault("DisableRSS", false)
	viper.SetDefault("DisableSitemap", false)
	viper.SetDefault("ContentDir", "content")
	viper.SetDefault("LayoutDir", "layouts")
	viper.SetDefault("StaticDir", "static")
	viper.SetDefault("ArchetypeDir", "archetypes")
	viper.SetDefault("PublishDir", "public")
	viper.SetDefault("DataDir", "data")
	viper.SetDefault("DefaultLayout", "post")
	viper.SetDefault("BuildDrafts", false)
	viper.SetDefault("BuildFuture", false)
	viper.SetDefault("UglyURLs", false)
	viper.SetDefault("Verbose", false)
	viper.SetDefault("IgnoreCache", false)
	viper.SetDefault("CanonifyURLs", false)
	viper.SetDefault("Taxonomies", map[string]string{"tag": "tags", "category": "categories"})
	viper.SetDefault("Permalinks", make(hugolib.PermalinkOverrides, 0))
	viper.SetDefault("Sitemap", hugolib.Sitemap{Priority: -1})
	viper.SetDefault("PygmentsStyle", "monokai")
	viper.SetDefault("DefaultExtension", "html")
	viper.SetDefault("PygmentsUseClasses", false)
	viper.SetDefault("DisableLiveReload", false)
	viper.SetDefault("PluralizeListTitles", true)
	viper.SetDefault("FootnoteAnchorPrefix", "")
	viper.SetDefault("FootnoteReturnLinkContents", "")
	viper.SetDefault("NewContentEditor", "")
	viper.SetDefault("Paginate", 10)
	viper.SetDefault("PaginatePath", "page")
	viper.SetDefault("Blackfriday", helpers.NewBlackfriday())

	if hugoCmdV.PersistentFlags().Lookup("buildDrafts").Changed {
		viper.Set("BuildDrafts", Draft)
	}

	if hugoCmdV.PersistentFlags().Lookup("buildFuture").Changed {
		viper.Set("BuildFuture", Future)
	}

	if hugoCmdV.PersistentFlags().Lookup("uglyUrls").Changed {
		viper.Set("UglyURLs", UglyURLs)
	}

	if hugoCmdV.PersistentFlags().Lookup("disableRSS").Changed {
		viper.Set("DisableRSS", DisableRSS)
	}

	if hugoCmdV.PersistentFlags().Lookup("disableSitemap").Changed {
		viper.Set("DisableSitemap", DisableSitemap)
	}

	if hugoCmdV.PersistentFlags().Lookup("verbose").Changed {
		viper.Set("Verbose", Verbose)
	}

	if hugoCmdV.PersistentFlags().Lookup("pluralizeListTitles").Changed {
		viper.Set("PluralizeListTitles", PluralizeListTitles)
	}

	if hugoCmdV.PersistentFlags().Lookup("editor").Changed {
		viper.Set("NewContentEditor", Editor)
	}

	if hugoCmdV.PersistentFlags().Lookup("logFile").Changed {
		viper.Set("LogFile", LogFile)
	}
	if BaseURL != "" {
		if !strings.HasSuffix(BaseURL, "/") {
			BaseURL = BaseURL + "/"
		}
		viper.Set("BaseURL", BaseURL)
	}

	if viper.GetString("BaseURL") == "" {
		jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
	}

	if Theme != "" {
		viper.Set("theme", Theme)
	}

	if Destination != "" {
		viper.Set("PublishDir", Destination)
	}

	if Source != "" {
		viper.Set("WorkingDir", Source)
	} else {
		dir, _ := os.Getwd()
		viper.Set("WorkingDir", dir)
	}

	if hugoCmdV.PersistentFlags().Lookup("ignoreCache").Changed {
		viper.Set("IgnoreCache", IgnoreCache)
	}

	if CacheDir != "" {
		if helpers.FilePathSeparator != CacheDir[len(CacheDir)-1:] {
			CacheDir = CacheDir + helpers.FilePathSeparator
		}
		isDir, err := helpers.DirExists(CacheDir, hugofs.SourceFs)
		utils.CheckErr(err)
		if isDir == false {
			mkdir(CacheDir)
		}
		viper.Set("CacheDir", CacheDir)
	} else {
		viper.Set("CacheDir", helpers.GetTempDir("hugo_cache", hugofs.SourceFs))
	}

	if VerboseLog || Logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
		if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
			jww.SetLogFile(viper.GetString("LogFile"))
		} else {
			jww.UseTempLogFile("hugo")
		}
	} else {
		jww.DiscardLogging()
	}

	if viper.GetBool("verbose") {
		jww.SetStdoutThreshold(jww.LevelInfo)
	}

	if VerboseLog {
		jww.SetLogThreshold(jww.LevelInfo)
	}

	jww.INFO.Println("Using config file:", viper.ConfigFileUsed())
}
Ejemplo n.º 28
0
func (conf *configuration) init() error {
	conf.configurationPathProperty = "peer.fileSystemPath"
	conf.ecaPAddressProperty = "peer.pki.eca.paddr"
	conf.tcaPAddressProperty = "peer.pki.tca.paddr"
	conf.tlscaPAddressProperty = "peer.pki.tlsca.paddr"
	conf.logPrefix = "[" + conf.prefix + "." + conf.name + "] "

	// Check mandatory fields
	if err := conf.checkProperty(conf.configurationPathProperty); err != nil {
		return err
	}
	if err := conf.checkProperty(conf.ecaPAddressProperty); err != nil {
		return err
	}
	if err := conf.checkProperty(conf.tcaPAddressProperty); err != nil {
		return err
	}
	if err := conf.checkProperty(conf.tlscaPAddressProperty); err != nil {
		return err
	}

	conf.configurationPath = viper.GetString(conf.configurationPathProperty)
	conf.rootDataPath = conf.configurationPath

	// Set configuration path
	conf.configurationPath = filepath.Join(
		conf.configurationPath,
		"crypto", conf.prefix, conf.name,
	)

	// Set ks path
	conf.keystorePath = filepath.Join(conf.configurationPath, "ks")

	// Set raws path
	conf.rawsPath = filepath.Join(conf.keystorePath, "raw")

	// Set tCerts path
	conf.tCertsPath = filepath.Join(conf.keystorePath, "tcerts")

	conf.securityLevel = 384
	if viper.IsSet("security.level") {
		ovveride := viper.GetInt("security.level")
		if ovveride != 0 {
			conf.securityLevel = ovveride
		}
	}

	conf.hashAlgorithm = "SHA3"
	if viper.IsSet("security.hashAlgorithm") {
		ovveride := viper.GetString("security.hashAlgorithm")
		if ovveride != "" {
			conf.hashAlgorithm = ovveride
		}
	}

	// Set TLS host override
	conf.tlsServerName = "tlsca"
	if viper.IsSet("peer.pki.tls.serverhostoverride") {
		ovveride := viper.GetString("peer.pki.tls.serverhostoverride")
		if ovveride != "" {
			conf.tlsServerName = ovveride
		}
	}

	// Set tCertBatchSize
	conf.tCertBatchSize = 200
	if viper.IsSet("security.tcert.batch.size") {
		ovveride := viper.GetInt("security.tcert.batch.size")
		if ovveride != 0 {
			conf.tCertBatchSize = ovveride
		}
	}

	// Set multithread
	conf.multiThreading = false
	if viper.IsSet("security.multithreading.enabled") {
		conf.multiThreading = viper.GetBool("security.multithreading.enabled")
	}

	// Set attributes
	conf.tCertAttributes = []*membersrvc.TCertAttribute{}
	if viper.IsSet("security.tcert.attributes") {
		attributes := viper.GetStringMapString("security.tcert.attributes")
		for key, value := range attributes {
			conf.tCertAttributes = append(conf.tCertAttributes, &membersrvc.TCertAttribute{key, value})
		}
	}

	return nil
}
Ejemplo n.º 29
0
Archivo: hugo.go Proyecto: nitoyon/hugo
// InitializeConfig initializes a config file with sensible default configuration flags.
// A Hugo command that calls initCoreCommonFlags() can pass itself
// as an argument to have its command-line flags processed here.
func InitializeConfig(subCmdVs ...*cobra.Command) error {
	viper.SetConfigFile(cfgFile)
	// See https://github.com/spf13/viper/issues/73#issuecomment-126970794
	if source == "" {
		viper.AddConfigPath(".")
	} else {
		viper.AddConfigPath(source)
	}
	err := viper.ReadInConfig()
	if err != nil {
		if _, ok := err.(viper.ConfigParseError); ok {
			return newSystemError(err)
		} else {
			return newSystemErrorF("Unable to locate Config file. Perhaps you need to create a new site.\n       Run `hugo help new` for details. (%s)\n", err)
		}
	}

	viper.RegisterAlias("indexes", "taxonomies")

	LoadDefaultSettings()

	for _, cmdV := range append([]*cobra.Command{hugoCmdV}, subCmdVs...) {

		if flagChanged(cmdV.PersistentFlags(), "verbose") {
			viper.Set("Verbose", verbose)
		}
		if flagChanged(cmdV.PersistentFlags(), "logFile") {
			viper.Set("LogFile", logFile)
		}
		if flagChanged(cmdV.Flags(), "cleanDestinationDir") {
			viper.Set("cleanDestinationDir", cleanDestination)
		}
		if flagChanged(cmdV.Flags(), "buildDrafts") {
			viper.Set("BuildDrafts", draft)
		}
		if flagChanged(cmdV.Flags(), "buildFuture") {
			viper.Set("BuildFuture", future)
		}
		if flagChanged(cmdV.Flags(), "uglyURLs") {
			viper.Set("UglyURLs", uglyURLs)
		}
		if flagChanged(cmdV.Flags(), "canonifyURLs") {
			viper.Set("CanonifyURLs", canonifyURLs)
		}
		if flagChanged(cmdV.Flags(), "disableRSS") {
			viper.Set("DisableRSS", disableRSS)
		}
		if flagChanged(cmdV.Flags(), "disableSitemap") {
			viper.Set("DisableSitemap", disableSitemap)
		}
		if flagChanged(cmdV.Flags(), "disableRobotsTXT") {
			viper.Set("DisableRobotsTXT", disableRobotsTXT)
		}
		if flagChanged(cmdV.Flags(), "pluralizeListTitles") {
			viper.Set("PluralizeListTitles", pluralizeListTitles)
		}
		if flagChanged(cmdV.Flags(), "preserveTaxonomyNames") {
			viper.Set("PreserveTaxonomyNames", preserveTaxonomyNames)
		}
		if flagChanged(cmdV.Flags(), "ignoreCache") {
			viper.Set("IgnoreCache", ignoreCache)
		}
		if flagChanged(cmdV.Flags(), "forceSyncStatic") {
			viper.Set("ForceSyncStatic", forceSync)
		}
		if flagChanged(cmdV.Flags(), "noTimes") {
			viper.Set("NoTimes", noTimes)
		}

	}

	if baseURL != "" {
		if !strings.HasSuffix(baseURL, "/") {
			baseURL = baseURL + "/"
		}
		viper.Set("BaseURL", baseURL)
	}

	if !viper.GetBool("RelativeURLs") && viper.GetString("BaseURL") == "" {
		jww.ERROR.Println("No 'baseurl' set in configuration or as a flag. Features like page menus will not work without one.")
	}

	if theme != "" {
		viper.Set("theme", theme)
	}

	if destination != "" {
		viper.Set("PublishDir", destination)
	}

	if source != "" {
		dir, _ := filepath.Abs(source)
		viper.Set("WorkingDir", dir)
	} else {
		dir, _ := os.Getwd()
		viper.Set("WorkingDir", dir)
	}

	if contentDir != "" {
		viper.Set("ContentDir", contentDir)
	}

	if layoutDir != "" {
		viper.Set("LayoutDir", layoutDir)
	}

	if cacheDir != "" {
		if helpers.FilePathSeparator != cacheDir[len(cacheDir)-1:] {
			cacheDir = cacheDir + helpers.FilePathSeparator
		}
		isDir, err := helpers.DirExists(cacheDir, hugofs.SourceFs)
		utils.CheckErr(err)
		if isDir == false {
			mkdir(cacheDir)
		}
		viper.Set("CacheDir", cacheDir)
	} else {
		viper.Set("CacheDir", helpers.GetTempDir("hugo_cache", hugofs.SourceFs))
	}

	if verboseLog || logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
		if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
			jww.SetLogFile(viper.GetString("LogFile"))
		} else {
			jww.UseTempLogFile("hugo")
		}
	} else {
		jww.DiscardLogging()
	}

	if viper.GetBool("verbose") {
		jww.SetStdoutThreshold(jww.LevelInfo)
	}

	if verboseLog {
		jww.SetLogThreshold(jww.LevelInfo)
	}

	jww.INFO.Println("Using config file:", viper.ConfigFileUsed())

	themeDir := helpers.GetThemeDir()
	if themeDir != "" {
		if _, err := os.Stat(themeDir); os.IsNotExist(err) {
			return newSystemError("Unable to find theme Directory:", themeDir)
		}
	}

	themeVersionMismatch, minVersion := isThemeVsHugoVersionMismatch()

	if themeVersionMismatch {
		jww.ERROR.Printf("Current theme does not support Hugo version %s. Minimum version required is %s\n",
			helpers.HugoReleaseVersion(), minVersion)
	}

	return nil
}
Ejemplo n.º 30
0
Archivo: hugo.go Proyecto: h0wn0w/hugo
func InitializeConfig() {
	viper.SetConfigName(CfgFile)
	viper.AddConfigPath(Source)
	viper.ReadInConfig()

	viper.SetDefault("ContentDir", "content")
	viper.SetDefault("LayoutDir", "layouts")
	viper.SetDefault("StaticDir", "static")
	viper.SetDefault("PublishDir", "public")
	viper.SetDefault("DefaultLayout", "post")
	viper.SetDefault("BuildDrafts", false)
	viper.SetDefault("UglyUrls", false)
	viper.SetDefault("Verbose", false)
	viper.SetDefault("CanonifyUrls", false)
	viper.SetDefault("Indexes", map[string]string{"tag": "tags", "category": "categories"})
	viper.SetDefault("Permalinks", make(hugolib.PermalinkOverrides, 0))

	if hugoCmdV.PersistentFlags().Lookup("build-drafts").Changed {
		viper.Set("BuildDrafts", Draft)
	}

	if hugoCmdV.PersistentFlags().Lookup("uglyurls").Changed {
		viper.Set("UglyUrls", UglyUrls)
	}

	if hugoCmdV.PersistentFlags().Lookup("verbose").Changed {
		viper.Set("Verbose", Verbose)
	}

	if hugoCmdV.PersistentFlags().Lookup("logfile").Changed {
		viper.Set("LogFile", LogFile)
	}

	if BaseUrl != "" {
		if !strings.HasSuffix(BaseUrl, "/") {
			BaseUrl = BaseUrl + "/"
		}
		viper.Set("BaseUrl", BaseUrl)
	}
	if Destination != "" {
		viper.Set("PublishDir", Destination)
	}

	if Source != "" {
		viper.Set("WorkingDir", Source)
	} else {
		dir, _ := helpers.FindCWD()
		viper.Set("WorkingDir", dir)
	}

	if VerboseLog || Logging || (viper.IsSet("LogFile") && viper.GetString("LogFile") != "") {
		if viper.IsSet("LogFile") && viper.GetString("LogFile") != "" {
			jww.SetLogFile(viper.GetString("LogFile"))
		} else {
			jww.UseTempLogFile("hugo")
		}
	} else {
		jww.DiscardLogging()
	}

	if viper.GetBool("verbose") {
		jww.SetStdoutThreshold(jww.LevelDebug)
	}

	if VerboseLog {
		jww.SetLogThreshold(jww.LevelDebug)
	}

	jww.INFO.Println("Using config file:", viper.ConfigFileUsed())
}