Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept []string as commands #64

Merged
merged 3 commits into from
Apr 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions cmd/lambda/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func generateLambdaOptions(c *cli.Context) (*corepb.RunAndWaitOptions, error) {
return nil, errors.New("[Lambda] no commands")
}

commands := c.Args().Slice()
network := c.String("network")

memRequest, err := utils.ParseRAMInHuman(c.String("memory-request"))
Expand All @@ -99,7 +98,7 @@ func generateLambdaOptions(c *cli.Context) (*corepb.RunAndWaitOptions, error) {
Name: "lambda",
Entrypoint: &corepb.EntrypointOptions{
Name: c.String("name"),
Command: strings.Join(commands, " && "),
Commands: c.Args().Slice(),
Privileged: c.Bool("privileged"),
Dir: c.String("working-dir"),
},
Expand Down
2 changes: 1 addition & 1 deletion cmd/workload/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func generateDeployOptions(c *cli.Context) (*corepb.DeployOptions, error) {
Name: specs.Appname,
Entrypoint: &corepb.EntrypointOptions{
Name: entry,
Command: entrypoint.Command,
Commands: entrypoint.GetCommands(),
Privileged: entrypoint.Privileged,
Dir: entrypoint.Dir,
Log: logConfig,
Expand Down
2 changes: 1 addition & 1 deletion cmd/workload/replace.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func generateReplaceOptions(c *cli.Context) (*corepb.DeployOptions, error) {
Name: specs.Appname,
Entrypoint: &corepb.EntrypointOptions{
Name: entry,
Command: entrypoint.Command,
Commands: entrypoint.GetCommands(),
Privileged: entrypoint.Privileged,
Dir: entrypoint.Dir,
Log: logConfig,
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ require (
github.com/juju/testing v0.0.0-20201216035041-2be42bba85f3 // indirect
github.com/kless/term v0.0.0-20161130133337-e551c64f56c0 // indirect
github.com/pkg/term v1.1.0
github.com/projecteru2/core v0.0.0-20210415093154-1f9362198e8a
github.com/projecteru2/core v0.0.0-20210419020340-872926788608
github.com/sethgrid/curse v0.0.0-20181231162520-d4ee583ebf0f
github.com/sethvargo/go-signalcontext v0.1.0
github.com/sirupsen/logrus v1.7.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,8 @@ github.com/projecteru2/core v0.0.0-20210412065234-d0cd929c9739 h1:1KX5LLjQO4iPCR
github.com/projecteru2/core v0.0.0-20210412065234-d0cd929c9739/go.mod h1:K5MyiUV8JDMSTIFE7CHY6TISS+nVTHV71hHl9aMrBdU=
github.com/projecteru2/core v0.0.0-20210412071726-d5e8a01c0b78 h1:4C/kJEGcq1s98ZHSlG39EFAAD3WymEyP7czIUUFw/d4=
github.com/projecteru2/core v0.0.0-20210412071726-d5e8a01c0b78/go.mod h1:K5MyiUV8JDMSTIFE7CHY6TISS+nVTHV71hHl9aMrBdU=
github.com/projecteru2/core v0.0.0-20210415093154-1f9362198e8a h1:JUSljwOZLDnV0B6PW19qc204QcOlNCtVU798flvmLxc=
github.com/projecteru2/core v0.0.0-20210415093154-1f9362198e8a/go.mod h1:K5MyiUV8JDMSTIFE7CHY6TISS+nVTHV71hHl9aMrBdU=
github.com/projecteru2/core v0.0.0-20210419020340-872926788608 h1:tVuf1DTpLiPMTa60CXLUy41xuJeTVV1lXy3rCsPEcw8=
github.com/projecteru2/core v0.0.0-20210419020340-872926788608/go.mod h1:K5MyiUV8JDMSTIFE7CHY6TISS+nVTHV71hHl9aMrBdU=
github.com/projecteru2/libyavirt v0.0.0-20201204100854-3646a3f5f5e5 h1:FxDFP3qtEi0RsnB6X2IpHTdklttamesggNCU7wb6rsY=
github.com/projecteru2/libyavirt v0.0.0-20201204100854-3646a3f5f5e5/go.mod h1:9/SNmdphwl12ubwihkRa9YtOozM6liYLDxsricra1mY=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
Expand Down
6 changes: 6 additions & 0 deletions specs.yaml.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@ appname: "elb"
entrypoints:
release:
cmd: "/usr/local/openresty/bin/openresty -p /elb/server -c /elb/conf/release.conf"
commands:
- /usr/local/openresty/bin/openresty
- -p
- /elb/server
- -c
- /elb/conf/release.conf
restart: always
dir: /elb
publish:
Expand Down
30 changes: 23 additions & 7 deletions types/specs.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
package types

import (
"strings"

"github.com/projecteru2/core/types"
)

// Specs correspond to app.yaml in repository
type Specs struct {
Appname string `yaml:"appname,omitempty"`
Entrypoints map[string]types.Entrypoint `yaml:"entrypoints,omitempty,flow"`
Volumes []string `yaml:"volumes,omitempty,flow"`
VolumesRequest []string `yaml:"volumes_request,omitempty,flow"`
Labels map[string]string `yaml:"labels,omitempty,flow"`
DNS []string `yaml:"dns,omitempty,flow"`
ExtraHosts []string `yaml:"extra_hosts,omitempty,flow"`
Appname string `yaml:"appname,omitempty"`
Entrypoints map[string]Entrypoint `yaml:"entrypoints,omitempty,flow"`
Volumes []string `yaml:"volumes,omitempty,flow"`
VolumesRequest []string `yaml:"volumes_request,omitempty,flow"`
Labels map[string]string `yaml:"labels,omitempty,flow"`
DNS []string `yaml:"dns,omitempty,flow"`
ExtraHosts []string `yaml:"extra_hosts,omitempty,flow"`
}

// Entrypoint is a facade of old stype `cmd` and new stype `commands`
type Entrypoint struct {
types.Entrypoint `yaml:",inline"`
Command string `yaml:"cmd,omitempty"`
}

// GetCommands .
func (e Entrypoint) GetCommands() []string {
if len(e.Commands) > 0 {
return e.Commands
}
return strings.Split(e.Command, " ")
}