flags

package
v0.0.0-...-9fc3f77 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CacheFlag = cli.StringFlag{
	Name:        "cache",
	DefaultText: "redis://127.0.0.1:6379/0?dial_timeout=5s&read_timeout=3s",
	Usage:       "`URI` of SSO background cache",

	Value:       "redis://127.0.0.1:6379/0?dial_timeout=5s&read_timeout=3s",
	Destination: &cache,
	Action:      nil,
}
View Source
var CfgFilePathFlag = cli.PathFlag{
	Name:        "config",
	Usage:       "Location of server config `FILE`",
	Destination: &path,
	Aliases:     []string{"c"},
	EnvVars:     []string{"SSO_CFG"},
}
View Source
var JwtFlag = cli.StringFlag{
	Name:        "jwt-secret",
	DefaultText: "./jwt-secret",
	Usage:       "Jwt secret phrase for user login authorization",

	FilePath:    "./jwt-secret",
	Destination: &jwtSecret,
	EnvVars:     []string{"SSO_JWT_SECRET"},
	Action:      nil,
}
View Source
var LogLevelFlag = cli.StringFlag{
	Name:        "log-level",
	DefaultText: "info",
	Usage:       "Set the logging level (\"debug\", \"info\", \"warn\", \"error\", \"fatal\")",
	Value:       "info",
	Destination: &logLevel,
	Aliases:     []string{"l"},
	EnvVars:     []string{"SSO_CFG"},
	Action: func(ctx *cli.Context, s string) error {
		levels := map[string]struct{}{
			"debug": struct{}{},
			"info":  struct{}{},
			"warn":  struct{}{},
			"error": struct{}{},
			"fatal": struct{}{},
		}
		if level := ctx.String("log-level"); level != "" {
			if _, ok := levels[level]; !ok {
				return fmt.Errorf("log-level %s is not support", level)
			}
		}
		return nil
	},
}
View Source
var ModeFlag = cli.StringFlag{
	Name:        "mode",
	DefaultText: "prod",
	Usage:       "Switch server mode",
	Value:       "prod",
	Destination: &mode,
	Aliases:     []string{"m"},
	EnvVars:     []string{"SSO_MODE"},
	Action: func(ctx *cli.Context, s string) error {
		if s != "" {
			if s == "dev" || s == "prod" {
				return nil
			}
			return fmt.Errorf("mode %s is not support", s)
		}
		return nil
	},
}
View Source
var OrmFlag = cli.StringFlag{
	Name:        "orm",
	DefaultText: "mysql://root:crane@127.0.0.1:3306/sso?charset=utf8mb4&parseTime=True&loc=UTC",
	Usage:       "`URI` of SSO background database",

	Value:       "mysql://root:crane@127.0.0.1:3306/sso?charset=utf8mb4&parseTime=True&loc=UTC",
	Destination: &orm,
	Action:      nil,
}

Functions

func CacheUri

func CacheUri() string

func CfgPath

func CfgPath() string

func JwtSecret

func JwtSecret() string

func LogFile

func LogFile() string

func LogLevel

func LogLevel() string

func Mode

func Mode() string

func OrmUri

func OrmUri() string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL