Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/USER_GUIDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ d8 v vnc linux-vm
Example command for connecting via SSH.

```bash
d8 v ssh cloud@linux-vm --local-ssh
d8 v ssh cloud@linux-vm
```

How to connect to a virtual machine in the web interface:
Expand Down Expand Up @@ -1807,7 +1807,7 @@ Let's consider an example of changing the configuration of a virtual machine:
Suppose we want to change the number of processor cores. The virtual machine is currently running and using one core, which can be confirmed by connecting to it through the serial console and executing the `nproc` command.

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "nproc"
d8 v ssh cloud@linux-vm --command "nproc"
```

Example output:
Expand Down Expand Up @@ -1835,7 +1835,7 @@ Example output:
Configuration changes have been made but not yet applied to the virtual machine. Check this by re-executing:

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "nproc"
d8 v ssh cloud@linux-vm --command "nproc"
```

Example output:
Expand Down Expand Up @@ -1889,7 +1889,7 @@ After a reboot, the changes will be applied and the `.status.restartAwaitingChan
Execute the command to verify:

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "nproc"
d8 v ssh cloud@linux-vm --command "nproc"
```

Example output:
Expand Down Expand Up @@ -2338,7 +2338,7 @@ attach-blank-disk Attached linux-vm 3m7s
Connect to the virtual machine and make sure the disk is connected:

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "lsblk"
d8 v ssh cloud@linux-vm --command "lsblk"
```

Example output:
Expand Down
10 changes: 5 additions & 5 deletions docs/USER_GUIDE.ru.md
Original file line number Diff line number Diff line change
Expand Up @@ -1699,7 +1699,7 @@ d8 v vnc linux-vm
Пример команды для подключения по SSH:

```bash
d8 v ssh cloud@linux-vm --local-ssh
d8 v ssh cloud@linux-vm
```

Как подключиться к виртуальной машине в веб-интерфейсе:
Expand Down Expand Up @@ -1825,7 +1825,7 @@ d8 k edit vm linux-vm
Предположим, мы хотим изменить количество ядер процессора. В данный момент виртуальная машина запущена и использует одно ядро, что можно подтвердить, подключившись к ней через серийную консоль и выполнив команду `nproc`.

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "nproc"
d8 v ssh cloud@linux-vm --command "nproc"
```

Пример вывода:
Expand Down Expand Up @@ -1853,7 +1853,7 @@ d8 k edit vm linux-vm
Изменения в конфигурации внесены, но ещё не применены к виртуальной машине. Проверьте это, повторно выполнив:

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "nproc"
d8 v ssh cloud@linux-vm --command "nproc"
```

Пример вывода:
Expand Down Expand Up @@ -1907,7 +1907,7 @@ d8 v restart linux-vm
Выполните команду для проверки:

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "nproc"
d8 v ssh cloud@linux-vm --command "nproc"
```

Пример вывода:
Expand Down Expand Up @@ -2355,7 +2355,7 @@ attach-blank-disk Attached linux-vm 3m7s
Подключитесь к виртуальной машине и удостоверитесь, что диск подключен:

```bash
d8 v ssh cloud@linux-vm --local-ssh --command "lsblk"
d8 v ssh cloud@linux-vm --command "lsblk"
```

Пример вывода:
Expand Down
4 changes: 2 additions & 2 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ d8 v scp user@myvm:myfile.bin ~/myfile.bin
#### ssh

```shell
d8 v --identity-file=/path/to/ssh_key ssh user@myvm.mynamespace
d8 v ssh --local-ssh=true --namespace=mynamespace --username=user myvm
d8 v ssh --identity-file=/path/to/ssh_key user@myvm.mynamespace
d8 v ssh --namespace=mynamespace --username=user myvm
```

