Skip to content

Commit

Permalink
Add --enable-group, --disable-group flags on command run
Browse files Browse the repository at this point in the history
  • Loading branch information
geaaru committed Dec 9, 2024
1 parent 5b87426 commit 626670a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
9 changes: 9 additions & 0 deletions cmd/command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ func NewRunCommand(config *specs.SshComposeConfig) *cobra.Command {
var envs []string
var renderEnvs []string
var varsFiles []string
var enabledGroups []string
var disabledGroups []string

var cmd = &cobra.Command{
Use: "run <project> <command>",
Expand Down Expand Up @@ -115,6 +117,9 @@ func NewRunCommand(config *specs.SshComposeConfig) *cobra.Command {
" on project " + pname)
}

command.SetDisableGroups(disabledGroups)
command.SetEnableGroups(enabledGroups)

err = ApplyCommand(command, composer,
env.GetProjectByName(pname),
envs, varsFiles,
Expand All @@ -128,6 +133,10 @@ func NewRunCommand(config *specs.SshComposeConfig) *cobra.Command {
}

var flags = cmd.Flags()
flags.StringSliceVar(&disabledGroups, "disable-group", []string{},
"Skip selected group from deploy.")
flags.StringSliceVar(&enabledGroups, "enable-group", []string{},
"Apply only selected groups.")
flags.StringArrayVar(&renderEnvs, "render-env", []string{},
"Append render engine environments in the format key=value.")
flags.StringArrayVar(&envs, "env", []string{},
Expand Down
24 changes: 13 additions & 11 deletions pkg/specs/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,19 @@ import (
"gopkg.in/yaml.v3"
)

func (c *SshCCommand) GetName() string { return c.Name }
func (c *SshCCommand) GetDescription() string { return c.Description }
func (c *SshCCommand) GetProject() string { return c.Project }
func (c *SshCCommand) GetEnvs() SshCEnvVars { return c.Envs }
func (c *SshCCommand) GetEnableFlags() []string { return c.EnableFlags }
func (c *SshCCommand) GetDisableFlags() []string { return c.DisableFlags }
func (c *SshCCommand) GetEnableGroups() []string { return c.EnableGroups }
func (c *SshCCommand) GetDisableGroups() []string { return c.DisableFlags }
func (c *SshCCommand) GetVarFiles() []string { return c.VarFiles }
func (c *SshCCommand) GetSkipSync() bool { return c.SkipSync }
func (c *SshCCommand) GetDestroy() bool { return c.Destroy }
func (c *SshCCommand) GetName() string { return c.Name }
func (c *SshCCommand) GetDescription() string { return c.Description }
func (c *SshCCommand) GetProject() string { return c.Project }
func (c *SshCCommand) GetEnvs() SshCEnvVars { return c.Envs }
func (c *SshCCommand) GetEnableFlags() []string { return c.EnableFlags }
func (c *SshCCommand) GetDisableFlags() []string { return c.DisableFlags }
func (c *SshCCommand) GetEnableGroups() []string { return c.EnableGroups }
func (c *SshCCommand) GetDisableGroups() []string { return c.DisableFlags }
func (c *SshCCommand) GetVarFiles() []string { return c.VarFiles }
func (c *SshCCommand) GetSkipSync() bool { return c.SkipSync }
func (c *SshCCommand) GetDestroy() bool { return c.Destroy }
func (c *SshCCommand) SetEnableGroups(list []string) { c.EnableGroups = list }
func (c *SshCCommand) SetDisableGroups(list []string) { c.DisableGroups = list }

func CommandFromYaml(data []byte) (*SshCCommand, error) {
ans := &SshCCommand{}
Expand Down

0 comments on commit 626670a

Please sign in to comment.