Skip to content

Commit

Permalink
fix: kcctl subcommand has a bug where the ssh port is 0 (#267)
Browse files Browse the repository at this point in the history
Signed-off-by: zhuzhenfan <981189503@qq.com>

Signed-off-by: zhuzhenfan <981189503@qq.com>
Co-authored-by: zhuzhenfan <981189503@qq.com>
  • Loading branch information
kubeclipper-bot and zhuzhenfan committed Oct 17, 2022
1 parent b7d5109 commit 4f19dcf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
9 changes: 3 additions & 6 deletions cmd/kcctl/app/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,8 @@ func (a AgentRegions) Exists(ip string) bool {

func NewDeployOptions() *DeployConfig {
return &DeployConfig{
IPDetect: autodetection.MethodFirst,
SSHConfig: &sshutils.SSH{
User: "root",
Port: 22,
},
IPDetect: autodetection.MethodFirst,
SSHConfig: sshutils.NewSSH(),
EtcdConfig: &Etcd{
ClientPort: 2379,
PeerPort: 2380,
Expand Down Expand Up @@ -420,7 +417,7 @@ func (c *DeployConfig) AddFlags(flags *pflag.FlagSet) {
func AddFlagsToSSH(ssh *sshutils.SSH, flags *pflag.FlagSet) {
flags.StringVarP(&ssh.User, "user", "u", ssh.User, "Deploy ssh user")
flags.StringVar(&ssh.Password, "passwd", ssh.Password, "Deploy ssh password")
flags.IntVar(&ssh.Port, "ssh-port", ssh.Port, "ssh connection port of agent nodes")
flags.IntVar(&ssh.Port, "ssh-port", 22, "ssh connection port of agent nodes")
flags.StringVar(&ssh.PkFile, "pk-file", ssh.PkFile, "ssh pk file which used to remote access other agent nodes")
flags.StringVar(&ssh.PkPassword, "pk-passwd", ssh.PkPassword, "the password of the ssh pk file which used to remote access other agent nodes")
}
Expand Down
8 changes: 3 additions & 5 deletions pkg/cli/registry/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,9 @@ var (

func NewRegistryOptions(streams options.IOStreams) *RegistryOptions {
return &RegistryOptions{
IOStreams: streams,
PrintFlags: printer.NewPrintFlags(),
SSHConfig: &sshutils.SSH{
User: "root",
},
IOStreams: streams,
PrintFlags: printer.NewPrintFlags(),
SSHConfig: sshutils.NewSSH(),
DataRoot: "/var/lib/docker",
RegistryVolume: "/opt/registry",
RegistryPort: 5000,
Expand Down
8 changes: 3 additions & 5 deletions pkg/cli/upgrade/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,9 @@ type UpgradeOptions struct {
func NewUpgradeOptions(stream options.IOStreams) *UpgradeOptions {
return &UpgradeOptions{
BaseOptions: BaseOptions{
CliOpts: options.NewCliOptions(),
client: nil,
SSHConfig: &sshutils.SSH{
User: "root",
},
CliOpts: options.NewCliOptions(),
client: nil,
SSHConfig: sshutils.NewSSH(),
IOStreams: stream,
deployConfig: options.NewDeployOptions(),
},
Expand Down
7 changes: 7 additions & 0 deletions pkg/utils/sshutils/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type SSH struct {
ConnectionTimeout *time.Duration `json:"connectionTimeout,omitempty" yaml:"connectionTimeout,omitempty"`
}

func NewSSH() *SSH {
return &SSH{
User: "root",
Port: 22,
}
}

func (ss *SSH) NewClient(host string) (*ssh.Client, error) {
return ss.connect(host)
}
Expand Down

0 comments on commit 4f19dcf

Please sign in to comment.