Explorar el Código

Merge pull request #170 from porter-dev/beta.3.provisioning-integration

use prod as host and set project by default
abelanger5 hace 5 años
padre
commit
1debea278f
Se han modificado 2 ficheros con 14 adiciones y 1 borrados
  1. 8 1
      cli/cmd/auth.go
  2. 6 0
      cli/cmd/root.go

+ 8 - 1
cli/cmd/auth.go

@@ -95,7 +95,7 @@ func login() error {
 		return err
 	}
 
-	_, err = client.Login(context.Background(), &api.LoginRequest{
+	_user, err := client.Login(context.Background(), &api.LoginRequest{
 		Email:    username,
 		Password: pw,
 	})
@@ -106,6 +106,13 @@ func login() error {
 
 	color.New(color.FgGreen).Println("Successfully logged in!")
 
+	// get a list of projects, and set the current project
+	projects, err := client.ListUserProjects(context.Background(), _user.ID)
+
+	if len(projects) > 0 {
+		setProject(projects[0].ID)
+	}
+
 	return nil
 }
 

+ 6 - 0
cli/cmd/root.go

@@ -63,4 +63,10 @@ func Setup() {
 			os.Exit(1)
 		}
 	}
+
+	// create defaults if configs are not set
+	if viper.GetString("host") == "" {
+		viper.Set("host", "https://dashboard.getporter.dev")
+		viper.WriteConfig()
+	}
 }