本文整理汇总了Golang中github.com/litl/galaxy/utils.GalaxyEnv函数的典型用法代码示例。如果您正苦于以下问题:Golang GalaxyEnv函数的具体用法?Golang GalaxyEnv怎么用?Golang GalaxyEnv使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GalaxyEnv函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
}
示例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)
}
}
示例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)
}
}
示例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
}
}
示例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
}
}
示例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)
}
}
示例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)
}
}
示例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)
}
}
示例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)
}
示例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))
}
}
示例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)
}
}