1
0
mirror of https://github.com/kairos-io/kairos-agent.git synced 2025-05-10 17:36:18 +00:00

Embed verioneer cli commands and fix duplicate command aliases

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
Signed-off-by: Dimitris Karakasilis <dimitris@karakasilis.me>
This commit is contained in:
Dimitris Karakasilis 2023-12-04 17:52:13 +02:00 committed by Dimitris Karakasilis
parent a89ebf2fca
commit faedd0fbae
No known key found for this signature in database
GPG Key ID: 286DCAFD2C97DDE3
3 changed files with 19 additions and 11 deletions

4
go.mod
View File

@ -13,7 +13,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1
github.com/jaypipes/ghw v0.12.0
github.com/joho/godotenv v1.5.1
github.com/kairos-io/kairos-sdk v0.0.17
github.com/kairos-io/kairos-sdk v0.0.18
github.com/labstack/echo/v4 v4.11.1
github.com/mitchellh/mapstructure v1.5.0
github.com/mudler/go-nodepair v0.0.0-20221223092639-ba399a66fdfb
@ -28,7 +28,7 @@ require (
github.com/sirupsen/logrus v1.9.3
github.com/spf13/viper v1.16.0
github.com/twpayne/go-vfs v1.7.2
github.com/urfave/cli/v2 v2.25.7
github.com/urfave/cli/v2 v2.26.0
golang.org/x/net v0.15.0
golang.org/x/oauth2 v0.12.0
gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0

8
go.sum
View File

@ -355,8 +355,8 @@ github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1
github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/kairos-io/kairos-sdk v0.0.17 h1:rBdtONkkRoIxtenB6BYb7Sir1Ss2yveSobyC7wC/fYU=
github.com/kairos-io/kairos-sdk v0.0.17/go.mod h1:6Y9RGvKU/B99euFE32OYrabLLsSVjjemCfyRgiEHuKE=
github.com/kairos-io/kairos-sdk v0.0.18 h1:eV4pf91MTG1Kho1AiA+9C4JnV9g/yvpyLy1g4JRtOEI=
github.com/kairos-io/kairos-sdk v0.0.18/go.mod h1:17dpFG2d3Q/TcT86DlLK5nNXEjlSrkYl7bsvO2cpYGE=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329 h1:qq2nCpSrXrmvDGRxW0ruW9BVEV1CN2a9YDOExdt+U0o=
github.com/kbinani/screenshot v0.0.0-20210720154843-7d3a670d8329/go.mod h1:2VPVQDR4wO7KXHwP+DAypEy67rXf+okUx2zjgpCxZw4=
github.com/kendru/darwin/go/depgraph v0.0.0-20221105232959-877d6a81060c h1:eKb4PqwAMhlqwXw0W3atpKaYaPGlXE/Fwh+xpCEYaPk=
@ -617,8 +617,8 @@ github.com/ulikunitz/xz v0.5.10/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0o
github.com/ulikunitz/xz v0.5.11 h1:kpFauv27b6ynzBNT/Xy+1k+fK4WswhN/6PN5WhFAGw8=
github.com/ulikunitz/xz v0.5.11/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
github.com/urfave/cli v1.22.12/go.mod h1:sSBEIC79qR6OvcmsD4U3KABeOTxDqQtdDnaFuUN30b8=
github.com/urfave/cli/v2 v2.25.7 h1:VAzn5oq403l5pHjc4OhD54+XGO9cdKVL/7lDjF+iKUs=
github.com/urfave/cli/v2 v2.25.7/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/urfave/cli/v2 v2.26.0 h1:3f3AMg3HpThFNT4I++TKOejZO8yU55t3JnnSr4S4QEI=
github.com/urfave/cli/v2 v2.26.0/go.mod h1:8qnjx1vcq5s2/wpsqoZFndg2CE5tNFyrTvS6SinrnYQ=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ=

18
main.go
View File

@ -5,14 +5,15 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/kairos-io/kairos-agent/v2/pkg/action"
"github.com/kairos-io/kairos-agent/v2/pkg/utils"
"os"
"path/filepath"
"regexp"
"runtime"
"strings"
"github.com/kairos-io/kairos-agent/v2/pkg/action"
"github.com/kairos-io/kairos-agent/v2/pkg/utils"
"github.com/kairos-io/kairos-agent/v2/internal/agent"
"github.com/kairos-io/kairos-agent/v2/internal/bus"
"github.com/kairos-io/kairos-agent/v2/internal/common"
@ -25,6 +26,7 @@ import (
"github.com/kairos-io/kairos-sdk/machine"
"github.com/kairos-io/kairos-sdk/schema"
"github.com/kairos-io/kairos-sdk/state"
"github.com/kairos-io/kairos-sdk/versioneer"
"github.com/sirupsen/logrus"
"github.com/Masterminds/semver/v3"
@ -211,7 +213,7 @@ Manually installs a kairos bundle.
E.g. kairos-agent install-bundle container:quay.io/kairos/kairos...
`,
Aliases: []string{"i"},
Aliases: []string{},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "repository",
@ -278,7 +280,7 @@ E.g. kairos-agent install-bundle container:quay.io/kairos/kairos...
Name: "show",
Usage: "Shows the machine configuration",
Description: "Show the runtime configuration of the machine. It will scan the machine for all the configuration and will return the config file processed and found.",
Aliases: []string{"s"},
Aliases: []string{},
Action: func(c *cli.Context) error {
config, err := agentConfig.Scan(collector.Directories(configScanDir...), collector.NoLogs)
if err != nil {
@ -328,7 +330,7 @@ enabled: true`,
Name: "state",
Usage: "get machine state",
Description: "Print machine state information, e.g. `state get uuid` returns the machine uuid",
Aliases: []string{"s"},
Aliases: []string{},
Action: func(c *cli.Context) error {
runtime, err := state.NewRuntime()
if err != nil {
@ -790,6 +792,12 @@ The validate command expects a configuration file as its only argument. Local fi
},
},
},
{
Name: "versioneer",
Usage: "versioneer subcommands",
Description: "versioneer subcommands",
Subcommands: versioneer.CliCommands(),
},
}
func main() {