mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 07:26:33 -04:00
51 lines
1.1 KiB
Go
51 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package deploytokens
|
|
|
|
import (
|
|
stdctx "context"
|
|
|
|
gitea "gitea.dev/sdk"
|
|
|
|
"gitea.dev/tea/cmd/flags"
|
|
"gitea.dev/tea/modules/context"
|
|
"gitea.dev/tea/modules/print"
|
|
"github.com/urfave/cli/v3"
|
|
)
|
|
|
|
var CmdDeployTokensList = cli.Command{
|
|
Name: "list",
|
|
Aliases: []string{"ls"},
|
|
Usage: "List deploy tokens",
|
|
Description: "List deploy tokens of a repository",
|
|
Action: RunDeployTokensList,
|
|
Flags: append([]cli.Flag{
|
|
&flags.PaginationPageFlag,
|
|
&flags.PaginationLimitFlag,
|
|
}, flags.AllDefaultFlags...),
|
|
}
|
|
|
|
func RunDeployTokensList(ctx stdctx.Context, cmd *cli.Command) error {
|
|
c, err := context.InitCommand(cmd)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if err := c.Ensure(context.CtxRequirement{RemoteRepo: true}); err != nil {
|
|
return err
|
|
}
|
|
client := c.Login.Client()
|
|
|
|
opts := gitea.ListDeployKeysOptions{
|
|
ListOptions: flags.GetListOptions(cmd),
|
|
}
|
|
|
|
tokens, _, err := client.ListDeployTokens(ctx, c.Owner, c.Repo, opts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
print.DeployTokensList(tokens, c.Output)
|
|
return nil
|
|
}
|