mirror of
https://github.com/kairos-io/kairos-agent.git
synced 2025-08-17 15:57:46 +00:00
DRY the definition of "--source" flag
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
parent
85196fbc59
commit
a10390e0a8
25
main.go
25
main.go
@ -54,6 +54,11 @@ func ReleasesToOutput(rels semver.Collection, output string) []string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var sourceFlag = cli.StringFlag{
|
||||||
|
Name: "source",
|
||||||
|
Usage: "Source for upgrade. Composed of `type:address`. Accepts `file:`,`dir:` or `oci:` for the type of source.\nFor example `file:/var/share/myimage.tar`, `dir:/tmp/extracted` or `oci:repo/image:tag`",
|
||||||
|
}
|
||||||
|
|
||||||
var cmds = []*cli.Command{
|
var cmds = []*cli.Command{
|
||||||
{
|
{
|
||||||
Name: "upgrade",
|
Name: "upgrade",
|
||||||
@ -66,10 +71,7 @@ var cmds = []*cli.Command{
|
|||||||
Name: "image",
|
Name: "image",
|
||||||
Usage: "[DEPRECATED] Specify a full image reference, e.g.: quay.io/some/image:tag",
|
Usage: "[DEPRECATED] Specify a full image reference, e.g.: quay.io/some/image:tag",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&sourceFlag,
|
||||||
Name: "source",
|
|
||||||
Usage: "Source for upgrade. Composed of `type:address`. Accepts `file:`,`dir:` or `oci:` for the type of source.\nFor example `file:/var/share/myimage.tar`, `dir:/tmp/extracted` or `oci:repo/image:tag`",
|
|
||||||
},
|
|
||||||
&cli.BoolFlag{Name: "pre", Usage: "Include pre-releases (rc, beta, alpha)"},
|
&cli.BoolFlag{Name: "pre", Usage: "Include pre-releases (rc, beta, alpha)"},
|
||||||
&cli.BoolFlag{Name: "recovery", Usage: "Upgrade recovery"},
|
&cli.BoolFlag{Name: "recovery", Usage: "Upgrade recovery"},
|
||||||
},
|
},
|
||||||
@ -378,10 +380,7 @@ This command is meant to be used from the boot GRUB menu, but can be also starte
|
|||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "shell",
|
Name: "shell",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&sourceFlag,
|
||||||
Name: "source",
|
|
||||||
Usage: "Source for upgrade. Composed of `type:address`. Accepts `file:`,`dir:` or `oci:` for the type of source.\nFor example `file:/var/share/myimage.tar`, `dir:/tmp/extracted` or `oci:repo/image:tag`",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Usage: "Starts interactive installation",
|
Usage: "Starts interactive installation",
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
@ -413,10 +412,7 @@ This command is meant to be used from the boot GRUB menu, but can be also starte
|
|||||||
&cli.BoolFlag{
|
&cli.BoolFlag{
|
||||||
Name: "reboot",
|
Name: "reboot",
|
||||||
},
|
},
|
||||||
&cli.StringFlag{
|
&sourceFlag,
|
||||||
Name: "source",
|
|
||||||
Usage: "Source for upgrade. Composed of `type:address`. Accepts `file:`,`dir:` or `oci:` for the type of source.\nFor example `file:/var/share/myimage.tar`, `dir:/tmp/extracted` or `oci:repo/image:tag`",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Before: func(c *cli.Context) error {
|
Before: func(c *cli.Context) error {
|
||||||
if err := validateSource(c.String("source")); err != nil {
|
if err := validateSource(c.String("source")); err != nil {
|
||||||
@ -456,10 +452,7 @@ This command is meant to be used from the boot GRUB menu, but can be started man
|
|||||||
return checkRoot()
|
return checkRoot()
|
||||||
},
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringFlag{
|
&sourceFlag,
|
||||||
Name: "source",
|
|
||||||
Usage: "Source for upgrade. Composed of `type:address`. Accepts `file:`,`dir:` or `oci:` for the type of source.\nFor example `file:/var/share/myimage.tar`, `dir:/tmp/extracted` or `oci:repo/image:tag`",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
source := c.String("source")
|
source := c.String("source")
|
||||||
|
Loading…
Reference in New Issue
Block a user