本文整理汇总了Golang中github.com/litl/galaxy/utils.GalaxyEnv函数的典型用法代码示例。如果您正苦于以下问题:Golang GalaxyEnv函数的具体用法?Golang GalaxyEnv怎么用?Golang GalaxyEnv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GalaxyEnv函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: appList
func appList(c *cli.Context) {
initStore(c)
err := commander.AppList(configStore, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:7,代码来源:galaxy.go
示例2: poolCreate
func poolCreate(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
initStore(c)
created, err := configStore.CreatePool(utils.GalaxyPool(c), utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: Could not create pool: %s", err)
return
}
if created {
log.Printf("Pool %s created\n", utils.GalaxyPool(c))
} else {
log.Printf("Pool %s already exists\n", utils.GalaxyPool(c))
}
ec2host, err := runtime.EC2PublicHostname()
if err != nil || ec2host == "" {
log.Debug("not running from AWS, skipping pool creation")
return
}
// now create the cloudformation stack
// is this fails, the stack can be created separately with
// stack:create_pool
stackCreatePool(c)
}
开发者ID:zombor,项目名称:galaxy,代码行数:27,代码来源:galaxy.go
示例3: poolList
func poolList(c *cli.Context) {
initStore(c)
envs := []string{utils.GalaxyEnv(c)}
if utils.GalaxyEnv(c) == "" {
var err error
envs, err = configStore.ListEnvs()
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
columns := []string{"ENV | POOL | APPS "}
for _, env := range envs {
pools, err := configStore.ListPools(env)
if err != nil {
log.Fatalf("ERROR: cannot list pools: %s", err)
return
}
if len(pools) == 0 {
columns = append(columns, strings.Join([]string{
env,
"",
""}, " | "))
continue
}
for _, pool := range pools {
assigments, err := configStore.ListAssignments(env, pool)
if err != nil {
log.Fatalf("ERROR: cannot list pool assignments: %s", err)
}
columns = append(columns, strings.Join([]string{
env,
pool,
strings.Join(assigments, ",")}, " | "))
}
}
output := columnize.SimpleFormat(columns)
log.Println(output)
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:46,代码来源:galaxy.go
示例4: appBackup
// Backup app config to a file or STDOUT
func appBackup(c *cli.Context) {
initStore(c)
env := utils.GalaxyEnv(c)
if env == "" {
log.Fatal("ERROR: env is required. Pass --env or set GALAXY_ENV")
}
backup := &backupData{
Time: time.Now(),
}
toBackup := c.Args()
if len(toBackup) == 0 {
appList, err := configStore.ListApps(env)
if err != nil {
log.Fatalf("ERROR: %s\n", err)
}
for _, app := range appList {
toBackup = append(toBackup, app.Name())
}
}
errCount := 0
for _, app := range toBackup {
data, err := getAppBackup(app, env)
if err != nil {
// log errors and continue
log.Errorf("ERROR: %s [%s]", err, app)
errCount++
continue
}
backup.Apps = append(backup.Apps, data)
}
if errCount > 0 {
fmt.Printf("WARNING: backup completed with %d errors\n", errCount)
defer os.Exit(errCount)
}
j, err := json.MarshalIndent(backup, "", " ")
if err != nil {
log.Fatal(err)
}
fileName := c.String("file")
if fileName != "" {
if err := ioutil.WriteFile(fileName, j, 0666); err != nil {
log.Fatal(err)
}
return
}
os.Stdout.Write(j)
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:58,代码来源:backup.go
示例5: pgPsql
func pgPsql(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
app := ensureAppParam(c, "pg:psql")
appCfg, err := configStore.GetApp(app, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: Unable to run command: %s.", err)
return
}
database_url := appCfg.Env()["DATABASE_URL"]
if database_url == "" {
log.Printf("No DATABASE_URL configured. Set one with config:set first.")
return
}
if !strings.HasPrefix(database_url, "postgres://") {
log.Printf("DATABASE_URL is not a postgres database.")
return
}
cmd := exec.Command("psql", database_url)
cmd.Stdin = os.Stdin
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
// Ignore SIGINT while the process is running
ch := make(chan os.Signal, 1)
signal.Notify(ch, os.Interrupt)
defer func() {
signal.Stop(ch)
close(ch)
}()
go func() {
for {
_, ok := <-ch
if !ok {
break
}
}
}()
err = cmd.Start()
if err != nil {
log.Fatal(err)
}
err = cmd.Wait()
if err != nil {
fmt.Printf("Command finished with error: %v\n", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:56,代码来源:galaxy.go
示例6: appRestart
func appRestart(c *cli.Context) {
initStore(c)
app := ensureAppParam(c, "app:restart")
err := commander.AppRestart(configStore, app, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:10,代码来源:galaxy.go
示例7: appDelete
func appDelete(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
app := ensureAppParam(c, "app:delete")
err := commander.AppDelete(configStore, app, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:11,代码来源:galaxy.go
示例8: configList
func configList(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
app := ensureAppParam(c, "config")
err := commander.ConfigList(configStore, app, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: Unable to list config: %s.", err)
return
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:11,代码来源:galaxy.go
示例9: configUnset
func configUnset(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
app := ensureAppParam(c, "config:unset")
err := commander.ConfigUnset(configStore, app, utils.GalaxyEnv(c), c.Args().Tail())
if err != nil {
log.Fatalf("ERROR: Unable to unset config: %s.", err)
return
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:11,代码来源:galaxy.go
示例10: poolAssign
func poolAssign(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
initStore(c)
app := ensureAppParam(c, "pool:assign")
err := commander.AppAssign(configStore, app, utils.GalaxyEnv(c), utils.GalaxyPool(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:12,代码来源:galaxy.go
示例11: appShell
func appShell(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
initRuntime(c)
app := ensureAppParam(c, "app:shell")
err := commander.AppShell(configStore, serviceRuntime, app,
utils.GalaxyEnv(c), utils.GalaxyPool(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:13,代码来源:galaxy.go
示例12: appCreate
func appCreate(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
app := c.Args().First()
if app == "" {
cli.ShowCommandHelp(c, "app:create")
log.Fatal("ERROR: app name missing")
}
err := commander.AppCreate(configStore, app, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:15,代码来源:galaxy.go
示例13: stackDeletePool
func stackDeletePool(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
if c.String("region") != "" {
stack.Region = c.String("region")
}
baseStack := getBase(c)
stackName := fmt.Sprintf("%s-%s-%s", baseStack,
utils.GalaxyEnv(c),
utils.GalaxyPool(c))
waitAndDelete(stackName)
}
开发者ID:zombor,项目名称:galaxy,代码行数:16,代码来源:stacks.go
示例14: poolCreate
func poolCreate(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
initStore(c)
created, err := configStore.CreatePool(utils.GalaxyPool(c), utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: Could not create pool: %s", err)
return
}
if created {
log.Printf("Pool %s created\n", utils.GalaxyPool(c))
} else {
log.Printf("Pool %s already exists\n", utils.GalaxyPool(c))
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:16,代码来源:galaxy.go
示例15: poolUnassign
func poolUnassign(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
initStore(c)
app := c.Args().First()
if app == "" {
cli.ShowCommandHelp(c, "pool:assign")
log.Fatal("ERROR: app name missing")
}
err := commander.AppUnassign(configStore, app, utils.GalaxyEnv(c), utils.GalaxyPool(c))
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:16,代码来源:galaxy.go
示例16: poolDelete
func poolDelete(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
initStore(c)
empty, err := configStore.DeletePool(utils.GalaxyPool(c), utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: Could not delete pool: %s", err)
return
}
if empty {
log.Printf("Pool %s deleted\n", utils.GalaxyPool(c))
} else {
log.Printf("Pool %s has apps assigned. Unassign them first.\n", utils.GalaxyPool(c))
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:17,代码来源:galaxy.go
示例17: appRun
func appRun(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
initRuntime(c)
app := ensureAppParam(c, "app:run")
if len(c.Args()) < 2 {
log.Fatalf("ERROR: Missing command to run.")
return
}
err := commander.AppRun(configStore, serviceRuntime, app, utils.GalaxyEnv(c), c.Args()[1:])
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:17,代码来源:galaxy.go
示例18: ensureAppParam
func ensureAppParam(c *cli.Context, command string) string {
app := c.Args().First()
if app == "" {
cli.ShowCommandHelp(c, command)
log.Fatal("ERROR: app name missing")
}
exists, err := appExists(app, utils.GalaxyEnv(c))
if err != nil {
log.Fatalf("ERROR: can't deteremine if %s exists: %s", app, err)
}
if !exists {
log.Fatalf("ERROR: %s does not exist. Create it first.", app)
}
return app
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:18,代码来源:galaxy.go
示例19: appDeploy
func appDeploy(c *cli.Context) {
ensureEnvArg(c)
initStore(c)
initRuntime(c)
app := ensureAppParam(c, "app:deploy")
version := ""
if len(c.Args().Tail()) == 1 {
version = c.Args().Tail()[0]
}
if version == "" {
log.Println("ERROR: version missing")
cli.ShowCommandHelp(c, "app:deploy")
return
}
err := commander.AppDeploy(configStore, serviceRuntime, app, utils.GalaxyEnv(c), version)
if err != nil {
log.Fatalf("ERROR: %s", err)
}
}
开发者ID:sguzwf,项目名称:galaxy,代码行数:23,代码来源:galaxy.go
示例20: stackUpdatePool
// Update an existing Pool Stack
func stackUpdatePool(c *cli.Context) {
ensureEnvArg(c)
ensurePoolArg(c)
if c.String("region") != "" {
stack.Region = c.String("region")
}
poolName := utils.GalaxyPool(c)
baseStack := getBase(c)
poolEnv := utils.GalaxyEnv(c)
stackName := fmt.Sprintf("%s-%s-%s", baseStack, poolEnv, poolName)
pool, err := stack.GetPool(stackName)
if err != nil {
log.Fatal(err)
}
options := make(map[string]string)
if policy := c.String("policy"); policy != "" {
policyJSON, err := jsonFromArg(policy)
if err != nil {
log.Fatal("policy error:", err)
}
options["StackPolicyDuringUpdateBody"] = string(policyJSON)
}
resources := sharedResources(c, baseStack)
asg := pool.ASG()
if asg == nil {
log.Fatal("missing ASG")
}
if c.Int("desired-size") > 0 {
asg.Properties.DesiredCapacity = c.Int("desired-size")
}
if c.Int("min-size") > 0 {
asg.Properties.MinSize = c.Int("min-size")
}
if c.Int("max-size") > 0 {
asg.Properties.MaxSize = c.Int("max-size")
}
if c.Bool("auto-update") {
// note that the max pause is only PT5M30S
asg.SetASGUpdatePolicy(c.Int("update-min"), c.Int("update-batch"), c.Duration("update-pause"))
}
numZones := c.Int("availability-zones")
if numZones == 0 {
numZones = len(asg.Properties.VPCZoneIdentifier)
}
// start with the current settings
subnetIDs := []string{}
azIDs := []string{}
// only update the subnets/AZs if we changed the count
if len(asg.Properties.VPCZoneIdentifier) != numZones {
subnets := resources.Subnets
if numZones <= len(subnets) {
subnets = subnets[:numZones]
} else {
log.Fatal("ERROR: cannot run in %d zones, only %d available.", numZones, len(subnets))
}
for _, sn := range subnets {
subnetIDs = append(subnetIDs, sn.ID)
azIDs = append(azIDs, sn.AvailabilityZone)
}
asg.Properties.VPCZoneIdentifier = subnetIDs
asg.Properties.AvailabilityZones = azIDs
}
elb := pool.ELB()
sslCert := ""
if cert := c.String("ssl-cert"); cert != "" {
sslCert = resources.ServerCerts[cert]
if sslCert == "" {
log.Fatalf("Could not find certificate '%s'", cert)
}
}
httpPort := c.Int("http-port")
if (sslCert != "" || httpPort > 0) && elb == nil {
log.Fatal("ERROR: Pool does not have an ELB")
}
// we can set the default now that we've verified that elb can be nil
if httpPort == 0 {
httpPort = 80
//.........这里部分代码省略.........
开发者ID:zombor,项目名称:galaxy,代码行数:101,代码来源:stacks.go
注:本文中的github.com/litl/galaxy/utils.GalaxyEnv函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论