Skip to content

Commit f7bdb1e

Browse files
bmsaadatclaude
andcommitted
Bump kernel-go-sdk v0.58.0 → v0.65.0; migrate pools + proxies to compile
Mechanical migration required by the SDK bump (no new features). The bump is needed for upcoming browser/acquire name+tags support, but v0.65.0 also ships unrelated breaking changes that the cmd packages must absorb to compile: - All list endpoints are now paginated. Update the List interface signatures and call sites for browser pools, proxies, credential providers, and extensions to take *ListParams and read OffsetPagination.Items. Because the pre-bump List returned the full unpaginated slice, these four commands gain --limit/--offset flags so they can page through results (matching the existing browsers/profiles/api-keys list convention) instead of silently truncating to the first page. - Browser pool update Size is now param.Opt[int64]. - Proxy config unions were renamed (ProxyNewParamsConfigDatacenterProxyConfig → ProxyNewParamsConfigDatacenter, OfProxyNewsConfig… → OfDatacenter, etc.). - The proxy API dropped `carrier` from both request (mobile create) and response configs, so the CLI no longer accepts --carrier or displays Carrier (mobile get/list now surface City/State instead). Mobile create also no longer supports zip/asn; passing them warns and they are ignored. The proxy command docs in README.md are trimmed to match. Tests updated to the new fake List signatures and config shapes, plus limit/offset forwarding tests for the proxy, extension, and credential-provider list commands. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 0757525 commit f7bdb1e

18 files changed

Lines changed: 262 additions & 102 deletions

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,10 +457,9 @@ Per-category updates are partial — only categories you name are changed; other
457457
- `--country <code>` - ISO 3166 country code or "EU" (location-based types)
458458
- `--city <name>` - City name (no spaces, e.g. sanfrancisco) (residential, mobile; requires `--country`)
459459
- `--state <code>` - Two-letter state code (residential, mobile)
460-
- `--zip <zip>` - US ZIP code (residential, mobile)
461-
- `--asn <asn>` - Autonomous system number (e.g., AS15169) (residential, mobile)
460+
- `--zip <zip>` - US ZIP code (residential)
461+
- `--asn <asn>` - Autonomous system number (e.g., AS15169) (residential)
462462
- `--os <os>` - Operating system: windows, macos, android (residential)
463-
- `--carrier <carrier>` - Mobile carrier (mobile)
464463
- `--host <host>` - Proxy host (custom; required)
465464
- `--port <port>` - Proxy port (custom; required)
466465
- `--username <username>` - Username for proxy authentication (custom)
@@ -781,8 +780,8 @@ kernel proxies create --type custom --host proxy.example.com --port 8080 --usern
781780
# Create a residential proxy with location and OS
782781
kernel proxies create --type residential --country US --city sanfrancisco --state CA --zip 94107 --asn AS15169 --os windows --name "SF Residential"
783782

784-
# Create a mobile proxy with carrier
785-
kernel proxies create --type mobile --country US --carrier verizon --name "US Mobile"
783+
# Create a mobile proxy
784+
kernel proxies create --type mobile --country US --city sanfrancisco --name "US Mobile"
786785

787786
# Get proxy details
788787
kernel proxies get prx_123

cmd/browser_pools.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import (
88
"github.com/kernel/cli/pkg/util"
99
"github.com/kernel/kernel-go-sdk"
1010
"github.com/kernel/kernel-go-sdk/option"
11+
"github.com/kernel/kernel-go-sdk/packages/pagination"
1112
"github.com/pterm/pterm"
1213
"github.com/spf13/cobra"
1314
)
1415

