mirror of
https://gitea.com/gitea/tea.git
synced 2026-09-10 07:26:33 -04:00
Adds a top-level 'tea deploy-keys' command under ENTITIES, providing
list, create, delete, and detail-by-id operations over the existing
Gitea REST API at /repos/{owner}/{repo}/keys.
- New CmdDeployKeys registered alongside tea webhooks/branches/etc.
- Subcommands: list (with pagination + --fingerprint filter),
create (<title> --key|--key-file [--read-only|--read-write]),
delete (<key-id> --confirm|-y), and a default <key-id> detail view.
- The Gitea API has no edit endpoint; 'change' is documented as
delete+create. No update subcommand is added.
- modules/print/deploy_key.go: DeployKeysList and DeployKeyDetails.
- Unit tests covering command metadata, flag wiring, key-material
resolution (--key vs --key-file, mutual exclusion, missing file),
delete confirmation logic, key-id parsing, and prompt formatting.
- README/CHANGELOG/CLI.md updated.
All four Gitea SDK methods used (CreateDeployKey, DeleteDeployKey,
GetDeployKey, ListDeployKeys) are already present in
code.gitea.io/sdk/gitea v0.23.2; no go.mod changes.
Refs #1066.
Signed-off-by: Ross Golder <ross@golder.org>
(cherry picked from commit 384540c91f9703d1e1b37dd6a8e51f502cc5f216)
53 lines
1.1 KiB
Go
53 lines
1.1 KiB
Go
// Copyright 2026 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package print
|
|
|
|
import (
|
|
"fmt"
|
|
"strconv"
|
|
|
|
"gitea.dev/sdk"
|
|
)
|
|
|
|
// DeployKeysList prints a listing of deploy keys
|
|
func DeployKeysList(keys []*gitea.DeployKey, output string) {
|
|
t := tableWithHeader(
|
|
"ID",
|
|
"Title",
|
|
"Fingerprint",
|
|
"Read-Only",
|
|
"Created",
|
|
)
|
|
|
|
for _, key := range keys {
|
|
readOnly := "no"
|
|
if key.ReadOnly {
|
|
readOnly = "yes"
|
|
}
|
|
|
|
t.addRow(
|
|
strconv.FormatInt(key.ID, 10),
|
|
key.Title,
|
|
key.Fingerprint,
|
|
readOnly,
|
|
FormatTime(key.Created, false),
|
|
)
|
|
}
|
|
|
|
t.print(output)
|
|
}
|
|
|
|
// DeployKeyDetails prints detailed information about a deploy key
|
|
func DeployKeyDetails(key *gitea.DeployKey) {
|
|
fmt.Printf("# Deploy Key %d\n\n", key.ID)
|
|
fmt.Printf("- **Title**: %s\n", key.Title)
|
|
fmt.Printf("- **Key ID**: %d\n", key.KeyID)
|
|
fmt.Printf("- **Fingerprint**: %s\n", key.Fingerprint)
|
|
fmt.Printf("- **Read-Only**: %t\n", key.ReadOnly)
|
|
fmt.Printf("- **Created**: %s\n", FormatTime(key.Created, false))
|
|
if key.URL != "" {
|
|
fmt.Printf("- **URL**: %s\n", key.URL)
|
|
}
|
|
}
|