Skip to content

Commit 32cb71a

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

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

internal/cmd/logs/access_token/describe/describe.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func parseInput(p *print.Printer, cmd *cobra.Command, inputArgs []string) (*inpu
101101
}
102102

103103
func buildRequest(ctx context.Context, model *inputModel, apiClient *logs.APIClient) logs.ApiGetAccessTokenRequest {
104-
return apiClient.GetAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId)
104+
return apiClient.DefaultAPI.GetAccessToken(ctx, model.ProjectId, model.Region, model.InstanceId, model.AccessTokenId)
105105
}
106106

107107
func outputResult(p *print.Printer, outputFormat string, token *logs.AccessToken) error {
@@ -110,21 +110,21 @@ func outputResult(p *print.Printer, outputFormat string, token *logs.AccessToken
110110
}
111111
return p.OutputResult(outputFormat, token, func() error {
112112
table := tables.NewTable()
113-
table.AddRow("ID", utils.PtrString(token.Id))
113+
table.AddRow("ID", token.Id)
114114
table.AddSeparator()
115-
table.AddRow("DISPLAY NAME", utils.PtrString(token.DisplayName))
115+
table.AddRow("DISPLAY NAME", token.DisplayName)
116116
table.AddSeparator()
117117
table.AddRow("DESCRIPTION", utils.PtrString(token.Description))
118118
table.AddSeparator()
119-
table.AddRow("PERMISSIONS", utils.PtrString(token.Permissions))
119+
table.AddRow("PERMISSIONS", token.Permissions)
120120
table.AddSeparator()
121-
table.AddRow("CREATOR", utils.PtrString(token.Creator))
121+
table.AddRow("CREATOR", token.Creator)
122122
table.AddSeparator()
123-
table.AddRow("STATE", utils.PtrString(token.Status))
123+
table.AddRow("STATE", token.Status)
124124
table.AddSeparator()
125-
table.AddRow("EXPIRES", utils.PtrString(token.Expires))
125+
table.AddRow("EXPIRES", token.Expires)
126126
table.AddSeparator()
127-
table.AddRow("VALID UNTIL", utils.PtrString(token.ValidUntil))
127+
table.AddRow("VALID UNTIL", token.ValidUntil)
128128
table.AddSeparator()
129129

130130
err := table.Display(p)

internal/cmd/logs/access_token/describe/describe_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()
@@ -71,7 +71,7 @@ func fixtureInputModel(mods ...func(model *inputModel)) *inputModel {
7171
}
7272

7373
func fixtureRequest(mods ...func(request *logs.ApiGetAccessTokenRequest)) logs.ApiGetAccessTokenRequest {
74-
request := testClient.GetAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId)
74+
request := testClient.DefaultAPI.GetAccessToken(testCtx, testProjectId, testRegion, testInstanceId, testAccessTokenId)
7575
for _, mod := range mods {
7676
mod(&request)
7777
}
@@ -199,7 +199,7 @@ func TestBuildRequest(t *testing.T) {
199199

200200
diff := cmp.Diff(request, tt.expectedRequest,
201201
cmp.AllowUnexported(tt.expectedRequest),
202-
cmpopts.EquateComparable(testCtx),
202+
cmpopts.EquateComparable(testCtx, tt.expectedRequest),
203203
)
204204
if diff != "" {
205205
t.Fatalf("Data does not match: %s", diff)
@@ -222,16 +222,16 @@ func TestOutputResult(t *testing.T) {
222222
name: "base",
223223
args: args{
224224
accessToken: utils.Ptr(logs.AccessToken{
225-
Id: utils.Ptr(uuid.NewString()),
226-
Permissions: utils.Ptr([]string{
225+
Id: uuid.NewString(),
226+
Permissions: []logs.PermissionsInner{
227227
"read",
228228
"write",
229-
}),
230-
DisplayName: utils.Ptr("Token"),
229+
},
230+
DisplayName: "Token",
231231
AccessToken: utils.Ptr("Secret access token"),
232-
Creator: utils.Ptr(uuid.NewString()),
233-
Expires: utils.Ptr(false),
234-
Status: utils.Ptr(logs.ACCESSTOKENSTATUS_ACTIVE),
232+
Creator: uuid.NewString(),
233+
Expires: false,
234+
Status: logs.ACCESSTOKENSTATUS_ACTIVE,
235235
}),
236236
},
237237
wantErr: false,

0 commit comments

Comments
 (0)