1516
// BrowserPoolsService defines the subset of the Kernel SDK browser pools client that we use.
1617
type BrowserPoolsService interface {
17-
List(ctx context.Context, opts ...option.RequestOption) (res *[]kernel.BrowserPool, err error)
18+
List(ctx context.Context, query kernel.BrowserPoolListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[kernel.BrowserPool], err error)
1819
New(ctx context.Context, body kernel.BrowserPoolNewParams, opts ...option.RequestOption) (res *kernel.BrowserPool, err error)
1920
Get(ctx context.Context, id string, opts ...option.RequestOption) (res *kernel.BrowserPool, err error)
2021
Update(ctx context.Context, id string, body kernel.BrowserPoolUpdateParams, opts ...option.RequestOption) (res *kernel.BrowserPool, err error)
@@ -29,6 +30,8 @@ type BrowserPoolsCmd struct {
2930
}
3031

3132
type BrowserPoolsListInput struct {
33+
Limit int
34+
Offset int
3235
Output string
3336
}
3437

@@ -37,20 +40,33 @@ func (c BrowserPoolsCmd) List(ctx context.Context, in BrowserPoolsListInput) err
3740
return err
3841
}
3942

40-
pools, err := c.client.List(ctx)
43+
params := kernel.BrowserPoolListParams{}
44+
if in.Limit > 0 {
45+
params.Limit = kernel.Int(int64(in.Limit))
46+
}
47+
if in.Offset > 0 {
48+
params.Offset = kernel.Int(int64(in.Offset))
49+
}
50+
51+
page, err := c.client.List(ctx, params)
4152
if err != nil {
4253
return util.CleanedUpSdkError{Err: err}
4354
}
4455

