Remove config show in favor of parent command (#281)

* Remove config show in favor of parent command

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

* add deprecation warning

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>

---------

Signed-off-by: Mauro Morales <mauro.morales@spectrocloud.com>
This commit is contained in:
Mauro Morales 2024-04-09 10:08:28 +02:00 committed by GitHub
parent b83e0433fd
commit d4e73caa28
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

23
main.go
View File

@ -5,16 +5,17 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"github.com/kairos-io/kairos-agent/v2/pkg/action"
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
"github.com/kairos-io/kairos-agent/v2/pkg/utils"
"github.com/mudler/go-pluggable"
"os" "os"
"path/filepath" "path/filepath"
"regexp" "regexp"
"runtime" "runtime"
"strings" "strings"
"github.com/kairos-io/kairos-agent/v2/pkg/action"
"github.com/kairos-io/kairos-agent/v2/pkg/constants"
"github.com/kairos-io/kairos-agent/v2/pkg/utils"
"github.com/mudler/go-pluggable"
"github.com/kairos-io/kairos-agent/v2/internal/agent" "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/bus"
"github.com/kairos-io/kairos-agent/v2/internal/common" "github.com/kairos-io/kairos-agent/v2/internal/common"
@ -303,23 +304,27 @@ E.g. kairos-agent install-bundle container:quay.io/kairos/kairos...
}, },
{ {
Name: "config", Name: "config",
Usage: "get machine configuration", Usage: "Shows the machine configuration",
Description: "Print machine state information, e.g. `state get uuid` returns the machine uuid", 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{"c"}, Aliases: []string{"c"},
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
runtime, err := state.NewRuntime() config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)
if err != nil { if err != nil {
return err return err
} }
fmt.Print(runtime) configStr, err := config.String()
if err != nil {
return err return err
}
fmt.Printf("%s", configStr)
return nil
}, },
Subcommands: []*cli.Command{ Subcommands: []*cli.Command{
{ {
Name: "show", Name: "show",
Usage: "Shows the machine configuration", 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.", Description: "WARNING this command will be deprecated in v3.2.0. Use `config` without a subcommand instead.\n\n 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{}, Aliases: []string{},
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs) config, err := agentConfig.Scan(collector.Directories(constants.GetConfigScanDirs()...), collector.NoLogs)