#### vnc
Expand Down
4 changes: 1 addition & 3 deletions src/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,8 @@ require (
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674
github.com/onsi/ginkgo/v2 v2.23.3
github.com/onsi/gomega v1.37.0
github.com/povsister/scp v0.0.0-20250504051308-e467f71ea63c
github.com/spf13/cobra v1.9.1
github.com/spf13/pflag v1.0.7
golang.org/x/crypto v0.45.0
golang.org/x/sys v0.38.0
golang.org/x/term v0.37.0
golang.org/x/text v0.31.0
gopkg.in/yaml.v3 v3.0.1
Expand Down Expand Up @@ -67,6 +64,7 @@ require (
go.yaml.in/yaml/v3 v3.0.4 // indirect
golang.org/x/net v0.47.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/sys v0.38.0 // indirect
golang.org/x/time v0.9.0 // indirect
golang.org/x/tools v0.38.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
Expand Down
6 changes: 0 additions & 6 deletions src/cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/povsister/scp v0.0.0-20250504051308-e467f71ea63c h1:1+j5JHz9mUzYSp0scuF6hzvJP28EDBFe5eBJb0xnGk4=
github.com/povsister/scp v0.0.0-20250504051308-e467f71ea63c/go.mod h1:CiJNEeV6v0tUCNul/+gTjl+FgjfImoiuptJB9AEzqjE=
github.com/prometheus/client_golang v1.22.0 h1:rb93p9lokFEsctTys46VnV1kLCDpVZ0a/Y92Vm0Zc6Q=
github.com/prometheus/client_golang v1.22.0/go.mod h1:R7ljNsLXhuQXYZYtw6GAE9AZg8Y7vEW5scdCXrWRXC0=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
Expand Down Expand Up @@ -230,9 +228,6 @@ go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.45.0 h1:jMBrvKuj23MTlT0bQEOBcAE0mjg8mK9RXFhRH6nyF3Q=
golang.org/x/crypto v0.45.0/go.mod h1:XTGrrkGJve7CYK7J8PEww4aY7gM3qMCElcJQ8n8JdX4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
Expand All @@ -252,7 +247,6 @@ golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM=
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
Expand Down
11 changes: 11 additions & 0 deletions src/cli/internal/clientconfig/clientconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ func ClientAndNamespaceFromContext(ctx context.Context) (client kubeclient.Clien
return client, namespace, overridden, nil
}

// NamespaceFromContext returns the namespace from the active kubeconfig
// context.
func NamespaceFromContext(ctx context.Context) (string, error) {
clientConfig, ok := ctx.Value(clientConfigKey).(clientcmd.ClientConfig)
if !ok {
return "", fmt.Errorf("unable to get client config from context")
}
namespace, _, err := clientConfig.Namespace()
return namespace, err
}

func GetRESTConfig(ctx context.Context) (*rest.Config, error) {
clientConfig, ok := ctx.Value(clientConfigKey).(clientcmd.ClientConfig)
if !ok {
Expand Down
126 changes: 0 additions & 126 deletions src/cli/internal/cmd/scp/native.go

This file was deleted.

11 changes: 5 additions & 6 deletions src/cli/internal/cmd/scp/scp.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (o *SCP) Run(cmd *cobra.Command, args []string) error {
return err
}

client, defaultNamespace, _, err := clientconfig.ClientAndNamespaceFromContext(cmd.Context())
defaultNamespace, err := clientconfig.NamespaceFromContext(cmd.Context())
if err != nil {
return err
}
Expand All @@ -77,16 +77,15 @@ func (o *SCP) Run(cmd *cobra.Command, args []string) error {
return err
}

if o.options.WrapLocalSSH {
clientArgs := o.buildSCPTarget(local, remote, toRemote)
return ssh.RunLocalClient(cmd, remote.Namespace, remote.Name, &o.options, clientArgs)
}
ssh.WarnDeprecatedSSHFlags(cmd)

return o.nativeSCP(client, local, remote, toRemote)
clientArgs := o.buildSCPTarget(local, remote, toRemote)
return ssh.RunLocalClient(cmd, remote.Namespace, remote.Name, &o.options, clientArgs)
}

func PrepareCommand(cmd *cobra.Command, defaultNamespace string, opts *ssh.SSHOptions, args []string) (local templates.LocalSCPArgument, remote templates.RemoteSCPArgument, toRemote bool, err error) {
opts.IdentityFilePathProvided = cmd.Flags().Changed(ssh.IdentityFilePathFlag)
opts.KnownHostsFilePathProvided = cmd.Flags().Changed("known-hosts")
local, remote, toRemote, err = templates.ParseSCPArguments(args[0], args[1])
if err != nil {
return local, remote, toRemote, err
Expand Down
39 changes: 39 additions & 0 deletions src/cli/internal/cmd/scp/scp_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2026 Flant JSC

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package scp

import (
"testing"

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
)

func TestSCP(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "SCP Command Suite")
}

var _ = Describe("SCP", func() {
Describe("NewCommand", func() {
It("registers the new --ssh-args flag inherited from ssh.AddCommonSSHFlags", func() {
cmd := NewCommand()
Expect(cmd.Flags().Lookup("ssh-args")).NotTo(BeNil())
Expect(cmd.Flags().Lookup("ssh-opts")).To(BeNil())
})
})
})
Loading
Loading