Skip to content

Commit

Permalink
Update config descriptions and list
Browse files Browse the repository at this point in the history
  • Loading branch information
carabasdaniel committed Apr 18, 2024
1 parent 980d021 commit dee7320
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
20 changes: 11 additions & 9 deletions pkg/cli/cmd/configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
)

type ConfigCmd struct {
Use UseConfigCmd `cmd:"" help:"set topaz CLI to use a configuration file"`
New ConfigureCmd `cmd:"" help:"generate new configuration file"`
List ListConfigCmd `cmd:"" help:"list configuration files"`
Rename RenameConfigCmd `cmd:"" help:"rename a topaz configuration"`
Delete DeleteConfigCmd `cmd:"" help:"delete a topaz configuration"`
Use UseConfigCmd `cmd:"" help:"set active configuration"`
New ConfigureCmd `cmd:"" help:"generate new configuration"`
List ListConfigCmd `cmd:"" help:"list configurations"`
Rename RenameConfigCmd `cmd:"" help:"rename configuration"`
Delete DeleteConfigCmd `cmd:"" help:"delete configuration"`
}

func (cmd *ConfigCmd) Run(c *cc.CommonCtx) error {
Expand Down Expand Up @@ -168,7 +168,7 @@ type ListConfigCmd struct {
}

func (cmd ListConfigCmd) Run(c *cc.CommonCtx) error {
table := c.UI.Normal().WithTable("Name", "Config File", "Is Default")
table := c.UI.Normal().WithTable("", "Name", "Config File")
files, err := os.ReadDir(cmd.ConfigDir)
if err != nil {
if os.IsNotExist(err) {
Expand All @@ -177,11 +177,13 @@ func (cmd ListConfigCmd) Run(c *cc.CommonCtx) error {
return err
}
for i := range files {
active := false
name := strings.Split(files[i].Name(), ".")[0]
active := ""
if files[i].Name() == filepath.Base(c.Config.TopazConfigFile) {
active = true
active = "*"
}
table.WithTableRow(strings.Replace(files[i].Name(), ".yaml", "", -1), files[i].Name(), fmt.Sprintf("%v", active))

table.WithTableRow(active, name, files[i].Name())
}
table.Do()

Expand Down
12 changes: 6 additions & 6 deletions pkg/cli/cmd/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type InstallTemplateCmd struct {
ContainerHostname string `optional:"" name:"hostname" default:"" env:"CONTAINER_HOSTNAME" help:"hostname for docker to set"`
TemplatesURL string `arg:"" required:"false" default:"https://topaz.sh/assets/templates/templates.json" help:"URL of template catalog"`
ContainerVersion string `optional:"" hidden:"" default:"" env:"CONTAINER_VERSION"`
CustomName string `optional:"" help:"set custom name for template"`
ConfigName string `optional:"" help:"set config name for template"`
clients.Config
}

Expand All @@ -83,8 +83,8 @@ func (cmd *InstallTemplateCmd) Run(c *cc.CommonCtx) error {
}
}
fileName := fmt.Sprintf("%s.yaml", tmpl.Name)
if cmd.CustomName != "" {
fileName = fmt.Sprintf("%s.yaml", cmd.CustomName)
if cmd.ConfigName != "" {
fileName = fmt.Sprintf("%s.yaml", cmd.ConfigName)
}

// reset defaults on template install
Expand Down Expand Up @@ -132,7 +132,7 @@ func (cmd *InstallTemplateCmd) installTemplate(c *cc.CommonCtx, tmpl *template)

cmd.Config.Insecure = true
// 1-3 - stop topaz, configure, start
err = cmd.prepareTopaz(c, tmpl, cmd.CustomName)
err = cmd.prepareTopaz(c, tmpl, cmd.ConfigName)
if err != nil {
return err
}
Expand All @@ -153,13 +153,13 @@ func (cmd *InstallTemplateCmd) installTemplate(c *cc.CommonCtx, tmpl *template)
}

// 5-7 - reset directory, apply (manifest, IDP and domain data) template.
if err := installTemplate(c, tmpl, topazDir, &cmd.Config, cmd.CustomName).Install(); err != nil {
if err := installTemplate(c, tmpl, topazDir, &cmd.Config, cmd.ConfigName).Install(); err != nil {
return err
}

// 8 - run tests
if !cmd.NoTests {
if err := installTemplate(c, tmpl, topazDir, &cmd.Config, cmd.CustomName).Test(); err != nil {
if err := installTemplate(c, tmpl, topazDir, &cmd.Config, cmd.ConfigName).Test(); err != nil {
return err
}
}
Expand Down

0 comments on commit dee7320

Please sign in to comment.