Skip to content

Commit

Permalink
Initialize logs API client with organization token, fix #120
Browse files Browse the repository at this point in the history
  • Loading branch information
brmzkw committed Sep 11, 2023
1 parent bee6616 commit 643e880
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions pkg/koyeb/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ func SetupCLIContext(cmd *cobra.Command, organization string) error {
return err
}

logsApiClient, err := NewLogsAPIClient(apiurl, token)
if err != nil {
return err
}

ctx := cmd.Context()
ctx = context.WithValue(ctx, koyeb.ContextAccessToken, token)

Expand All @@ -41,10 +36,18 @@ func SetupCLIContext(cmd *cobra.Command, organization string) error {
return err
}
ctx = context.WithValue(ctx, koyeb.ContextAccessToken, token)
// Update command context with the organization token. This is required
// because the idmapper initialization below will use the token from the
// context.
cmd.SetContext(ctx)
}

ctx = context.WithValue(ctx, ctx_client, apiClient)

logsApiClient, err := NewLogsAPIClient(apiurl, ctx.Value(koyeb.ContextAccessToken).(string))
if err != nil {
return err
}
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))
Expand Down

0 comments on commit 643e880

Please sign in to comment.