Skip to content

Commit

Permalink
fix removal of org ID since it's now infered from session token
Browse files Browse the repository at this point in the history
  • Loading branch information
aybabtme committed Nov 29, 2024
1 parent d87084e commit 7bc25cc
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 17 deletions.
16 changes: 7 additions & 9 deletions cmd/humanlog/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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
}
Expand All @@ -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 {
Expand Down Expand Up @@ -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()
Expand Down
5 changes: 3 additions & 2 deletions cmd/humanlog/localhost.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down Expand Up @@ -78,7 +79,7 @@ func startLocalhostServer(
}, nil
}

features := featurev1connect.NewFeatureServiceClient(apiHttpClient, apiClientOpts...)
features := featurev1connect.NewFeatureServiceClient(apiHttpClient, apiURL, apiClientOpts...)

storage, err := localstorage.Open(
ctx,
Expand Down
4 changes: 2 additions & 2 deletions cmd/humanlog/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,15 @@ 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))...,
)}

machineID = uint64(*state.MachineID)
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 {
Expand Down
1 change: 0 additions & 1 deletion cmd/humanlog/organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 2 additions & 3 deletions pkg/tui/accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7bc25cc

Please sign in to comment.