chore: add --version flag for 'machine init|add' to specify uncloud daemon version

This commit is contained in:
Pavel Sviderski
2025-04-23 14:40:04 +10:00
parent 33550be65e
commit 02a418aafb
4 changed files with 93 additions and 56 deletions
+13 -1
View File
@@ -25,6 +25,7 @@ type addOptions struct {
publicIP string
sshKey string
context string
version string
}
func NewAddCommand() *cobra.Command {
@@ -64,10 +65,15 @@ func NewAddCommand() *cobra.Command {
&opts.sshKey, "ssh-key", "i", "",
"path to SSH private key for SSH remote login. (default ~/.ssh/id_*)",
)
cmd.Flags().StringVar(
&opts.version, "version", "latest",
"Version of the Uncloud daemon to install on the machine.",
)
cmd.Flags().StringVarP(
&opts.context, "context", "c", "",
"Name of the cluster context to add the machine to. (default is the current context)",
)
return cmd
}
@@ -86,7 +92,13 @@ func add(ctx context.Context, uncli *cli.CLI, remoteMachine cli.RemoteMachine, o
publicIP = &ip
}
machineClient, err := uncli.AddMachine(ctx, remoteMachine, opts.context, opts.name, publicIP)
machineClient, err := uncli.AddMachine(ctx, cli.AddMachineOptions{
Context: opts.context,
MachineName: opts.name,
PublicIP: publicIP,
RemoteMachine: remoteMachine,
Version: opts.version,
})
if err != nil {
return err
}
+14 -2
View File
@@ -24,6 +24,7 @@ type initOptions struct {
noDNS bool
publicIP string
sshKey string
version string
context string
}
@@ -82,6 +83,10 @@ func NewInitCommand() *cobra.Command {
&opts.sshKey, "ssh-key", "i", "",
"Path to SSH private key for SSH remote login. (default ~/.ssh/id_*)",
)
cmd.Flags().StringVar(
&opts.version, "version", "latest",
"Version of the Uncloud daemon to install on the machine.",
)
cmd.Flags().StringVarP(
&opts.context, "context", "c", "default",
"Name of the created context for the initialised cluster in the Uncloud config.",
@@ -109,8 +114,15 @@ func initCluster(ctx context.Context, uncli *cli.CLI, remoteMachine *cli.RemoteM
}
publicIP = &ip
}
client, err := uncli.InitCluster(ctx, remoteMachine, opts.context, opts.name, netPrefix, publicIP)
client, err := uncli.InitCluster(ctx, cli.InitClusterOptions{
Context: opts.context,
MachineName: opts.name,
Network: netPrefix,
PublicIP: publicIP,
RemoteMachine: remoteMachine,
Version: opts.version,
})
if err != nil {
return err
}