mirror of
https://github.com/foomo/squadron.git
synced 2025-10-16 12:35:42 +00:00
feat: add push command
This commit is contained in:
parent
31bb559e47
commit
c8e02ecdd2
65
cmd/actions/push.go
Normal file
65
cmd/actions/push.go
Normal file
@ -0,0 +1,65 @@
|
||||
package actions
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"github.com/foomo/squadron"
|
||||
)
|
||||
|
||||
func init() {
|
||||
pushCmd.Flags().StringVarP(&flagNamespace, "namespace", "n", "default", "specifies the namespace")
|
||||
pushCmd.Flags().BoolVarP(&flagBuild, "build", "b", false, "builds or rebuilds units")
|
||||
}
|
||||
|
||||
var pushCmd = &cobra.Command{
|
||||
Use: "push [UNIT...]",
|
||||
Short: "pushes the squadron or given units",
|
||||
Example: " squadron push frontend backend --namespace demo --build",
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return push(args, cwd, flagNamespace, flagBuild, flagFiles)
|
||||
},
|
||||
}
|
||||
|
||||
func push(args []string, cwd, namespace string, build bool, files []string) error {
|
||||
sq := squadron.New(cwd, namespace, files)
|
||||
|
||||
if err := sq.MergeConfigFiles(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
unitsNames, err := parseUnitNames(args, sq.GetConfig().Units)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if unitsNames != nil {
|
||||
if err := sq.FilterConfig(unitsNames); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
if err := sq.RenderConfig(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
units, err := parseUnitArgs(args, sq.GetConfig().Units)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if build {
|
||||
for _, unit := range units {
|
||||
if err := unit.Build(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, unit := range units {
|
||||
if err := unit.Push(); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@ -41,7 +41,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().BoolVarP(&flagVerbose, "verbose", "v", false, "show more output")
|
||||
rootCmd.PersistentFlags().StringSliceVarP(&flagFiles, "file", "f", []string{"squadron.yaml"}, "specify alternative squadron files")
|
||||
|
||||
rootCmd.AddCommand(upCmd, downCmd, buildCmd, listCmd, generateCmd, configCmd, versionCmd, completionCmd, templateCmd)
|
||||
rootCmd.AddCommand(upCmd, downCmd, buildCmd, pushCmd, listCmd, generateCmd, configCmd, versionCmd, completionCmd, templateCmd)
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user