Documentation ¶
Overview ¶
The parent config package get root dir when init, it panics if no root is found. So this package extract the common code, so it can be used by xiaomei.
Index ¶
- Constants
- func DetectReleaseConfigDirOf(majorEnv string) string
- func DetectReleaseDir() (dir string, hasDirectContent bool)
- func GetDB(configMap strmap.StrMap, typ, key string) (interface{}, error)
- func TimestampSign(ts int64, secret string) string
- type Config
- type Cookie
- type Environment
- func (e *Environment) IsCI() bool
- func (e *Environment) IsDev() bool
- func (e *Environment) IsPreview() bool
- func (e *Environment) IsProduction() bool
- func (e *Environment) IsQA() bool
- func (e *Environment) IsTest() bool
- func (e *Environment) Major() string
- func (e *Environment) MajorIs(v string) bool
- func (e *Environment) Minor() string
- func (e *Environment) MinorIs(v string) bool
- func (e *Environment) PreviewToProduction() Environment
- func (e *Environment) String() string
- func (e *Environment) Vars() []string
- type Shard
- type Shards
- type ShardsSettings
Examples ¶
Constants ¶
View Source
const EnvVar = "ProENV"
Variables ¶
This section is empty.
Functions ¶
func DetectReleaseConfigDirOf ¶
DetectReleaseConfigDirOf return the release config dir of a major environment, which contains clusters.yml, deploy.yml.
func DetectReleaseDir ¶
DetectReleaseDir return the top release dir of a project.
Types ¶
type Config ¶
type Config struct { Name string `yaml:"name"` RawExternalURL string `yaml:"externalURL"` Secret string `yaml:"secret"` Cookie Cookie `yaml:"cookie"` Mailer string `yaml:"mailer"` Keepers []string `yaml:"keepers"` TimeZone timeZone `yaml:"timeZone"` Data strmap.StrMap `yaml:"data"` Env Environment `yaml:"-"` ExternalURL *url.URL `yaml:"-"` TimeLocation *time.Location `yaml:"-"` // contains filtered or unexported fields }
func Get ¶
Example ¶
config := Get(`../release/img-app/config/test.yml`, `test`) fmt.Println(GetDB(config.Data, `postgres`, `test`)) if v, err := GetDB(config.Data, `postgres`, `shards`); err != nil { fmt.Println(err) } else if shards, ok := v.(*Shards); ok { for _, row := range shards.Shards { fmt.Printf("%+v\n", row) } fmt.Printf("%+v\n", shards.Settings) } else { fmt.Println(v) }
Output: postgres://postgres:postgres@localhost/postgres?sslmode=disable <nil> {No:1 Url:postgres://postgres:@localhost/test_1?sslmode=disable} {No:2 Url:postgres://postgres:@localhost/test_2?sslmode=disable} {IdSeqIncrementBy:1000}
func (*Config) DeployName ¶
func (*Config) ExternalURLIsHTTPS ¶
func (*Config) HttpCookie ¶
func (*Config) TimestampSign ¶
type Cookie ¶
type Cookie struct { Name string `yaml:"name"` Domain string `yaml:"domain"` Path string `yaml:"path"` MaxAge time2.Duration `yaml:"maxAge"` Secure bool `yaml:"secure"` HttpOnly bool `yaml:"httpOnly"` SameSite string `yaml:"sameSite"` }
If use http.Cookie, it has no yaml tags, upper camel case is required, so define a new one.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
func (*Environment) IsCI ¶
func (e *Environment) IsCI() bool
func (*Environment) IsDev ¶
func (e *Environment) IsDev() bool
func (*Environment) IsPreview ¶
func (e *Environment) IsPreview() bool
func (*Environment) IsProduction ¶
func (e *Environment) IsProduction() bool
func (*Environment) IsQA ¶
func (e *Environment) IsQA() bool
func (*Environment) IsTest ¶
func (e *Environment) IsTest() bool
func (*Environment) Major ¶
func (e *Environment) Major() string
func (*Environment) MajorIs ¶
func (e *Environment) MajorIs(v string) bool
func (*Environment) Minor ¶
func (e *Environment) Minor() string
func (*Environment) MinorIs ¶
func (e *Environment) MinorIs(v string) bool
func (*Environment) PreviewToProduction ¶
func (e *Environment) PreviewToProduction() Environment
PreviewToProduction return a production copy if IsPreview.
func (*Environment) String ¶
func (e *Environment) String() string
func (*Environment) Vars ¶
func (e *Environment) Vars() []string
type Shards ¶
type Shards struct { Shards []Shard Settings ShardsSettings }
type ShardsSettings ¶
type ShardsSettings struct {
IdSeqIncrementBy int
}
func GetShardsSettings ¶
func GetShardsSettings(v interface{}, path string) (*ShardsSettings, error)
Click to show internal directories.
Click to hide internal directories.