typesafehub / conductr-cli

CLI for Lightbend ConductR
Other
16 stars 21 forks source link

Add ability to set `start-command` to `bndl` #467

Closed longshorej closed 7 years ago

longshorej commented 7 years ago

This PR allows you to change the start-command of a component using bndl.

Manual Test

Description

We'll invoke bndl from the command line with a few options to ensure it's working as intended, namely that start-command does get updated and for the correct component.

Test: A bundle with only one component does not need to specify --component

$ cat single-bundle.conf 
name = "test"
components {
  test1 {
    start-command = ["basic", "command"]
  }
}
-> 0
$  (bndl single-bundle.conf --no-shazar --start-command '["it", "worked"]' | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test1 {
    start-command = [
      "it"
      "worked"
    ]
  }
}-> 0

Test: A bundle with more than one component fails if --component isn't specified

$ cat multi-bundle.conf 
name = "test"
components {
  test1 {
    start-command = []
  }
  test2 {
    start-command = []
  }
}
-> 0
$ (bndl multi-bundle.conf --no-shazar --start-command '["it", "worked"]' | tar x) && cat test/bundle.conf && rm -r test
Error: bndl: Unable to auto-detect the component. Component not specified and bundle.conf contains multiple components: ['test1', 'test2']
tar: This does not look like a tar archive
tar: Exiting with failure status due to previous errors
-> 2

Test: A bundle with more than one component succeeds if --component is specified

$ cat multi-bundle.conf 
name = "test"
components {
  test1 {
    start-command = []
  }
  test2 {
    start-command = []
  }
}
-> 0
$ (bndl multi-bundle.conf --no-shazar --start-command '["it", "worked"]' --component test1 | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test1 {
    start-command = [
      "it"
      "worked"
    ]
  }
  test2 {
    start-command = []
  }
}-> 0
$ (bndl multi-bundle.conf --no-shazar --start-command '["it", "worked"]' --component test2 | tar x) && cat test/bundle.conf && rm -r test
name = "test"
components {
  test1 {
    start-command = []
  }
  test2 {
    start-command = [
      "it"
      "worked"
    ]
  }
}-> 0