From 8de0c69ed9ba6ace3191f3983728ea45117e6f31 Mon Sep 17 00:00:00 2001 From: Julien Castets Date: Fri, 18 Aug 2023 09:25:13 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"orga=20list:=20display=20=E2=9C=93=20?= =?UTF-8?q?for=20the=20current=20organization"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit fb6bd49d5fdc7021b912988d028de9f4c4a8ffec. --- pkg/koyeb/context.go | 28 ++++++++++++---------------- pkg/koyeb/organizations_list.go | 31 ++++++++++++------------------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/pkg/koyeb/context.go b/pkg/koyeb/context.go index 339143c9..5b86b32c 100644 --- a/pkg/koyeb/context.go +++ b/pkg/koyeb/context.go @@ -16,7 +16,6 @@ const ( ctx_logs_client ctx_mapper ctx_renderer - ctx_organization ) // SetupCLIContext is called by the root command to setup the context for all subcommands. @@ -38,7 +37,6 @@ func SetupCLIContext(cmd *cobra.Command, organization string) error { ctx = context.WithValue(ctx, ctx_logs_client, logsApiClient) ctx = context.WithValue(ctx, ctx_mapper, idmapper.NewMapper(ctx, apiClient)) ctx = context.WithValue(ctx, ctx_renderer, renderer.NewRenderer(outputFormat)) - ctx = context.WithValue(ctx, ctx_organization, organization) cmd.SetContext(ctx) if organization != "" { @@ -53,25 +51,23 @@ func SetupCLIContext(cmd *cobra.Command, organization string) error { } type CLIContext struct { - Context context.Context - Client *koyeb.APIClient - LogsClient *LogsAPIClient - Mapper *idmapper.Mapper - Token string - Renderer renderer.Renderer - Organization string + Context context.Context + Client *koyeb.APIClient + LogsClient *LogsAPIClient + Mapper *idmapper.Mapper + Token string + Renderer renderer.Renderer } // GetCLIContext transforms the untyped context passed to cobra commands into a CLIContext. func GetCLIContext(ctx context.Context) *CLIContext { return &CLIContext{ - Context: ctx, - Client: ctx.Value(ctx_client).(*koyeb.APIClient), - LogsClient: ctx.Value(ctx_logs_client).(*LogsAPIClient), - Mapper: ctx.Value(ctx_mapper).(*idmapper.Mapper), - Token: ctx.Value(koyeb.ContextAccessToken).(string), - Renderer: ctx.Value(ctx_renderer).(renderer.Renderer), - Organization: ctx.Value(ctx_organization).(string), + Context: ctx, + Client: ctx.Value(ctx_client).(*koyeb.APIClient), + LogsClient: ctx.Value(ctx_logs_client).(*LogsAPIClient), + Mapper: ctx.Value(ctx_mapper).(*idmapper.Mapper), + Token: ctx.Value(koyeb.ContextAccessToken).(string), + Renderer: ctx.Value(ctx_renderer).(renderer.Renderer), } } diff --git a/pkg/koyeb/organizations_list.go b/pkg/koyeb/organizations_list.go index 9014f6ae..32f0e3c1 100644 --- a/pkg/koyeb/organizations_list.go +++ b/pkg/koyeb/organizations_list.go @@ -48,24 +48,22 @@ func (h *OrganizationHandler) List(ctx *CLIContext, cmd *cobra.Command, args []s } full := GetBoolFlags(cmd, "full") - reply := NewListOragnizationsReply(ctx.Mapper, &koyeb.ListOrganizationMembersReply{Members: list}, full, ctx.Organization) + reply := NewListOragnizationsReply(ctx.Mapper, &koyeb.ListOrganizationMembersReply{Members: list}, full) ctx.Renderer.Render(reply) return nil } type ListOrganizationsReply struct { - mapper *idmapper.Mapper - value *koyeb.ListOrganizationMembersReply - full bool - currentOrganization string + mapper *idmapper.Mapper + value *koyeb.ListOrganizationMembersReply + full bool } -func NewListOragnizationsReply(mapper *idmapper.Mapper, value *koyeb.ListOrganizationMembersReply, full bool, currentOrganization string) *ListOrganizationsReply { +func NewListOragnizationsReply(mapper *idmapper.Mapper, value *koyeb.ListOrganizationMembersReply, full bool) *ListOrganizationsReply { return &ListOrganizationsReply{ - mapper: mapper, - value: value, - full: full, - currentOrganization: currentOrganization, + mapper: mapper, + value: value, + full: full, } } @@ -78,7 +76,7 @@ func (r *ListOrganizationsReply) MarshalBinary() ([]byte, error) { } func (r *ListOrganizationsReply) Headers() []string { - return []string{"id", "name", "plan", "current"} + return []string{"id", "name", "plan"} } func (r *ListOrganizationsReply) Fields() []map[string]string { @@ -86,15 +84,10 @@ func (r *ListOrganizationsReply) Fields() []map[string]string { resp := make([]map[string]string, 0, len(items)) for _, member := range items { - current := "" - if member.Organization.GetId() == r.currentOrganization { - current = "✓" - } fields := map[string]string{ - "id": renderer.FormatID(member.Organization.GetId(), r.full), - "name": member.Organization.GetName(), - "plan": string(member.Organization.GetPlan()), - "current": current, + "id": renderer.FormatID(member.Organization.GetId(), r.full), + "name": member.Organization.GetName(), + "plan": string(member.Organization.GetPlan()), } resp = append(resp, fields) }