mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-05 18:58:43 +02:00
Move sdk from code.gitea.io/sdk/gitea to gitea.dev/sdk (#1006)
Reviewed-on: https://gitea.com/gitea/tea/pulls/1006 Reviewed-by: Zettat123 <39446+zettat123@noreply.gitea.com>
This commit is contained in:
+3
-3
@@ -10,7 +10,7 @@ import (
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/cmd/flags"
|
||||
"gitea.dev/tea/modules/context"
|
||||
@@ -35,7 +35,7 @@ var CmdSSHKeyAdd = cli.Command{
|
||||
}
|
||||
|
||||
// RunSSHKeyAdd reads a public key file and registers it with the Gitea instance
|
||||
func RunSSHKeyAdd(_ stdctx.Context, cmd *cli.Command) error {
|
||||
func RunSSHKeyAdd(requestCtx stdctx.Context, cmd *cli.Command) error {
|
||||
ctx, err := context.InitCommand(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -62,7 +62,7 @@ func RunSSHKeyAdd(_ stdctx.Context, cmd *cli.Command) error {
|
||||
title = strings.TrimSuffix(base, filepath.Ext(base))
|
||||
}
|
||||
|
||||
key, _, err := ctx.Login.Client().CreatePublicKey(gitea.CreateKeyOption{
|
||||
key, _, err := ctx.Login.Client().Users.CreatePublicKey(requestCtx, gitea.CreateKeyOption{
|
||||
Title: title,
|
||||
Key: keyContent,
|
||||
})
|
||||
|
||||
@@ -32,7 +32,7 @@ var CmdSSHKeyDelete = cli.Command{
|
||||
}
|
||||
|
||||
// RunSSHKeyDelete removes an SSH key by its numeric ID
|
||||
func RunSSHKeyDelete(_ stdctx.Context, cmd *cli.Command) error {
|
||||
func RunSSHKeyDelete(requestCtx stdctx.Context, cmd *cli.Command) error {
|
||||
ctx, err := context.InitCommand(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -49,7 +49,7 @@ func RunSSHKeyDelete(_ stdctx.Context, cmd *cli.Command) error {
|
||||
|
||||
client := ctx.Login.Client()
|
||||
|
||||
key, resp, err := client.GetPublicKey(keyID)
|
||||
key, resp, err := client.Users.GetPublicKey(requestCtx, keyID)
|
||||
if err != nil {
|
||||
if resp != nil && resp.StatusCode == 404 {
|
||||
return fmt.Errorf("SSH key with ID %d not found", keyID)
|
||||
@@ -67,7 +67,7 @@ func RunSSHKeyDelete(_ stdctx.Context, cmd *cli.Command) error {
|
||||
}
|
||||
}
|
||||
|
||||
if _, err = client.DeletePublicKey(keyID); err != nil {
|
||||
if _, err = client.Users.DeletePublicKey(requestCtx, keyID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -6,7 +6,7 @@ package sshkeys
|
||||
import (
|
||||
stdctx "context"
|
||||
|
||||
"code.gitea.io/sdk/gitea"
|
||||
"gitea.dev/sdk"
|
||||
|
||||
"gitea.dev/tea/cmd/flags"
|
||||
"gitea.dev/tea/modules/context"
|
||||
@@ -30,14 +30,14 @@ var CmdSSHKeyList = cli.Command{
|
||||
}
|
||||
|
||||
// RunSSHKeyList lists SSH keys for the current user
|
||||
func RunSSHKeyList(_ stdctx.Context, cmd *cli.Command) error {
|
||||
func RunSSHKeyList(requestCtx stdctx.Context, cmd *cli.Command) error {
|
||||
ctx, err := context.InitCommand(cmd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
client := ctx.Login.Client()
|
||||
|
||||
keys, _, err := client.ListMyPublicKeys(gitea.ListPublicKeysOptions{
|
||||
keys, _, err := client.Users.ListMyPublicKeys(requestCtx, gitea.ListPublicKeysOptions{
|
||||
ListOptions: flags.GetListOptions(cmd),
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user