all: Switch the --lang syntax to use argv instead

It was a bit awkward using `mgmt run lang --lang <input>` so instead, we
now drop the --lang, and read the positional argv for the input.

This also does the same for the --yaml frontend.
This commit is contained in:
James Shubin
2019-05-05 10:37:53 -04:00
parent b3632584c3
commit 43839d1090
42 changed files with 91 additions and 78 deletions

View File

@@ -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 <graph.yaml>`
Point to a graph file to run.
#### `--converged-timeout <seconds>`
Exit if the machine has converged for approximately this many seconds.

View File

@@ -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...`.

View File

@@ -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

View File

@@ -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
```

View File

@@ -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"

View File

@@ -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"

View File

@@ -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)),

View File

@@ -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...)

View File

@@ -16,9 +16,9 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// 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)

View File

@@ -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")
}

View File

@@ -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,

View File

@@ -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")
}
s := c.String(Name)
return nil, fmt.Errorf("must specify input program")
}
s := c.Args().Get(0)
if s == "" {
return nil, fmt.Errorf("%s input is empty", Name)
}

View File

@@ -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: ''

View File

@@ -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: ''

View File

@@ -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

View File

@@ -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'."

View File

@@ -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

View File

@@ -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"

View File

@@ -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

View File

@@ -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=$?

View File

@@ -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=$?

View File

@@ -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

View File

@@ -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

View File

@@ -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=$?

View File

@@ -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=$?

View File

@@ -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

View File

@@ -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

View File

@@ -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 $?

View File

@@ -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=$?

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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 $?

View File

@@ -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 $?

View File

@@ -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=$?

View File

@@ -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

View File

@@ -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 $?

View File

@@ -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 $?

View File

@@ -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

View File

@@ -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

View File

@@ -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!

View File

@@ -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")
}