...

Package cmdline

import "golang.conradwood.net/go-easyops/cmdline"
Overview
Index

Overview ▾

provides a standard configuration mechanism for clients and servers on the commandline

go-easyops itself can be configured through environment variables and command line parameters. any go-easyops program includes standard command line parameters. some are described below

-h

prints out build information and command line parameters for the application

-X

prints out build information and command line parameters to the behaviour of go-easyops

Environment Variables

-h and -X also print environment variables and a short help text for each. Application developers are encouraged to use this package to manage environment variables. a typical example

var (
  mytext = cmdline.ENV("MYTEXT","specifies the text to display")
)
func main() {
  fmt.Println(mytext.Value())
}

Config Files

a config file (typically /tmp/goeasyops.config) provides optional and initial configuration for go-easyops. This is intented to configure developer machines on-the-fly for access to a different cloud and cluster. For example, based on the current path, a git repository url may be used to configure a specific and matching registry. (config file syntax is in yaml, see goeasyops proto, protobuf "Config")

Constants

const (
    CONFIG_FILE      = "/tmp/goeasyops.config"
    REGISTRY_DEFAULT = "localhost:5000"
)
const (
    BUILD_NUMBER        = 1         // replaceme
    BUILD_DESCRIPTION   = "not set" //replaceme
    BUILD_TIMESTAMP     = 1         //replaceme
    BUILD_REPOSITORY_ID = 1         // replaceme
    BUILD_ARTEFACT_ID   = 1         // replaceme
    BUILD_REPOSITORY    = "not set" // replaceme
    BUILD_COMMIT        = "not set" // replaceme
)

Variables

var (
    XXdoappinfo = ImmediatePara("ge_info", "print application build number", doappinfo)
)

func ContextWithBuilder

func ContextWithBuilder() bool

func Datacenter

func Datacenter() bool

func DebugAuth

func DebugAuth() bool

func DebugSignature

func DebugSignature() bool

func DebugfContext

func DebugfContext(format string, args ...interface{})

print context debug stuff

func DebugfRPC

func DebugfRPC(format string, args ...interface{})

print context debug stuff

func DefaultTimeout

func DefaultTimeout() time.Duration

default timeout for new contexts

func ENV

func ENV(name, description string) *env_var

func EnabledExperiments

func EnabledExperiments() []string

func GetClientRegistryAddress

func GetClientRegistryAddress() string

get registry address as per -registry parameter, or if -registry_resolver is set, use that

func GetContextBuilderVersion

func GetContextBuilderVersion() int

this is for testing purposes to mock the parameter -ge_context_with_builder

func GetEnvContext

func GetEnvContext() string

get a serialised context from environment variable GE_CTX

func GetInstanceID

func GetInstanceID() string

func GetPid

func GetPid() uint64

func GetRegistryAddress

func GetRegistryAddress() string

get registry address as per -registry parameter

func GetYACloudDir

func GetYACloudDir() string

usually returns /opt/yacloud/current

func ImmediatePara

func ImmediatePara(name string, desc string, f func()) *impara

func IsDebugRPCClient

func IsDebugRPCClient() bool

func IsDebugRPCServer

func IsDebugRPCServer() bool

func IsEasyopsFlag

func IsEasyopsFlag(name string) bool

is this a flag defined and used by go-easyops?

func IsStandalone

func IsStandalone() bool

func LocalRegistrationDir

func LocalRegistrationDir() string

func OptEnvString

func OptEnvString(para, envname string) string

if (para != "") { return para }, else return os.GetEnv(envname)

func PrintDefaults

func PrintDefaults()

func PrintUsage

func PrintUsage()

func RandomString

func RandomString(n int) string

copy of "utils", but avoiding import cycle

func SetClientRegistryAddress

func SetClientRegistryAddress(reg string)

programmatically override -registry_resolver flag

func SetContextBuilderVersion

func SetContextBuilderVersion(version int)

this is for testing purposes to mock the parameter -ge_context_with_builder

func SetDatacenter

func SetDatacenter(b bool)

for testing purposes to mock parameter -AD_started_by_auto_deployer

func SetDebugContext

func SetDebugContext()

func SetEnvContext

func SetEnvContext(s string)

this is for testing purposes to mock the environment variable GE_CTX

func SourceCodePath

func SourceCodePath() string

returns the sourceode path from which main() was compiled into this binary