From 43839d10904624dae987a28eabbc6e1f12c65ebd Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sun, 5 May 2019 10:37:53 -0400 Subject: [PATCH] all: Switch the --lang syntax to use argv instead It was a bit awkward using `mgmt run lang --lang ` so instead, we now drop the --lang, and read the positional argv for the input. This also does the same for the --yaml frontend. --- docs/documentation.md | 4 ---- docs/faq.md | 2 +- docs/puppet-guide.md | 2 +- docs/quick-start-guide.md | 6 +++--- examples/lang/env0.mcl | 2 +- examples/lang/exchange0.mcl | 2 +- examples/lang/regexp0.mcl | 4 ++-- integration/instance.go | 2 +- lang/funcs/core/world/schedule_func.go | 6 +++--- lang/gapi.go | 27 ++++++++++++++++---------- langpuppet/gapi.go | 15 ++++++++++++++ puppet/gapi.go | 14 ++++++------- test/omv/pkg1a.yaml | 2 +- test/omv/pkg1b.yaml | 2 +- test/shell/augeas-1.sh | 2 +- test/shell/env0.sh | 2 +- test/shell/exchange.sh | 2 +- test/shell/exchange0.mcl | 2 +- test/shell/exec-fail.sh | 2 +- test/shell/exec-usergroup.sh | 2 +- test/shell/file-mode.sh | 2 +- test/shell/file-move-upper-dir.sh | 2 +- test/shell/file-move.sh | 2 +- test/shell/file-owner.sh | 2 +- test/shell/file-source.sh | 2 +- test/shell/graph-exit1.sh | 2 +- test/shell/graph-exit2.sh | 2 +- test/shell/graph-fanin-1.sh | 2 +- test/shell/load0.sh | 2 +- test/shell/net.sh | 4 ++-- test/shell/prometheus-3.sh | 2 +- test/shell/prometheus-4.sh | 2 +- test/shell/sema-1.sh | 2 +- test/shell/sema-2.sh | 2 +- test/shell/t2.sh | 2 +- test/shell/t3.sh | 6 +++--- test/shell/t5.sh | 2 +- test/shell/t5b.sh | 2 +- test/shell/t6.sh | 2 +- test/shell/yaml-change1.sh | 2 +- vagrant/motd | 2 +- yamlgraph/gapi.go | 19 ++++++++---------- 42 files changed, 91 insertions(+), 78 deletions(-) diff --git a/docs/documentation.md b/docs/documentation.md index b6224926..5e0d099c 100644 --- a/docs/documentation.md +++ b/docs/documentation.md @@ -298,10 +298,6 @@ recommended that you use this, since it's preferable to write code in the The main interface to the `mgmt` tool is the command line. For the most recent documentation, please run `mgmt --help`. -#### `--yaml ` - -Point to a graph file to run. - #### `--converged-timeout ` Exit if the machine has converged for approximately this many seconds. diff --git a/docs/faq.md b/docs/faq.md index deda3840..6702fc1f 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -212,7 +212,7 @@ requires a number of seconds as an argument. #### Example: ``` -./mgmt run lang --lang examples/lang/hello0.mcl --converged-timeout=5 +./mgmt run lang examples/lang/hello0.mcl --converged-timeout=5 ``` ### On startup `mgmt` hangs after: `etcd: server: starting...`. diff --git a/docs/puppet-guide.md b/docs/puppet-guide.md index 6ee52a08..46ec486f 100644 --- a/docs/puppet-guide.md +++ b/docs/puppet-guide.md @@ -173,7 +173,7 @@ useful when you are in the process of replacing Puppet with mgmt. You can translate your custom modules into mgmt's language one by one, and let mgmt run the current mix. -Instead of the usual `--puppet`, `--puppet-conf`, and `--lang` for mcl, +Instead of the usual `--puppet-conf` flag and argv for `puppet` and `mcl` input, you need to use alternative flags to make this work: * `--lp-lang` to specify the mcl input diff --git a/docs/quick-start-guide.md b/docs/quick-start-guide.md index 15925a09..38d80b8b 100644 --- a/docs/quick-start-guide.md +++ b/docs/quick-start-guide.md @@ -57,8 +57,8 @@ export PATH=$PATH:$GOPATH/bin ### Running mgmt -* Run `time ./mgmt run --tmp-prefix lang --lang examples/lang/hello0.mcl` to try -out a very simple example! +* Run `time ./mgmt run --tmp-prefix lang examples/lang/hello0.mcl` to try out a +very simple example! * Look in that example file that you ran to see if you can figure out what it did! * Have fun hacking on our future technology and get involved to shape the @@ -181,5 +181,5 @@ Other examples: ``` docker/scripts/exec-development make build -docker/scripts/exec-development ./mgmt run --tmp-prefix lang --lang examples/lang/load0.mcl +docker/scripts/exec-development ./mgmt run --tmp-prefix lang examples/lang/load0.mcl ``` diff --git a/examples/lang/env0.mcl b/examples/lang/env0.mcl index 67bc4fe1..aa775cee 100644 --- a/examples/lang/env0.mcl +++ b/examples/lang/env0.mcl @@ -1,5 +1,5 @@ # read and print environment variable -# env TEST=123 EMPTY= ./mgmt run --tmp-prefix --converged-timeout=5 lang --lang=examples/lang/env0.mcl +# env TEST=123 EMPTY= ./mgmt run --tmp-prefix --converged-timeout=5 lang examples/lang/env0.mcl import "fmt" import "sys" diff --git a/examples/lang/exchange0.mcl b/examples/lang/exchange0.mcl index 9e855ce6..7c020ed8 100644 --- a/examples/lang/exchange0.mcl +++ b/examples/lang/exchange0.mcl @@ -4,7 +4,7 @@ # time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty # time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty # time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty -# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang --lang examples/lang/exchange0.mcl +# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang examples/lang/exchange0.mcl import "sys" import "world" diff --git a/examples/lang/regexp0.mcl b/examples/lang/regexp0.mcl index 4bbaa6c0..537177ad 100644 --- a/examples/lang/regexp0.mcl +++ b/examples/lang/regexp0.mcl @@ -2,8 +2,8 @@ import "fmt" import "regexp" # test with: -# ./mgmt run --hostname foo.example.com --tmp-prefix lang --lang examples/lang/regexp0.mcl -# ./mgmt run --hostname db1.example.com --tmp-prefix lang --lang examples/lang/regexp0.mcl +# ./mgmt run --hostname foo.example.com --tmp-prefix lang examples/lang/regexp0.mcl +# ./mgmt run --hostname db1.example.com --tmp-prefix lang examples/lang/regexp0.mcl print "regexp" { # TODO: add a heredoc string to avoid needing to escape the \ chars msg => fmt.printf("match: %t", regexp.match("^db\\d+\\.example\\.com$", $hostname)), diff --git a/integration/instance.go b/integration/instance.go index 29dfc065..0e6b6e6c 100644 --- a/integration/instance.go +++ b/integration/instance.go @@ -373,7 +373,7 @@ func (obj *Instance) DeployLang(code string) error { "deploy", // mode "--no-git", "--seeds", obj.clientURL, - "lang", "--lang", filename, + "lang", filename, } obj.Logf("run: %s %s", cmdName, strings.Join(cmdArgs, " ")) cmd := exec.Command(cmdName, cmdArgs...) diff --git a/lang/funcs/core/world/schedule_func.go b/lang/funcs/core/world/schedule_func.go index feeb1e4d..a0338641 100644 --- a/lang/funcs/core/world/schedule_func.go +++ b/lang/funcs/core/world/schedule_func.go @@ -16,9 +16,9 @@ // along with this program. If not, see . // test with: -// time ./mgmt run --hostname h1 --tmp-prefix --no-pgp lang --lang examples/lang/schedule0.mcl -// time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang --lang examples/lang/schedule0.mcl -// time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang --lang examples/lang/schedule0.mcl +// time ./mgmt run --hostname h1 --tmp-prefix --no-pgp lang examples/lang/schedule0.mcl +// time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang examples/lang/schedule0.mcl +// time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang examples/lang/schedule0.mcl // kill h2 (should see h1 and h3 pick [h1, h3] instead) // restart h2 (should see [h1, h3] as before) // kill h3 (should see h1 and h2 pick [h1, h2] instead) diff --git a/lang/gapi.go b/lang/gapi.go index bed43fe1..f7b6fc3f 100644 --- a/lang/gapi.go +++ b/lang/gapi.go @@ -110,11 +110,6 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag { fallthrough case gapi.CommandDeploy: flags := []cli.Flag{ - cli.StringFlag{ - Name: fmt.Sprintf("%s, %s", Name, Name[0:1]), - Value: "", - Usage: "code to deploy", - }, // TODO: removed (temporarily?) //cli.BoolFlag{ // Name: "stdin", @@ -157,9 +152,13 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { cliInfo.Logf(Name+": "+format, v...) } - if !c.IsSet(Name) { - return nil, nil // we weren't activated! + if l := c.NArg(); l != 1 { + if l > 1 { + return nil, fmt.Errorf("input program must be a single arg") + } + return nil, fmt.Errorf("must specify input program") } + input := c.Args().Get(0) // empty by default (don't set for deploy, only download) modules := c.String(flagModulePath) @@ -180,7 +179,7 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { // the fs input here is the local fs we're reading to get the files from // this is different from the fs variable which is our output dest!!! - output, err := parseInput(c.String(Name), localFs) + output, err := parseInput(input, localFs) if err != nil { return nil, errwrap.Wrapf(err, "could not activate an input parser") } @@ -356,7 +355,7 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { // display the deploy fs tree if debug || true { // TODO: should this only be shown on debug? - logf("input: %s", c.String(Name)) + logf("input: %s", input) tree, err := util.FsTree(fs, "/") if err != nil { return nil, err @@ -587,6 +586,14 @@ func (obj *GAPI) Get(getInfo *gapi.GetInfo) error { debug := getInfo.Debug logf := getInfo.Logf + if l := c.NArg(); l != 1 { + if l > 1 { + return fmt.Errorf("input program must be a single arg") + } + return fmt.Errorf("must specify input program") + } + input := c.Args().Get(0) + // empty by default (don't set for deploy, only download) modules := c.String(flagModulePath) if modules != "" && (!strings.HasPrefix(modules, "/") || !strings.HasSuffix(modules, "/")) { @@ -603,7 +610,7 @@ func (obj *GAPI) Get(getInfo *gapi.GetInfo) error { // the fs input here is the local fs we're reading to get the files from // this is different from the fs variable which is our output dest!!! - output, err := parseInput(c.String(Name), localFs) + output, err := parseInput(input, localFs) if err != nil { return errwrap.Wrapf(err, "could not activate an input parser") } diff --git a/langpuppet/gapi.go b/langpuppet/gapi.go index 251e0b81..d0b80a39 100644 --- a/langpuppet/gapi.go +++ b/langpuppet/gapi.go @@ -73,6 +73,19 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag { langFlags := (&lang.GAPI{}).CliFlags(command) puppetFlags := (&puppet.GAPI{}).CliFlags(command) + l := cli.StringFlag{ + Name: fmt.Sprintf("%s, %s", lang.Name, lang.Name[0:1]), + Value: "", + Usage: "code to deploy", + } + langFlags = append(langFlags, l) + p := cli.StringFlag{ + Name: fmt.Sprintf("%s, %s", puppet.Name, puppet.Name[0:1]), + Value: "", + Usage: "load graph from puppet, optionally takes a manifest or path to manifest file", + } + puppetFlags = append(puppetFlags, p) + var childFlags []cli.Flag for _, flag := range append(langFlags, puppetFlags...) { childFlags = append(childFlags, &cli.StringFlag{ @@ -121,12 +134,14 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { var langDeploy *gapi.Deploy var puppetDeploy *gapi.Deploy + // XXX: put the c.String(FlagPrefix+lang.Name) into the argv here! langCliInfo := &gapi.CliInfo{ CliContext: cli.NewContext(c.App, flagSet, c.Parent()), Fs: fs, Debug: debug, Logf: logf, // TODO: wrap logf? } + // XXX: put the c.String(FlagPrefix+puppet.Name) into the argv here! puppetCliInfo := &gapi.CliInfo{ CliContext: cli.NewContext(c.App, flagSet, c.Parent()), Fs: fs, diff --git a/puppet/gapi.go b/puppet/gapi.go index f3ffb4dd..ce8d5664 100644 --- a/puppet/gapi.go +++ b/puppet/gapi.go @@ -70,11 +70,6 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag { fallthrough case gapi.CommandDeploy: return []cli.Flag{ - cli.StringFlag{ - Name: "puppet, p", - Value: "", - Usage: "load graph from puppet, optionally takes a manifest or path to manifest file", - }, cli.StringFlag{ Name: "puppet-conf", Value: "", @@ -99,10 +94,13 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { // cliInfo.Logf(Name + ": "+format, v...) //} - if !c.IsSet(Name) { - return nil, nil // we weren't activated! + if l := c.NArg(); l != 1 { + if l > 1 { + return nil, fmt.Errorf("input program must be a single arg") + } + return nil, fmt.Errorf("must specify input program") } - s := c.String(Name) + s := c.Args().Get(0) if s == "" { return nil, fmt.Errorf("%s input is empty", Name) } diff --git a/test/omv/pkg1a.yaml b/test/omv/pkg1a.yaml index e2501845..ccb02856 100644 --- a/test/omv/pkg1a.yaml +++ b/test/omv/pkg1a.yaml @@ -32,7 +32,7 @@ - iptables -F - cd /vagrant/mgmt/ && make path - cd /vagrant/mgmt/ && make deps && make build && cp mgmt ~/bin/ - - cd && mgmt run --converged-timeout=5 yaml --yaml /vagrant/mgmt/examples/pkg1.yaml + - cd && mgmt run --converged-timeout=5 yaml /vagrant/mgmt/examples/pkg1.yaml :namespace: omv :count: 0 :username: '' diff --git a/test/omv/pkg1b.yaml b/test/omv/pkg1b.yaml index 11d91446..ea08c52b 100644 --- a/test/omv/pkg1b.yaml +++ b/test/omv/pkg1b.yaml @@ -33,7 +33,7 @@ - iptables -F - cd /vagrant/mgmt/ && make path - cd /vagrant/mgmt/ && make deps && make build && cp mgmt ~/bin/ - - cd && mgmt run --converged-timeout=5 yaml --yaml /vagrant/mgmt/examples/pkg1.yaml + - cd && mgmt run --converged-timeout=5 yaml /vagrant/mgmt/examples/pkg1.yaml :namespace: omv :count: 0 :username: '' diff --git a/test/shell/augeas-1.sh b/test/shell/augeas-1.sh index fde2108c..10da72f1 100755 --- a/test/shell/augeas-1.sh +++ b/test/shell/augeas-1.sh @@ -5,7 +5,7 @@ mkdir -p "${MGMT_TMPDIR}" echo > "${MGMT_TMPDIR}"sshd_config -$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=augeas-1.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix yaml augeas-1.yaml & pid=$! # kill server on error diff --git a/test/shell/env0.sh b/test/shell/env0.sh index f10370ee..bf72a094 100755 --- a/test/shell/env0.sh +++ b/test/shell/env0.sh @@ -14,7 +14,7 @@ if [[ ! "$tmpdir" =~ "/tmp" ]]; then exit 99 fi -env TMPDIR="${tmpdir}" TEST=123 EMPTY="" $TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=5 lang --lang env0.mcl +env TMPDIR="${tmpdir}" TEST=123 EMPTY="" $TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=5 lang env0.mcl e=$? egrep "$regex" "$tmpdir/environ" || fail_test "Could not match '$(cat "$tmpdir/environ")' in '$tmpdir/environ' to '$regex'." diff --git a/test/shell/exchange.sh b/test/shell/exchange.sh index c2a48836..a9852796 100755 --- a/test/shell/exchange.sh +++ b/test/shell/exchange.sh @@ -17,7 +17,7 @@ sleep 10s $TIMEOUT "$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty & pid4=$! sleep 10s -$TIMEOUT "$MGMT" deploy --no-git --seeds http://127.0.0.1:2379 lang --lang exchange0.mcl +$TIMEOUT "$MGMT" deploy --no-git --seeds http://127.0.0.1:2379 lang exchange0.mcl # kill servers on error/exit #trap 'pkill -9 mgmt' EXIT diff --git a/test/shell/exchange0.mcl b/test/shell/exchange0.mcl index 9e855ce6..7c020ed8 100644 --- a/test/shell/exchange0.mcl +++ b/test/shell/exchange0.mcl @@ -4,7 +4,7 @@ # time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty # time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty # time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty -# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang --lang examples/lang/exchange0.mcl +# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang examples/lang/exchange0.mcl import "sys" import "world" diff --git a/test/shell/exec-fail.sh b/test/shell/exec-fail.sh index c4701b44..154a6756 100755 --- a/test/shell/exec-fail.sh +++ b/test/shell/exec-fail.sh @@ -5,7 +5,7 @@ # should take a few seconds plus converged timeout, and test we don't hang! # TODO: should we return a different exit code if the resources fail? # TODO: should we be converged if one of the resources has permanently failed? -$TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --no-pgp --tmp-prefix yaml --yaml exec-fail.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --no-pgp --tmp-prefix yaml exec-fail.yaml & # there's no ^C sent... it should shutdown on its own pid=$! wait $pid # get exit status diff --git a/test/shell/exec-usergroup.sh b/test/shell/exec-usergroup.sh index dd17f448..63095a4c 100755 --- a/test/shell/exec-usergroup.sh +++ b/test/shell/exec-usergroup.sh @@ -40,7 +40,7 @@ function run_usergroup_test() { setup # run till completion - sudo -A $TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --tmp-prefix yaml --yaml ./exec-usergroup/${graph} & + sudo -A $TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --tmp-prefix yaml ./exec-usergroup/${graph} & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/file-mode.sh b/test/shell/file-mode.sh index 010b13e5..692fbcc5 100755 --- a/test/shell/file-mode.sh +++ b/test/shell/file-mode.sh @@ -5,7 +5,7 @@ set -x # run till completion -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-mode.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml file-mode.yaml & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/file-move-upper-dir.sh b/test/shell/file-move-upper-dir.sh index 7de580c4..31feeb8b 100755 --- a/test/shell/file-move-upper-dir.sh +++ b/test/shell/file-move-upper-dir.sh @@ -9,7 +9,7 @@ exit 0 mkdir -p /tmp/mgmt/a/b/c/ # run empty graph, with prometheus support -$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=examples/deep-dirs.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix yaml examples/deep-dirs.yaml & pid=$! sleep 10s # let it converge diff --git a/test/shell/file-move.sh b/test/shell/file-move.sh index a90b73c5..dad9bbe2 100755 --- a/test/shell/file-move.sh +++ b/test/shell/file-move.sh @@ -6,7 +6,7 @@ mkdir -p /tmp/mgmt/ rm /tmp/mgmt/f1 &>/dev/null || true # run empty graph, with prometheus support -$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=file-move.yaml 2>&1 | tee /tmp/mgmt/file-move.log & +$TIMEOUT "$MGMT" run --tmp-prefix yaml file-move.yaml 2>&1 | tee /tmp/mgmt/file-move.log & pid=$! sleep 5s # let it converge diff --git a/test/shell/file-owner.sh b/test/shell/file-owner.sh index 37e68aa2..8c1a0d53 100755 --- a/test/shell/file-owner.sh +++ b/test/shell/file-owner.sh @@ -11,7 +11,7 @@ if ! timeout 1s sudo -A true; then fi # run till completion -$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-owner.yaml & +$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml file-owner.yaml & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/file-source.sh b/test/shell/file-source.sh index 95862231..f93ff9b1 100755 --- a/test/shell/file-source.sh +++ b/test/shell/file-source.sh @@ -11,7 +11,7 @@ if ! timeout 1s sudo -A true; then fi # run till completion -$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix lang --lang file-source.mcl & +$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix lang file-source.mcl & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/graph-exit1.sh b/test/shell/graph-exit1.sh index 0e74be0f..e343c1d2 100755 --- a/test/shell/graph-exit1.sh +++ b/test/shell/graph-exit1.sh @@ -5,7 +5,7 @@ # should take 15 seconds for longest resources plus startup time to shutdown # we don't want the ^C to allow the rest of the graph to continue executing! # this is a test of mgmt exiting quickly via a fast pause after it sees a ^C -$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix lang --lang graph-exit1.mcl & +$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix lang graph-exit1.mcl & pid=$! sleep 5s # let the initial resources start to run... killall -SIGINT mgmt # send ^C to exit mgmt diff --git a/test/shell/graph-exit2.sh b/test/shell/graph-exit2.sh index 04293f13..d192bb49 100755 --- a/test/shell/graph-exit2.sh +++ b/test/shell/graph-exit2.sh @@ -4,7 +4,7 @@ # should take 15 seconds for longest resources plus startup time to shutdown # we don't want the ^C to allow the rest of the graph to continue executing! -$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml --yaml graph-exit2.yaml & +$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml graph-exit2.yaml & pid=$! sleep 10s # let the initial resources start to run... killall -SIGINT mgmt # send ^C to exit mgmt diff --git a/test/shell/graph-fanin-1.sh b/test/shell/graph-fanin-1.sh index 86be03ea..07288b08 100755 --- a/test/shell/graph-fanin-1.sh +++ b/test/shell/graph-fanin-1.sh @@ -3,7 +3,7 @@ . "$(dirname "$0")/../util.sh" # should take more than 25s plus overhead -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix --no-pgp yaml --yaml graph-fanin-1.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix --no-pgp yaml graph-fanin-1.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/load0.sh b/test/shell/load0.sh index ac42bed0..8ea8c5b4 100755 --- a/test/shell/load0.sh +++ b/test/shell/load0.sh @@ -37,7 +37,7 @@ file "${tmpdir}/loadavg" { } EOF -$TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=15 lang --lang "$tmpdir/load0.mcl" & +$TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=15 lang "$tmpdir/load0.mcl" & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/net.sh b/test/shell/net.sh index aee92d05..d95ec2cc 100755 --- a/test/shell/net.sh +++ b/test/shell/net.sh @@ -52,7 +52,7 @@ sudo mkdir -p /etc/systemd/network sudo ip link add $IFACE type dummy || true # run mgmt net res with $IFACE and $ADDR set as above -sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net0.mcl & +sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang ./net0.mcl & pid1=$! # give the engine time to start up @@ -93,7 +93,7 @@ wait $pid1 e1=$? # run mgmt net res with $IFACE state => "down" -sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net1.mcl & +sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang ./net1.mcl & # give the engine time to start up sleep 5 diff --git a/test/shell/prometheus-3.sh b/test/shell/prometheus-3.sh index 9ea16fc8..5a34d9b5 100755 --- a/test/shell/prometheus-3.sh +++ b/test/shell/prometheus-3.sh @@ -5,7 +5,7 @@ exit 0 # XXX: temporarily disabled until prometheus is added back post refactor # run a graph, with prometheus support -$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-3.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml prometheus-3.yaml & pid=$! sleep 10s # let it converge diff --git a/test/shell/prometheus-4.sh b/test/shell/prometheus-4.sh index 5d3df310..f8b36047 100755 --- a/test/shell/prometheus-4.sh +++ b/test/shell/prometheus-4.sh @@ -5,7 +5,7 @@ exit 0 # XXX: temporarily disabled until prometheus is added back post refactor # run a graph, with prometheus support -$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-4.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml prometheus-4.yaml & pid=$! sleep 15s # let it converge diff --git a/test/shell/sema-1.sh b/test/shell/sema-1.sh index 14d01e1b..7eb725a0 100755 --- a/test/shell/sema-1.sh +++ b/test/shell/sema-1.sh @@ -4,7 +4,7 @@ # should take at least 55s, but fail if we block this # TODO: it would be nice to make sure this test doesn't exit too early! -$TIMEOUT "$MGMT" run --sema 2 --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml sema-1.yaml & +$TIMEOUT "$MGMT" run --sema 2 --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml sema-1.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/sema-2.sh b/test/shell/sema-2.sh index 79275042..a3a0e977 100755 --- a/test/shell/sema-2.sh +++ b/test/shell/sema-2.sh @@ -4,7 +4,7 @@ # should take at least 55s, but fail if we block this # TODO: it would be nice to make sure this test doesn't exit too early! -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix lang --lang sema-2.mcl & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix lang sema-2.mcl & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t2.sh b/test/shell/t2.sh index a0cd3327..a09eae24 100755 --- a/test/shell/t2.sh +++ b/test/shell/t2.sh @@ -3,7 +3,7 @@ . "$(dirname "$0")/../util.sh" # run till completion -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t2.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t2.yaml & pid=$! wait $pid # get exit status e=$? diff --git a/test/shell/t3.sh b/test/shell/t3.sh index 25b34041..b7734f11 100755 --- a/test/shell/t3.sh +++ b/test/shell/t3.sh @@ -12,11 +12,11 @@ fi mkdir -p "${MGMT_TMPDIR}"mgmt{A..C} # run till completion -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-a.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t3-a.yaml & pid1=$! -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-b.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t3-b.yaml & pid2=$! -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-c.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t3-c.yaml & pid3=$! wait $pid1 # get exit status diff --git a/test/shell/t5.sh b/test/shell/t5.sh index a789eb91..1ab5a7e3 100755 --- a/test/shell/t5.sh +++ b/test/shell/t5.sh @@ -3,7 +3,7 @@ . "$(dirname "$0")/../util.sh" # should take slightly more than 35s, but fail if we take much longer) -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml t5.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t5b.sh b/test/shell/t5b.sh index 286b8cac..14e03874 100755 --- a/test/shell/t5b.sh +++ b/test/shell/t5b.sh @@ -3,7 +3,7 @@ . "$(dirname "$0")/../util.sh" # should take slightly more than 35s, but fail if we take much longer) -$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5b.yaml & +$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml t5b.yaml & pid=$! wait $pid # get exit status exit $? diff --git a/test/shell/t6.sh b/test/shell/t6.sh index acbefc16..92bc07c3 100755 --- a/test/shell/t6.sh +++ b/test/shell/t6.sh @@ -3,7 +3,7 @@ . "$(dirname "$0")/../util.sh" # run till completion -$TIMEOUT "$MGMT" run --no-watch --tmp-prefix yaml --yaml t6.yaml & +$TIMEOUT "$MGMT" run --no-watch --tmp-prefix yaml t6.yaml & pid=$! sleep 10s # let it converge test -e /tmp/mgmt/f1 diff --git a/test/shell/yaml-change1.sh b/test/shell/yaml-change1.sh index 63d5f833..93299e46 100755 --- a/test/shell/yaml-change1.sh +++ b/test/shell/yaml-change1.sh @@ -16,7 +16,7 @@ fi # set the config file cp -a yaml-change1a.yaml /tmp/mgmt/yaml-change.yaml -$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml /tmp/mgmt/yaml-change.yaml & +$TIMEOUT "$MGMT" run --tmp-prefix yaml /tmp/mgmt/yaml-change.yaml & pid=$! sleep 5s # let it converge grep -q 'hello world' /tmp/mgmt/change1 # check contents are correct diff --git a/vagrant/motd b/vagrant/motd index 3ad0bd98..2563dfed 100644 --- a/vagrant/motd +++ b/vagrant/motd @@ -9,6 +9,6 @@ To get started, try: $ cdmgmt $ make clean build -$ ./mgmt run --tmp-prefix lang --lang examples/lang/hello0.mcl` +$ ./mgmt run --tmp-prefix lang examples/lang/hello0.mcl` Enjoy! diff --git a/yamlgraph/gapi.go b/yamlgraph/gapi.go index cc065eff..08187336 100644 --- a/yamlgraph/gapi.go +++ b/yamlgraph/gapi.go @@ -56,13 +56,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag { case gapi.CommandRun: fallthrough case gapi.CommandDeploy: - return []cli.Flag{ - cli.StringFlag{ - Name: Name, - Value: "", - Usage: "yaml graph definition to run", - }, - } + return []cli.Flag{} //case gapi.CommandGet: default: return []cli.Flag{} @@ -80,11 +74,14 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) { //logf := func(format string, v ...interface{}) { // cliInfo.Logf(Name + ": "+format, v...) //} - if !c.IsSet(Name) { - return nil, nil // we weren't activated! - } - s := c.String(Name) + if l := c.NArg(); l != 1 { + if l > 1 { + return nil, fmt.Errorf("input program must be a single arg") + } + return nil, fmt.Errorf("must specify input program") + } + s := c.Args().Get(0) if s == "" { return nil, fmt.Errorf("input yaml is empty") }