Skip to content

fix(cli): mute warnings during cobra command configuration#2204

Open
diafour wants to merge 3 commits intomainfrom
fix/cli/mute-warnings-during-cobra-init
Open

fix(cli): mute warnings during cobra command configuration#2204
diafour wants to merge 3 commits intomainfrom
fix/cli/mute-warnings-during-cobra-init

Conversation

@diafour
Copy link
Copy Markdown
Member

@diafour diafour commented Apr 11, 2026

Description

  • Move home dir detection into RunE function.
  • Cleanup flags descriptions.
  • Build d8v in current dir, instead of a hidden directory.
  • More examples for ssh command.

Why do we need it, and what problem does it solve?

Warnings from "virtualization" command affects other commands in d8 cli.

What is the expected result?

No warnings if $HOME is empty

Before:

# HOME= d8 help
W0411 17:35:50.840692 1639809 ssh.go:67] failed to determine user home directory: $HOME is not defined
W0411 17:35:50.840724 1639809 ssh.go:67] failed to determine user home directory: $HOME is not defined
d8 controls the Deckhouse Kubernetes Platform

Usage:
  d8 [flags]
  d8 [command]

After:

# HOME= d8 help
d8 controls the Deckhouse Kubernetes Platform

Usage:
  d8 [flags]
  d8 [command]

Clean descriptions for ssh/scp flags

Before:

$ ./d8v help ssh
Open a SSH connection to a virtual machine.

Usage:
  ./d8v ssh VirtualMachine [flags]

Examples:
  # Connect to 'myvm':
  ./d8v ssh user@myvm [--identity-file]

  # Connect to 'myvm' in 'mynamespace' namespace
  ./d8v ssh user@myvm.mynamespace [--identity-file]

  # Specify a username and namespace:
  ./d8v ssh --namespace=mynamespace --username=user myvm

  # Connect to 'myvm' using the local ssh binary found in $PATH:
  ./d8v ssh --local-ssh=true user@myvm

Flags:
  -c, --command string               Specify a command to execute in the VM.
                                     Example: --command='ls /'
  -h, --help                         help for ssh
  -i, --identity-file string         --identity-file=/home/user/.ssh/id_rsa: Set the path to a private key used for authenticating to the server; If not provided, the client will try to use the local ssh-agent at $SSH_AUTH_SOCK (default "~/.ssh/id_rsa")
      --known-hosts string           --d8virtualization_known_hosts=/home/user/.ssh/known-hosts: Set the path to the known_hosts file. (default "~/.ssh/d8virtualization_known_hosts")
      --local-ssh                    --local-ssh=true: Set this to true to use the SSH/SCP client available on your system by using this command as ProxyCommand; If set to false, this will establish a SSH/SCP connection with limited capabilities provided by this client
  -t, --local-ssh-opts stringArray   --local-ssh-opts="-o StrictHostKeyChecking=no" : Additional options to be passed to the local ssh. This is applied only if local-ssh=true
  -p, --port int                     --port=22: Specify a port on the VM to send SSH traffic to (default 22)
  -l, --username string              --username=diafour: Set this to the user you want to open the SSH connection as; If unassigned, this will be empty and the SSH default will apply (default "diafour")

After:

$ ./d8v help ssh
Open a SSH connection to a virtual machine.

Usage:
  ./d8v ssh [-n|--namespace NAMESPACE] VIRTUAL-MACHINE-NAME [flags]

Examples:
  # Connect to virtualMachine 'myvm' in 'vms' namespace:
  ./d8v ssh user@myvm.vms

  # Specify namespace and user with flags:
  ./d8v ssh --namespace=vms --username=user myvm

  # Specify identity file:
  ./d8v ssh -n vms user@myvm -i /some/path/id_rsa_for_myvm

  # Run command instead of opening shell:
  ./d8v ssh -n vms user@myvm -c 'ls -la /'

  # Connect using the local ssh binary found in $PATH:
  ./d8v ssh --local-ssh=true user@myvm

  # Specify additional options for local ssh:
  ./d8v ssh user@myvm --local-ssh=true --local-ssh-opts='-o StrictHostKeyChecking=no' --local-ssh-opts='-o UserKnownHostsFile=/dev/null'


Flags:
  -c, --command string               Specify a command to execute in the VM.
  -h, --help                         help for ssh
  -i, --identity-file string         Specify a path to a private key used for authenticating to the server; If not provided, the client will try to use the local ssh-agent at $SSH_AUTH_SOCK (default "~/.ssh/id_rsa")
      --known-hosts string           Set a path to the known_hosts file. (default "~/.ssh/d8virtualization_known_hosts")
      --local-ssh                    Use the SSH/SCP client available on your system by using this command as ProxyCommand; Default is false: use embedded SSH client with limited capabilities
  -t, --local-ssh-opts stringArray   Additional options to be passed to the ssh client if --local-ssh=true is set
  -p, --port int                     Specify a port to connect to (default 22)
  -l, --username string              Specify user to log into virtual machine; If unassigned, this will be empty and the SSH default will apply (default "diafour")

Notes about changes in deckhouse/deckhouse-cli

PR: deckhouse/deckhouse-cli#324

Virtualization module is already migrated to Go 1.25 in the 'main' branch. deckhouse-cli still uses Go 1.24. These changes are backported to release-1.6 in branch fix/cli/mute-warnings-during-cobra-init-release-1-6-2 so dependencies in go.mod are compatible with the current state of dependencies in deckhouse-cli.

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

Changelog entries

section: cli
type: fix
summary: Mute warnings about empty home directory while executing other d8 commands.

- Move home dir detection into RunE function.
- Cleanup flags descriptions.
- Build d8v in current dir, instead of a hidden directory.
- More examples for ssh command.

Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
@diafour diafour added this to the v1.8.0 milestone Apr 11, 2026
@diafour diafour self-assigned this Apr 11, 2026
Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
@diafour diafour marked this pull request as ready for review April 11, 2026 17:12
@diafour diafour requested a review from Isteb4k as a code owner April 11, 2026 17:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant