exposed cmd api

This commit is contained in:
Jan Halfar 2020-06-25 17:55:55 +02:00
parent 36dd275213
commit b967071b6c
3 changed files with 30 additions and 30 deletions

View File

@ -146,7 +146,7 @@ func squadronGitignore() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/.gitignore", size: 8, mode: os.FileMode(420), modTime: time.Unix(1590781685, 0)}
info := bindataFileInfo{name: "squadron/.gitignore", size: 8, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -166,7 +166,7 @@ func squadronChartsExampleHelmignore() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/.helmignore", size: 342, mode: os.FileMode(420), modTime: time.Unix(1590781685, 0)}
info := bindataFileInfo{name: "squadron/charts/example/.helmignore", size: 342, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -186,7 +186,7 @@ func squadronChartsExampleChartYaml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/Chart.yaml", size: 105, mode: os.FileMode(420), modTime: time.Unix(1593094167, 0)}
info := bindataFileInfo{name: "squadron/charts/example/Chart.yaml", size: 105, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -206,7 +206,7 @@ func squadronChartsExampleTemplates_helpersTpl() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/templates/_helpers.tpl", size: 1045, mode: os.FileMode(420), modTime: time.Unix(1590781685, 0)}
info := bindataFileInfo{name: "squadron/charts/example/templates/_helpers.tpl", size: 1045, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -226,7 +226,7 @@ func squadronChartsExampleTemplatesDeploymentYaml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/templates/deployment.yaml", size: 2057, mode: os.FileMode(420), modTime: time.Unix(1593093613, 0)}
info := bindataFileInfo{name: "squadron/charts/example/templates/deployment.yaml", size: 2057, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -246,7 +246,7 @@ func squadronChartsExampleTemplatesIngressYaml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/templates/ingress.yaml", size: 1001, mode: os.FileMode(420), modTime: time.Unix(1593093613, 0)}
info := bindataFileInfo{name: "squadron/charts/example/templates/ingress.yaml", size: 1001, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -266,7 +266,7 @@ func squadronChartsExampleTemplatesServiceYaml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/templates/service.yaml", size: 470, mode: os.FileMode(420), modTime: time.Unix(1593093613, 0)}
info := bindataFileInfo{name: "squadron/charts/example/templates/service.yaml", size: 470, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -286,7 +286,7 @@ func squadronChartsExampleTemplatesTestsTestConnectionYaml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/templates/tests/test-connection.yaml", size: 555, mode: os.FileMode(420), modTime: time.Unix(1593093613, 0)}
info := bindataFileInfo{name: "squadron/charts/example/templates/tests/test-connection.yaml", size: 555, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -306,7 +306,7 @@ func squadronChartsExampleValuesYaml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/charts/example/values.yaml", size: 1548, mode: os.FileMode(420), modTime: time.Unix(1590781685, 0)}
info := bindataFileInfo{name: "squadron/charts/example/values.yaml", size: 1548, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -326,7 +326,7 @@ func squadronNamespacesLocalHelloGroupYml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/namespaces/local/hello-group.yml", size: 537, mode: os.FileMode(420), modTime: time.Unix(1593093613, 0)}
info := bindataFileInfo{name: "squadron/namespaces/local/hello-group.yml", size: 537, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -346,7 +346,7 @@ func squadronServicesExampleYml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/services/example.yml", size: 513, mode: os.FileMode(420), modTime: time.Unix(1593093613, 0)}
info := bindataFileInfo{name: "squadron/services/example.yml", size: 513, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -366,7 +366,7 @@ func squadronServicesHelloServiceYml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/services/hello-service.yml", size: 235, mode: os.FileMode(420), modTime: time.Unix(1593094012, 0)}
info := bindataFileInfo{name: "squadron/services/hello-service.yml", size: 235, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}
@ -386,7 +386,7 @@ func squadronServicesHiServiceYml() (*asset, error) {
return nil, err
}
info := bindataFileInfo{name: "squadron/services/hi-service.yml", size: 233, mode: os.FileMode(420), modTime: time.Unix(1593094024, 0)}
info := bindataFileInfo{name: "squadron/services/hi-service.yml", size: 233, mode: os.FileMode(420), modTime: time.Unix(1593099856, 0)}
a := &asset{bytes: bytes, info: info}
return a, nil
}

View File

@ -65,7 +65,7 @@ func generateYaml(_ *logrus.Entry, path string, data interface{}) error {
func helmUpdateDependency(l *logrus.Entry, group, groupChartPath string) (string, error) {
l.Infof("Running helm dependency update for group: %v", group)
cmd := []string{"helm", "dependency", "update", groupChartPath}
return command(l, cmd...).run()
return Command(l, cmd...).Run()
}
func helmInstall(l *logrus.Entry, group, namespace, groupChartPath string) (string, error) {
@ -75,7 +75,7 @@ func helmInstall(l *logrus.Entry, group, namespace, groupChartPath string) (stri
"-n", namespace,
"--install",
}
return command(l, cmd...).run()
return Command(l, cmd...).Run()
}
func helmUninstall(l *logrus.Entry, group, namespace string) (string, error) {
@ -86,7 +86,7 @@ func helmUninstall(l *logrus.Entry, group, namespace string) (string, error) {
"-n", namespace,
group,
}
return command(l, cmd...).run()
return Command(l, cmd...).Run()
}
func updateImageOverride(image, tag string, override Override) (Override, error) {

View File

@ -255,7 +255,7 @@ func (c Squadron) Build(s Service) (string, error) {
env := []string{
fmt.Sprintf("TAG=%s", s.Tag),
}
return command(l, args...).cwd(c.config.BasePath).env(env).run()
return Command(l, args...).Cwd(c.config.BasePath).Env(env).Run()
}
func (c Squadron) Push(name string) (string, error) {
@ -268,7 +268,7 @@ func (c Squadron) Push(name string) (string, error) {
l.Infof("Pushing service %v to %s", s.Name, image)
return command(l, "docker", "push", image).cwd(c.config.BasePath).run()
return Command(l, "docker", "push", image).Cwd(c.config.BasePath).Run()
}
func loadService(reader io.Reader, name, defaultTag, basePath string) (Service, error) {
@ -402,7 +402,7 @@ type Cmd struct {
stderrWriters []io.Writer
}
func command(l *logrus.Entry, command ...string) *Cmd {
func Command(l *logrus.Entry, command ...string) *Cmd {
cmd := exec.Command(command[0], command[1:]...)
cmd.Env = os.Environ()
return &Cmd{
@ -412,22 +412,22 @@ func command(l *logrus.Entry, command ...string) *Cmd {
}
}
func (c *Cmd) cwd(path string) *Cmd {
func (c *Cmd) Cwd(path string) *Cmd {
c.cmd.Dir = path
return c
}
func (c *Cmd) env(env []string) *Cmd {
func (c *Cmd) Env(env []string) *Cmd {
c.cmd.Env = append(c.cmd.Env, env...)
return c
}
func (c *Cmd) stdin(r io.Reader) *Cmd {
func (c *Cmd) Stdin(r io.Reader) *Cmd {
c.cmd.Stdin = r
return c
}
func (c *Cmd) stdout(w io.Writer) *Cmd {
func (c *Cmd) Stdout(w io.Writer) *Cmd {
if w == nil {
w, _ = os.Open(os.DevNull)
}
@ -435,7 +435,7 @@ func (c *Cmd) stdout(w io.Writer) *Cmd {
return c
}
func (c *Cmd) stderr(w io.Writer) *Cmd {
func (c *Cmd) Stderr(w io.Writer) *Cmd {
if w == nil {
w, _ = os.Open(os.DevNull)
}
@ -443,32 +443,32 @@ func (c *Cmd) stderr(w io.Writer) *Cmd {
return c
}
func (c *Cmd) timeout(t time.Duration) *Cmd {
func (c *Cmd) Timeout(t time.Duration) *Cmd {
c.t = t
return c
}
func (c *Cmd) noWait() *Cmd {
func (c *Cmd) NoWait() *Cmd {
c.wait = false
return c
}
func (c *Cmd) preStart(f func() error) *Cmd {
func (c *Cmd) PreStart(f func() error) *Cmd {
c.preStartFunc = f
return c
}
func (c *Cmd) postStart(f func() error) *Cmd {
func (c *Cmd) PostStart(f func() error) *Cmd {
c.postStartFunc = f
return c
}
func (c *Cmd) postEnd(f func() error) *Cmd {
func (c *Cmd) PostEnd(f func() error) *Cmd {
c.postEndFunc = f
return c
}
func (c *Cmd) run() (string, error) {
func (c *Cmd) Run() (string, error) {
c.l.Tracef("executing %q", c.cmd.String())
combinedBuf := new(bytes.Buffer)