From 1005c6e794f201188473af060e5842c3c86e6848 Mon Sep 17 00:00:00 2001 From: Antoine Grondin Date: Fri, 29 Nov 2024 14:40:11 +0900 Subject: [PATCH] fix removal of org ID since it's now infered from session token --- cmd/humanlog/environment.go | 16 +++++++--------- cmd/humanlog/localhost.go | 5 +++-- cmd/humanlog/main.go | 4 ++-- cmd/humanlog/organization.go | 1 - pkg/tui/accounts.go | 5 ++--- 5 files changed, 14 insertions(+), 17 deletions(-) diff --git a/cmd/humanlog/environment.go b/cmd/humanlog/environment.go index ff5b5af..a9d0ae7 100644 --- a/cmd/humanlog/environment.go +++ b/cmd/humanlog/environment.go @@ -99,7 +99,7 @@ func environmentCmd( auth.Interceptors(ll, tokenSource)..., ) orgClient := organizationv1connect.NewOrganizationServiceClient(httpClient, apiURL, clOpts) - iter := ListEnvironments(ctx, orgID, orgClient) + iter := ListEnvironments(ctx, orgClient) a, ok, err := iterapi.Find(iter, func(el *organizationv1.ListEnvironmentResponse_ListItem) bool { return el.Environment.Id == environmentID }) @@ -126,7 +126,7 @@ func environmentCmd( apiURL := getAPIUrl(cctx) httpClient := getHTTPClient(cctx, apiURL) - orgID, err := ensureOrgSelected(ctx, ll, cctx, state, tokenSource, apiURL, httpClient) + _, err := ensureOrgSelected(ctx, ll, cctx, state, tokenSource, apiURL, httpClient) if err != nil { return err } @@ -136,9 +136,7 @@ func environmentCmd( ) orgClient := organizationv1connect.NewOrganizationServiceClient(httpClient, apiURL, clOpts) - res, err := orgClient.CreateEnvironment(ctx, connect.NewRequest(&organizationv1.CreateEnvironmentRequest{ - OrganizationId: orgID, - })) + res, err := orgClient.CreateEnvironment(ctx, connect.NewRequest(&organizationv1.CreateEnvironmentRequest{})) if err != nil { return err } @@ -165,7 +163,7 @@ func environmentCmd( return cli.ShowSubcommandHelp(cctx) } - orgID, err := ensureOrgSelected(ctx, ll, cctx, state, tokenSource, apiURL, httpClient) + _, err := ensureOrgSelected(ctx, ll, cctx, state, tokenSource, apiURL, httpClient) if err != nil { return err } @@ -175,7 +173,7 @@ func environmentCmd( ) orgClient := organizationv1connect.NewOrganizationServiceClient(httpClient, apiURL, clOpts) - el, ok, err := iterapi.Find(ListEnvironments(ctx, orgID, orgClient), func(el *organizationv1.ListEnvironmentResponse_ListItem) bool { + el, ok, err := iterapi.Find(ListEnvironments(ctx, orgClient), func(el *organizationv1.ListEnvironmentResponse_ListItem) bool { return el.Environment.Name == environmentName }) if err != nil { @@ -204,12 +202,12 @@ func environmentCmd( ) orgClient := organizationv1connect.NewOrganizationServiceClient(httpClient, apiURL, clOpts) - orgID, err := ensureOrgSelected(ctx, ll, cctx, state, tokenSource, apiURL, httpClient) + _, err := ensureOrgSelected(ctx, ll, cctx, state, tokenSource, apiURL, httpClient) if err != nil { return err } - iter := ListEnvironments(ctx, orgID, orgClient) + iter := ListEnvironments(ctx, orgClient) for iter.Next() { li := iter.Current() diff --git a/cmd/humanlog/localhost.go b/cmd/humanlog/localhost.go index 2535344..57507cf 100644 --- a/cmd/humanlog/localhost.go +++ b/cmd/humanlog/localhost.go @@ -46,7 +46,8 @@ func startLocalhostServer( port int, localhostHttpClient *http.Client, apiHttpClient *http.Client, - apiClientOpts []connect.Option, + apiURL string, + apiClientOpts []connect.ClientOption, ownVersion *typesv1.Version, ) (localsink sink.Sink, done func(context.Context) error, err error) { @@ -78,7 +79,7 @@ func startLocalhostServer( }, nil } - features := featurev1connect.NewFeatureServiceClient(apiHttpClient, apiClientOpts...) + features := featurev1connect.NewFeatureServiceClient(apiHttpClient, apiURL, apiClientOpts...) storage, err := localstorage.Open( ctx, diff --git a/cmd/humanlog/main.go b/cmd/humanlog/main.go index 8e37c30..fc7670e 100644 --- a/cmd/humanlog/main.go +++ b/cmd/humanlog/main.go @@ -533,7 +533,7 @@ func newApp() *cli.App { return fmt.Errorf("this feature requires a valid machine ID, which requires an environment. failed to login: %v", err) } } - clOpts := []connect.Option{connect.WithInterceptors( + clOpts := []connect.ClientOption{connect.WithInterceptors( auth.Interceptors(ll, getTokenSource(cctx))..., )} @@ -541,7 +541,7 @@ func newApp() *cli.App { localhostSink, done, err := startLocalhostServer( ctx, ll, cfg, state, machineID, localhostCfg.Port, getLocalhostHTTPClient(cctx), - getHTTPClient(cctx, getAPIUrl(cctx)), clOpts, + getHTTPClient(cctx, getAPIUrl(cctx)), getAPIUrl(cctx), clOpts, version, ) if err != nil { diff --git a/cmd/humanlog/organization.go b/cmd/humanlog/organization.go index 71468b7..870999d 100644 --- a/cmd/humanlog/organization.go +++ b/cmd/humanlog/organization.go @@ -274,7 +274,6 @@ func organizationCmd( Action: func(cctx *cli.Context) error { ctx := getCtx(cctx) ll := getLogger(cctx) - state := getState(cctx) tokenSource := getTokenSource(cctx) apiURL := getAPIUrl(cctx) httpClient := getHTTPClient(cctx, apiURL) diff --git a/pkg/tui/accounts.go b/pkg/tui/accounts.go index a77412b..bc5bd01 100644 --- a/pkg/tui/accounts.go +++ b/pkg/tui/accounts.go @@ -165,9 +165,8 @@ func listEnvironmentsCmd( return func() tea.Msg { log.Printf("environment: listEnvironments") res, err := organizationClient.ListEnvironment(ctx, connect.NewRequest(&organizationv1.ListEnvironmentRequest{ - Cursor: nil, - Limit: 10, - OrganizationId: *state.CurrentOrgID, + Cursor: nil, + Limit: 10, })) if err != nil { cerr := new(connect.Error)