فهرست منبع

patching clusterID

Stefan McShane 2 سال پیش
والد
کامیت
d49bb8abb5
3فایلهای تغییر یافته به همراه11 افزوده شده و 10 حذف شده
  1. 7 6
      cli/cmd/commands/auth.go
  2. 1 1
      cli/cmd/commands/project.go
  3. 3 3
      cli/cmd/config/update.go

+ 7 - 6
cli/cmd/commands/auth.go

@@ -149,7 +149,7 @@ func login(ctx context.Context, cliConf config.CLIConfig, currentProfile string)
 		}
 
 		_, _ = color.New(color.FgGreen).Println("Successfully logged in!")
-		return setProjectForUser(ctx, client, cliConf, currentProfile)
+		return setProjectForUser(ctx, client, currentProfile)
 
 	}
 
@@ -171,10 +171,11 @@ func login(ctx context.Context, cliConf config.CLIConfig, currentProfile string)
 	// if project ID does not exist for the token, this is a user-issued CLI token, so the project
 	// ID should be queried
 	if !exists {
-		err = setProjectForUser(ctx, client, cliConf, currentProfile)
+		err = setProjectForUser(ctx, client, currentProfile)
 		if err != nil {
 			return err
 		}
+
 	} else {
 		// if the project ID does exist for the token, this is a project-issued token, and
 		// the project should be set automatically
@@ -183,7 +184,7 @@ func login(ctx context.Context, cliConf config.CLIConfig, currentProfile string)
 			return err
 		}
 
-		err = setProjectCluster(ctx, client, cliConf, currentProfile, projID)
+		err = setProjectCluster(ctx, client, currentProfile, projID)
 		if err != nil {
 			return err
 		}
@@ -193,7 +194,7 @@ func login(ctx context.Context, cliConf config.CLIConfig, currentProfile string)
 	return nil
 }
 
-func setProjectForUser(ctx context.Context, client api.Client, cliConfig config.CLIConfig, currentProfile string) error {
+func setProjectForUser(ctx context.Context, client api.Client, currentProfile string) error {
 	// get a list of projects, and set the current project
 	resp, err := client.ListUserProjects(ctx)
 	if err != nil {
@@ -205,7 +206,7 @@ func setProjectForUser(ctx context.Context, client api.Client, cliConfig config.
 	if len(projects) > 0 {
 		config.SetProject(projects[0].ID, currentProfile) //nolint:errcheck,gosec // do not want to change logic of CLI. New linter error
 
-		err = setProjectCluster(ctx, client, cliConfig, currentProfile, projects[0].ID)
+		err = setProjectCluster(ctx, client, currentProfile, projects[0].ID)
 		if err != nil {
 			return err
 		}
@@ -253,7 +254,7 @@ func loginManual(ctx context.Context, cliConf config.CLIConfig, client api.Clien
 	if len(projects) > 0 {
 		config.SetProject(projects[0].ID, currentProfile) //nolint:errcheck,gosec // do not want to change logic of CLI. New linter error
 
-		err = setProjectCluster(ctx, client, cliConf, currentProfile, projects[0].ID)
+		err = setProjectCluster(ctx, client, currentProfile, projects[0].ID)
 		if err != nil {
 			return err
 		}

+ 1 - 1
cli/cmd/commands/project.go

@@ -135,7 +135,7 @@ func deleteProject(ctx context.Context, _ *types.GetAuthenticatedUserResponse, c
 	return nil
 }
 
-func setProjectCluster(ctx context.Context, client api.Client, cliConf config.CLIConfig, currentProfile string, projectID uint) error {
+func setProjectCluster(ctx context.Context, client api.Client, currentProfile string, projectID uint) error {
 	resp, err := client.ListProjectClusters(ctx, projectID)
 	if err != nil {
 		return err

+ 3 - 3
cli/cmd/config/update.go

@@ -32,20 +32,20 @@ func SetHost(host string, currentProfile string) error {
 
 	color.New(color.FgGreen).Printf("Set the current host as %s\n", host) //nolint:errcheck,gosec
 
-	return updateValuesForSelectedProfile(currentProfile, porterConfigFilePath, withHost(host), withClusterID(0), withProjectID(0))
+	return updateValuesForSelectedProfile(currentProfile, porterConfigFilePath, withHost(host))
 }
 
 // SetProject sets a project for all API commands
 func SetProject(projectID uint, currentProfile string) error {
 	color.New(color.FgGreen).Printf("Set the current project as %d\n", projectID) //nolint:errcheck,gosec
 
-	return updateValuesForSelectedProfile(currentProfile, porterConfigFilePath, withProjectID(0))
+	return updateValuesForSelectedProfile(currentProfile, porterConfigFilePath, withProjectID(projectID))
 }
 
 // SetCluster sets the cluster in the current profile. All further actions will be targeted at this cluster
 func SetCluster(clusterID uint, currentProfile string) error {
 	color.New(color.FgGreen).Printf("Set the current cluster as %d\n", clusterID) //nolint:errcheck,gosec
-	return updateValuesForSelectedProfile(currentProfile, porterConfigFilePath, withClusterID(0), withKubeconfig(""))
+	return updateValuesForSelectedProfile(currentProfile, porterConfigFilePath, withClusterID(clusterID), withKubeconfig(""))
 }
 
 // SetToken sets the token in the current profile. All further actions will be authenticated with this token