config

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2020 License: Apache-2.0 Imports: 14 Imported by: 53

Documentation

Overview

Example (UnmarshalInitConfig)
package main

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

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

Index

Examples

Constants

View Source
const InitialGlobalConfig = `` /* 1476-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()

Types

type AppServiceConfig added in v0.2.1

type AppServiceConfig struct {
	DefaultDraftStatus bool `json:"default_draft_status"`
}

type AttachmentConfig added in v0.4.2

type AttachmentConfig struct {
	AccessKey  string `default:"openpitrixminioaccesskey"`
	SecretKey  string `default:"openpitrixminiosecretkey"`
	Endpoint   string `default:"http://openpitrix-minio:9000"`
	BucketName string `default:"openpitrix-attachment"`
}

type BasicConfig added in v0.4.0

type BasicConfig struct {
	PlatformName string `json:"platform_name"`
	PlatformUrl  string `json:"platform_url"`
}

type ClusterServiceConfig

type ClusterServiceConfig struct {
	FrontgateConf       string `json:"frontgate_conf"`
	FrontgateAutoDelete bool   `json:"frontgate_auto_delete"`
	FrontgateAutoUpdate bool   `json:"frontgate_auto_update"`
	RegistryMirror      string `json:"registry_mirror"`
}

type Config

type Config struct {
	Log         LogConfig
	Grpc        GrpcConfig
	Mysql       MysqlConfig
	Etcd        EtcdConfig
	IAM         IAMConfig
	Attachment  AttachmentConfig
	DisableGops bool `default:"false"`
}

func GetConf added in v0.4.2

func GetConf() *Config

type EtcdConfig

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

type GlobalConfig

type GlobalConfig struct {
	App             AppServiceConfig                  `json:"app"`
	Repo            RepoServiceConfig                 `json:"repo"`
	Cluster         ClusterServiceConfig              `json:"cluster"`
	RuntimeProvider map[string]*RuntimeProviderConfig `json:"runtime_provider"`
	Pilot           PilotServiceConfig                `json:"pilot"`
	Job             JobServiceConfig                  `json:"job"`
	Task            TaskServiceConfig                 `json:"task"`
	BasicCfg        BasicConfig                       `json:"basic_config"`
	InstallModule   InstallModuleConfig               `json:"install_module"`
}

func DecodeInitConfig

func DecodeInitConfig() GlobalConfig

func ParseGlobalConfig

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

func (*GlobalConfig) GetAppDefaultStatus added in v0.2.1

func (g *GlobalConfig) GetAppDefaultStatus() string

func (*GlobalConfig) GetRuntimeImageIdAndUrl added in v0.1.5

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

func (*GlobalConfig) RegisterRuntimeProviderConfig added in v0.4.0

func (g *GlobalConfig) RegisterRuntimeProviderConfig(provider, config string) error

type GrpcConfig

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

type IAMConfig added in v0.2.3

type IAMConfig struct {
	SecretKey              string        `default:"OpenPitrix-lC4LipAXPYsuqw5F"`
	ExpireTime             time.Duration `default:"2h"`
	RefreshTokenExpireTime time.Duration `default:"336h"` // default is 2 week
}

type InstallModuleConfig added in v0.4.2

type InstallModuleConfig struct {
	Iam          bool `json:"iam"`
	Notification bool `json:"notification"`
}

type JobServiceConfig added in v0.2.3

type JobServiceConfig struct {
	MaxWorkingJobs int32 `json:"max_working_jobs"`
}

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"`
	Port int32  `json:"port"`
}

type RepoServiceConfig

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

type RuntimeProviderConfig added in v0.4.0

type RuntimeProviderConfig 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"`
	FrontgateConf   string                 `json:"frontgate_conf"`
	ProviderType    string                 `json:"provider_type"`
	Host            string                 `json:"host"`
	Port            int                    `json:"port"`
	Enable          bool                   `json:"enable"`
	AdvancedOptions map[string]interface{} `json:"advanced_options"`
}

func ParseRuntimeProviderConfig added in v0.4.0

func ParseRuntimeProviderConfig(data []byte) (*RuntimeProviderConfig, error)

func (*RuntimeProviderConfig) GetEnable added in v0.4.0

func (r *RuntimeProviderConfig) GetEnable() bool

func (*RuntimeProviderConfig) GetHost added in v0.4.0

func (r *RuntimeProviderConfig) GetHost(provider string) string

func (*RuntimeProviderConfig) GetPort added in v0.4.0

func (r *RuntimeProviderConfig) GetPort() int

type TaskServiceConfig added in v0.2.3

type TaskServiceConfig struct {
	MaxWorkingTasks int32 `json:"max_working_tasks"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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