Esempio n. 1
0
func rackClient(c *cli.Context) *client.Client {
	host, password, err := currentLogin()

	if err != nil {
		stdcli.Error(err)
		return nil
	}

	return client.New(host, password, c.App.Version)
}
Esempio n. 2
0
func testLogin(host, password, version string) (err error) {
	cl := client.New(host, password, version)

	if cl == nil {
		return
	}

	_, err = cl.GetApps()

	if err != nil {
		return
	}

	return nil
}
Esempio n. 3
0
File: main.go Progetto: convox/rack
func main() {
	app := stdcli.New()
	app.Version = Version
	app.Usage = "command-line application management"

	err := app.Run(os.Args)

	if err != nil {
		if err.Error() == "Token expired" {
			email, err := currentId()
			if err != nil {
				email = promptForUsername()
			} else {
				_, err := mail.ParseAddress(email)
				if err != nil {
					email = promptForUsername()
				}
			}

			pw := promptForPassword()
			host, _ := currentHost()
			cl := client.New(host, "", "")

			token, err := cl.RegenerateToken(email, pw)

			if err == nil {
				err = addLogin(host, token)
				if err != nil {
					stdcli.Error(err)
				}
				err = app.Run(os.Args)
				if err != nil {
					stdcli.Error(err)
					os.Exit(1)
				}
			} else {
				stdcli.Error(err)
				os.Exit(1)
			}
		}
		os.Exit(1)
	}
}
Esempio n. 4
0
File: login.go Progetto: jbuck/rack
func cmdLogin(c *cli.Context) {
	if len(c.Args()) != 1 {
		stdcli.Usage(c, "login")
	}

	host := c.Args()[0]
	u, err := url.Parse(host)

	if err != nil {
		stdcli.Error(err)
		return
	}

	if u.Host != "" {
		host = u.Host
	}

	password := c.String("password")

	if password == "" {
		fmt.Print("Password: "******"invalid login"))
		return
	}

	err = addLogin(host, password)

	if err != nil {
		stdcli.Error(err)
		return
	}

	err = switchHost(host)

	if err != nil {
		stdcli.Error(err)
		return
	}

	fmt.Println("Logged in successfully.")
}
Esempio n. 5
0
	"os"
	"os/exec"
	"strings"

	"github.com/convox/rack/api/manifest"
	"github.com/convox/rack/client"
)

var (
	manifestPath    string
	app             string
	cache           = true
	registryAddress string
	buildId         string
	repository      string
	rackClient      = client.New(os.Getenv("RACK_HOST"), os.Getenv("RACK_PASSWORD"), "build")
)

func init() {
	app = os.Getenv("APP")
	buildId = os.Getenv("BUILD")
	registryAddress = os.Getenv("REGISTRY_ADDRESS")
	repository = os.Getenv("REPOSITORY")

	manifestPath = os.Getenv("MANIFEST_PATH")
	if manifestPath == "" {
		manifestPath = "docker-compose.yml"
	}

	if os.Getenv("NO_CACHE") != "" {
		cache = false