config

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2018 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Example (UnmarshalInitConfig)
package main

import (
	"openpitrix.io/openpitrix/pkg/config"
	"openpitrix.io/openpitrix/pkg/logger"
)

func main() {
	globalConfig := config.DecodeInitConfig()
	logger.Info("Got global config: \n%+v\n", globalConfig)
	logger.Info("Get global config string: \n%s\n", config.EncodeGlobalConfig(globalConfig))
}
Output:

Index

Examples

Constants

View Source
const (
	EtcdPrefix      = "openpitrix/"
	GlobalConfigKey = "global_config"
	DlockKey        = "dlock_" + GlobalConfigKey
)
View Source
const InitialGlobalConfig = `` /* 1623-byte string literal not displayed */

Variables

This section is empty.

Functions

func EncodeGlobalConfig

func EncodeGlobalConfig(conf GlobalConfig) string

func GetFlagSet

func GetFlagSet() *flag.FlagSet

func ParseFlag

func ParseFlag()

func PrintUsage

func PrintUsage()

func WatchGlobalConfig

func WatchGlobalConfig(etcd *etcd.Etcd, watcher Watcher) error

Types

type ClusterServiceConfig

type ClusterServiceConfig struct {
	Plugins             []string `json:"plugins"`
	FrontgateConf       string   `json:"frontgate_conf"`
	FrontgateAutoDelete bool     `json:"frontgate_auto_delete"`
}

type Config

type Config struct {
	Log       LogConfig
	Grpc      GrpcConfig
	Mysql     MysqlConfig
	Etcd      EtcdConfig
	Profiling ProfilingConfig
}

func LoadConf

func LoadConf() *Config

type EtcdConfig

type EtcdConfig struct {
	Endpoints string `default:"openpitrix-etcd:2379"` // Example: "localhost:2379,localhost:22379,localhost:32379"
}

type GlobalConfig

type GlobalConfig struct {
	Repo    RepoServiceConfig      `json:"repo"`
	Cluster ClusterServiceConfig   `json:"cluster"`
	Runtime map[string]ImageConfig `json:"runtime"`
	Pilot   PilotServiceConfig     `json:"pilot"`
}

func DecodeInitConfig

func DecodeInitConfig() GlobalConfig

func ParseGlobalConfig

func ParseGlobalConfig(data []byte) (GlobalConfig, error)

func (*GlobalConfig) GetFrontgateAutoDelete added in v0.1.7

func (g *GlobalConfig) GetFrontgateAutoDelete() bool

func (*GlobalConfig) GetRuntimeImageIdAndUrl added in v0.1.5

func (g *GlobalConfig) GetRuntimeImageIdAndUrl(apiServer, zone string) (*ImageConfig, error)

type GrpcConfig

type GrpcConfig struct {
	ShowErrorCause bool `default:"false"` // show grpc error cause to frontend
}

type ImageConfig

type ImageConfig struct {
	ApiServer string `json:"api_server"`
	Zone      string `json:"zone"`
	ImageId   string `json:"image_id"`
	ImageUrl  string `json:"image_url"`
	ImageName string `json:"image_name"`
}

type LogConfig

type LogConfig struct {
	Level string `default:"info"` // debug, info, warn, error, fatal
}

type MysqlConfig

type MysqlConfig struct {
	Host     string `default:"openpitrix-db"`
	Port     string `default:"3306"`
	User     string `default:"root"`
	Password string `default:"password"`
	Database string `default:"openpitrix"`
	Disable  bool   `default:"false"`
}

func (*MysqlConfig) GetUrl

func (m *MysqlConfig) GetUrl() string

type PilotServiceConfig

type PilotServiceConfig struct {
	Ip string `json:"ip"`
}

type ProfilingConfig added in v0.1.5

type ProfilingConfig struct {
	Enable bool `default:"false"`
}

type RepoServiceConfig

type RepoServiceConfig struct {
	Cron string `json:"cron"`
}

type Watcher

type Watcher chan *GlobalConfig

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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