56+
var pools []kernel.BrowserPool
57+
if page != nil {
58+
pools = page.Items
59+
}
60+
4561
if in.Output == "json" {
46-
if pools == nil || len(*pools) == 0 {
62+
if len(pools) == 0 {
4763
fmt.Println("[]")
4864
return nil
4965
}
50-
return util.PrintPrettyJSONSlice(*pools)
66+
return util.PrintPrettyJSONSlice(pools)
5167
}
5268

53-
if pools == nil || len(*pools) == 0 {
69+
if len(pools) == 0 {
5470
pterm.Info.Println("No browser pools found")
5571
return nil
5672
}
@@ -59,7 +75,7 @@ func (c BrowserPoolsCmd) List(ctx context.Context, in BrowserPoolsListInput) err
5975
{"ID", "Name", "Available", "Acquired", "Created At", "Size"},
6076
}
6177

62-
for _, p := range *pools {
78+
for _, p := range pools {
6379
tableData = append(tableData, []string{
6480
p.ID,
6581
util.OrDash(p.Name),
@@ -250,7 +266,7 @@ func (c BrowserPoolsCmd) Update(ctx context.Context, in BrowserPoolsUpdateInput)
250266
params.Name = kernel.String(in.Name)
251267
}
252268
if in.Size > 0 {
253-
params.Size = in.Size
269+
params.Size = kernel.Int(in.Size)
254270
}
255271
if in.FillRate > 0 {
256272
params.FillRatePerMinute = kernel.Int(in.FillRate)
@@ -482,6 +498,8 @@ var browserPoolsFlushCmd = &cobra.Command{
482498

483499
func init() {
484500
addJSONOutputFlag(browserPoolsListCmd)
501+
browserPoolsListCmd.Flags().Int("limit", 0, "Maximum number of pools to return")
502+
browserPoolsListCmd.Flags().Int("offset", 0, "Number of pools to skip (for pagination)")
485503

486504
addJSONOutputFlag(browserPoolsCreateCmd)
487505
browserPoolsCreateCmd.Flags().String("name", "", "Optional unique name for the pool")
@@ -542,8 +560,10 @@ func init() {
542560
func runBrowserPoolsList(cmd *cobra.Command, args []string) error {
543561
client := getKernelClient(cmd)
544562
out, _ := cmd.Flags().GetString("output")
563+
limit, _ := cmd.Flags().GetInt("limit")
564+
offset, _ := cmd.Flags().GetInt("offset")
545565
c := BrowserPoolsCmd{client: &client.BrowserPools}
546-
return c.List(cmd.Context(), BrowserPoolsListInput{Output: out})
566+
return c.List(cmd.Context(), BrowserPoolsListInput{Limit: limit, Offset: offset, Output: out})
547567
}
548568

549569
func runBrowserPoolsCreate(cmd *cobra.Command, args []string) error {

cmd/credential_providers.go

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/kernel/cli/pkg/util"
99
"github.com/kernel/kernel-go-sdk"
1010
"github.com/kernel/kernel-go-sdk/option"
11+
"github.com/kernel/kernel-go-sdk/packages/pagination"
1112
"github.com/pterm/pterm"
1213
"github.com/spf13/cobra"
1314
)
@@ -17,7 +18,7 @@ type CredentialProvidersService interface {
1718
New(ctx context.Context, body kernel.CredentialProviderNewParams, opts ...option.RequestOption) (res *kernel.CredentialProvider, err error)
1819
Get(ctx context.Context, id string, opts ...option.RequestOption) (res *kernel.CredentialProvider, err error)
1920
Update(ctx context.Context, id string, body kernel.CredentialProviderUpdateParams, opts ...option.RequestOption) (res *kernel.CredentialProvider, err error)
20-
List(ctx context.Context, opts ...option.RequestOption) (res *[]kernel.CredentialProvider, err error)
21+
List(ctx context.Context, query kernel.CredentialProviderListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[kernel.CredentialProvider], err error)
2122
Delete(ctx context.Context, id string, opts ...option.RequestOption) (err error)
2223
Test(ctx context.Context, id string, opts ...option.RequestOption) (res *kernel.CredentialProviderTestResult, err error)
2324
ListItems(ctx context.Context, id string, opts ...option.RequestOption) (res *kernel.CredentialProviderListItemsResponse, err error)
@@ -29,6 +30,8 @@ type CredentialProvidersCmd struct {
2930
}
3031

3132
type CredentialProvidersListInput struct {
33+
Limit int
34+
Offset int
3235
Output string
3336
}
3437

@@ -75,26 +78,38 @@ func (c CredentialProvidersCmd) List(ctx context.Context, in CredentialProviders
7578
return err
7679
}
7780

78-
providers, err := c.providers.List(ctx)
81+
params := kernel.CredentialProviderListParams{}
82+
if in.Limit > 0 {
83+
params.Limit = kernel.Int(int64(in.Limit))
84+
}
85+
if in.Offset > 0 {
86+
params.Offset = kernel.Int(int64(in.Offset))
87+
}
88+
page, err := c.providers.List(ctx, params)
7989
if err != nil {
8090
return util.CleanedUpSdkError{Err: err}
8191
}
8292

93+
var providers []kernel.CredentialProvider
94+
if page != nil {
95+
providers = page.Items
96+
}
97+
8398
if in.Output == "json" {
84-
if providers == nil || len(*providers) == 0 {
99+
if len(providers) == 0 {
85100
fmt.Println("[]")
86101
return nil
87102
}
88-
return util.PrintPrettyJSONSlice(*providers)
103+
return util.PrintPrettyJSONSlice(providers)
89104
}
90105

91-
if providers == nil || len(*providers) == 0 {
106+
if len(providers) == 0 {
92107
pterm.Info.Println("No credential providers found")
93108
return nil
94109
}
95110

96111
tableData := pterm.TableData{{"ID", "Provider Type", "Enabled", "Priority", "Created At"}}
97-
for _, p := range *providers {
112+
for _, p := range providers {
98113
tableData = append(tableData, []string{
99114
p.ID,
100115
string(p.ProviderType),
@@ -425,6 +440,8 @@ func init() {
425440

426441
// List flags
427442
addJSONOutputFlag(credentialProvidersListCmd)
443+
credentialProvidersListCmd.Flags().Int("limit", 0, "Maximum number of credential providers to return")
444+
credentialProvidersListCmd.Flags().Int("offset", 0, "Number of credential providers to skip (for pagination)")
428445

429446
// Get flags
430447
addJSONOutputFlag(credentialProvidersGetCmd)
@@ -460,10 +477,14 @@ func init() {
460477
func runCredentialProvidersList(cmd *cobra.Command, args []string) error {
461478
client := getKernelClient(cmd)
462479
output, _ := cmd.Flags().GetString("output")
480+
limit, _ := cmd.Flags().GetInt("limit")
481+
offset, _ := cmd.Flags().GetInt("offset")
463482

464483
svc := client.CredentialProviders
465484
c := CredentialProvidersCmd{providers: &svc}
466485
return c.List(cmd.Context(), CredentialProvidersListInput{
486+
Limit: limit,
487+
Offset: offset,
467488
Output: output,
468489
})
469490
}

cmd/credential_providers_test.go

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package cmd
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/kernel/kernel-go-sdk"
8+
"github.com/kernel/kernel-go-sdk/option"
9+
"github.com/kernel/kernel-go-sdk/packages/pagination"
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
// FakeCredentialProvidersService is a configurable fake implementing CredentialProvidersService.
14+
type FakeCredentialProvidersService struct {
15+
ListFunc func(ctx context.Context, query kernel.CredentialProviderListParams, opts ...option.RequestOption) (*pagination.OffsetPagination[kernel.CredentialProvider], error)
16+
}
17+
18+
func (f *FakeCredentialProvidersService) New(ctx context.Context, body kernel.CredentialProviderNewParams, opts ...option.RequestOption) (*kernel.CredentialProvider, error) {
19+
return &kernel.CredentialProvider{}, nil
20+
}
21+
22+
func (f *FakeCredentialProvidersService) Get(ctx context.Context, id string, opts ...option.RequestOption) (*kernel.CredentialProvider, error) {
23+
return &kernel.CredentialProvider{}, nil
24+
}
25+
26+
func (f *FakeCredentialProvidersService) Update(ctx context.Context, id string, body kernel.CredentialProviderUpdateParams, opts ...option.RequestOption) (*kernel.CredentialProvider, error) {
27+
return &kernel.CredentialProvider{}, nil
28+
}
29+
30+
func (f *FakeCredentialProvidersService) List(ctx context.Context, query kernel.CredentialProviderListParams, opts ...option.RequestOption) (*pagination.OffsetPagination[kernel.CredentialProvider], error) {
31+
if f.ListFunc != nil {
32+
return f.ListFunc(ctx, query, opts...)
33+
}
34+
return &pagination.OffsetPagination[kernel.CredentialProvider]{Items: []kernel.CredentialProvider{}}, nil
35+
}
36+
37+
func (f *FakeCredentialProvidersService) Delete(ctx context.Context, id string, opts ...option.RequestOption) error {
38+
return nil
39+
}
40+
41+
func (f *FakeCredentialProvidersService) Test(ctx context.Context, id string, opts ...option.RequestOption) (*kernel.CredentialProviderTestResult, error) {
42+
return &kernel.CredentialProviderTestResult{}, nil
43+
}
44+
45+
func (f *FakeCredentialProvidersService) ListItems(ctx context.Context, id string, opts ...option.RequestOption) (*kernel.CredentialProviderListItemsResponse, error) {
46+
return &kernel.CredentialProviderListItemsResponse{}, nil
47+
}
48+
49+
func TestCredentialProvidersList_ForwardsLimitOffset(t *testing.T) {
50+
setupStdoutCapture(t)
51+
52+
var captured kernel.CredentialProviderListParams
53+
fake := &FakeCredentialProvidersService{
54+
ListFunc: func(ctx context.Context, query kernel.CredentialProviderListParams, opts ...option.RequestOption) (*pagination.OffsetPagination[kernel.CredentialProvider], error) {
55+
captured = query
56+
return &pagination.OffsetPagination[kernel.CredentialProvider]{Items: []kernel.CredentialProvider{}}, nil
57+
},
58+
}
59+
60+
c := CredentialProvidersCmd{providers: fake}
61+
err := c.List(context.Background(), CredentialProvidersListInput{Limit: 5, Offset: 10})
62+
63+
assert.NoError(t, err)
64+
assert.Equal(t, int64(5), captured.Limit.Value)
65+
assert.Equal(t, int64(10), captured.Offset.Value)
66+
}

cmd/extensions.go

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/kernel/cli/pkg/util"
1515
"github.com/kernel/kernel-go-sdk"
1616
"github.com/kernel/kernel-go-sdk/option"
17+
"github.com/kernel/kernel-go-sdk/packages/pagination"
1718
"github.com/pterm/pterm"
1819
"github.com/spf13/cobra"
1920
)
@@ -43,14 +44,16 @@ var defaultExtensionExclusions = util.ZipOptions{
4344

4445
// ExtensionsService defines the subset of the Kernel SDK extension client that we use.
4546
type ExtensionsService interface {
46-
List(ctx context.Context, opts ...option.RequestOption) (res *[]kernel.ExtensionListResponse, err error)
47+
List(ctx context.Context, query kernel.ExtensionListParams, opts ...option.RequestOption) (res *pagination.OffsetPagination[kernel.ExtensionListResponse], err error)
4748
Delete(ctx context.Context, idOrName string, opts ...option.RequestOption) (err error)
4849
Download(ctx context.Context, idOrName string, opts ...option.RequestOption) (res *http.Response, err error)
4950
DownloadFromChromeStore(ctx context.Context, query kernel.ExtensionDownloadFromChromeStoreParams, opts ...option.RequestOption) (res *http.Response, err error)
5051
Upload(ctx context.Context, body kernel.ExtensionUploadParams, opts ...option.RequestOption) (res *kernel.ExtensionUploadResponse, err error)
5152
}
5253

5354
type ExtensionsListInput struct {
55+
Limit int
56+
Offset int
5457
Output string
5558
}
5659

@@ -89,25 +92,37 @@ func (e ExtensionsCmd) List(ctx context.Context, in ExtensionsListInput) error {
8992
if in.Output != "json" {
9093
pterm.Info.Println("Fetching extensions...")
9194
}
92-
items, err := e.extensions.List(ctx)
95+
params := kernel.ExtensionListParams{}
96+
if in.Limit > 0 {
97+
params.Limit = kernel.Int(int64(in.Limit))
98+
}
99+
if in.Offset > 0 {
100+
params.Offset = kernel.Int(int64(in.Offset))
101+
}
102+
page, err := e.extensions.List(ctx, params)
93103
if err != nil {
94104
return util.CleanedUpSdkError{Err: err}
95105
}
96106

107+
var items []kernel.ExtensionListResponse
108+
if page != nil {
109+
items = page.Items
110+
}
111+
97112
if in.Output == "json" {
98-
if items == nil || len(*items) == 0 {
113+
if len(items) == 0 {
99114
fmt.Println("[]")
100115
return nil
101116
}
102-
return util.PrintPrettyJSONSlice(*items)
117+
return util.PrintPrettyJSONSlice(items)
103118
}
104119

105-
if items == nil || len(*items) == 0 {
120+
if len(items) == 0 {
106121
pterm.Info.Println("No extensions found")
107122
return nil
108123
}
109124
rows := pterm.TableData{{"Extension ID", "Name", "Created At", "Size (bytes)", "Last Used At"}}
110-
for _, it := range *items {
125+
for _, it := range items {
111126
name := it.Name
112127
if name == "" {
113128
name = "-"
@@ -402,9 +417,11 @@ var extensionsListCmd = &cobra.Command{
402417
RunE: func(cmd *cobra.Command, args []string) error {
403418
client := getKernelClient(cmd)
404419
output, _ := cmd.Flags().GetString("output")
420+
limit, _ := cmd.Flags().GetInt("limit")
421+
offset, _ := cmd.Flags().GetInt("offset")
405422
svc := client.Extensions
406423
e := ExtensionsCmd{extensions: &svc}
407-
return e.List(cmd.Context(), ExtensionsListInput{Output: output})
424+
return e.List(cmd.Context(), ExtensionsListInput{Limit: limit, Offset: offset, Output: output})
408425
},
409426
}
410427

@@ -519,6 +536,8 @@ func init() {
519536
extensionsCmd.AddCommand(extensionsBuildWebBotAuthCmd)
520537

521538
addJSONOutputFlag(extensionsListCmd)
539+
extensionsListCmd.Flags().Int("limit", 0, "Maximum number of extensions to return")
540+
extensionsListCmd.Flags().Int("offset", 0, "Number of extensions to skip (for pagination)")
522541
extensionsDeleteCmd.Flags().BoolP("yes", "y", false, "Skip confirmation prompt")
523542
extensionsDownloadCmd.Flags().String("to", "", "Output zip file path")
524543
extensionsDownloadWebStoreCmd.Flags().String("to", "", "Output zip file path for the downloaded archive")

0 commit comments

Comments
 (0)