Skip to content

Commit d0aaf17

Browse files
committed
chore(logs): refactor access token list
1 parent 32cb71a commit d0aaf17

2 files changed

Lines changed: 16 additions & 16 deletions

File tree

internal/cmd/logs/access_token/list/list.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ func NewCmd(params *types.CmdParams) *cobra.Command {
8282
}
8383

8484
// Truncate output
85-
items := utils.PtrValue(resp.Tokens)
85+
items := resp.Tokens
8686
if model.Limit != nil && len(items) > int(*model.Limit) {
8787
items = items[:*model.Limit]
8888
}
@@ -127,7 +127,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, _ []string) (*inputModel,
127127
}
128128

129129
func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiListAccessTokensRequest {
130-
return apiClient.ListAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId)
130+
return apiClient.DefaultAPI.ListAccessTokens(ctx, model.ProjectId, model.Region, model.InstanceId)
131131
}
132132

133133
func outputResult(p *print.Printer, outputFormat string, tokens []logs.AccessToken, projectLabel string) error {
@@ -142,12 +142,12 @@ func outputResult(p *print.Printer, outputFormat string, tokens []logs.AccessTok
142142

143143
for _, token := range tokens {
144144
table.AddRow(
145-
utils.PtrString(token.Id),
146-
utils.PtrString(token.DisplayName),
145+
token.Id,
146+
token.DisplayName,
147147
utils.PtrString(token.Description),
148-
utils.PtrString(token.Permissions),
148+
token.Permissions,
149149
utils.PtrString(token.ValidUntil),
150-
utils.PtrString(token.Status),
150+
token.Status,
151151
)
152152
table.AddSeparator()
153153
}

internal/cmd/logs/access_token/list/list_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type testCtxKey struct{}
2323

2424
var (
2525
testCtx = context.WithValue(context.Background(), testCtxKey{}, "foo")
26-
testClient = &logs.APIClient{}
26+
testClient = &logs.APIClient{DefaultAPI: &logs.DefaultAPIService{}}
2727

2828
testProjectId = uuid.NewString()
2929
testInstanceId = uuid.NewString()
@@ -61,7 +61,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
6161
}
6262

6363
func fixtureRequest(mods ...func(request *logs.ApiListAccessTokensRequest)) logs.ApiListAccessTokensRequest {
64-
request := testClient.ListAccessTokens(testCtx, testProjectId, testRegion, testInstanceId)
64+
request := testClient.DefaultAPI.ListAccessTokens(testCtx, testProjectId, testRegion, testInstanceId)
6565
for _, mod := range mods {
6666
mod(&request)
6767
}
@@ -171,7 +171,7 @@ func TestBuildRequest(t *testing.T) {
171171

172172
diff := cmp.Diff(request, tt.expectedRequest,
173173
cmp.AllowUnexported(tt.expectedRequest),
174-
cmpopts.EquateComparable(testCtx),
174+
cmpopts.EquateComparable(testCtx, tt.expectedRequest),
175175
)
176176
if diff != "" {
177177
t.Fatalf("Data does not match: %s", diff)
@@ -196,16 +196,16 @@ func TestOutputResult(t *testing.T) {
196196
args: args{
197197
accessTokens: []logs.AccessToken{
198198
{
199-
Id: utils.Ptr(uuid.NewString()),
200-
Permissions: utils.Ptr([]string{
199+
Id: uuid.NewString(),
200+
Permissions: []logs.PermissionsInner{
201201
"read",
202202
"write",
203-
}),
204-
DisplayName: utils.Ptr("Token"),
203+
},
204+
DisplayName: "Token",
205205
AccessToken: utils.Ptr("Secret access token"),
206-
Creator: utils.Ptr(uuid.NewString()),
207-
Expires: utils.Ptr(false),
208-
Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE),
206+
Creator: uuid.NewString(),
207+
Expires: false,
208+
Status: logs.ACCESSTOKENSTATUS_ACTIVE,
209209
},
210210
},
211211
},

0 commit comments

Comments
 (0)