Пример #1
0
func SetScalingoEnv(herokuAppName, scalingoAppName string) error {
	var variables scalingo.Variables

	env, err := getHerokuEnv(herokuAppName)
	if err != nil {
		return errgo.Mask(err)
	}

	for k := range env {
		if strings.TrimSpace(env[k]) == "" {

			io.Warnf("%s has an empty value and couldn't be set\n", k)
		} else {
			variables = append(variables, &scalingo.Variable{
				Name:  k,
				Value: env[k],
			})
		}
	}

	_, _, err = scalingo.VariableMultipleSet(scalingoAppName, variables)
	if err != nil {
		return errgo.Mask(err)
	}

	for _, v := range variables {
		io.Printf("%s has been set to %s\n", v.Name, v.Value)
	}

	return nil
}
Пример #2
0
func Handle() {
	signals := make(chan os.Signal, 1)
	signal.Notify(signals, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
	for sig := range signals {
		if CatchQuitSignals {
			io.Warnf("%v catched, aborting…\n", sig)
			os.Exit(-127)
		}
	}
}
Пример #3
0
func Create(appName string) (*scalingo.App, error) {
	for len(appName) < 6 || len(appName) > 32 {
		fmt.Println("Your app '" + appName + "' should contain between 6 and 32 characters")
		appName = getNewAppName()
	}

	app, err := scalingo.AppsCreate(appName)
	if err != nil {
		if strings.Contains(err.Error(), "is already taken") {
			io.Warnf("The name '%s' is already taken.\n\n", appName)
			return Create(getNewAppName())
		}
		return nil, errgo.Mask(err)
	}

	return app, nil
}