Beispiel #1
0
def test_shellify():
  dump = list(shellify(
    {
      "num": 123,
      "string": "abc",
      "obj": {
        "num": 456,
        "string": "def",
        "description": "Runs the world",
      },
      "arr": [
        7,
        "g",
        {
          "hi": [0],
        },
      ]
    }, prefix="TEST_"))

  assert set(dump) == set([
    "TEST_NUM=123",
    "TEST_STRING=abc",
    "TEST_OBJ_NUM=456",
    "TEST_OBJ_STRING=def",
    "TEST_OBJ_DESCRIPTION='Runs the world'",
    "TEST_ARR_0=7",
    "TEST_ARR_1=g",
    "TEST_ARR_2_HI_0=0",
  ])
Beispiel #2
0
def get_cluster_config(cluster):
  """usage: get_cluster_config [--sh] [--export] CLUSTER

  Dumps the configuration for CLUSTER. By default we emit a json blob to stdout equivalent to
  an entry in clusters.json. With --sh a shell script is written to stdout that can be used
  with eval in a script to load the cluster config. With --export the shell script is prefixed
  with 'export '."""
  options = app.get_options()
  cluster = CLUSTERS[cluster]
  if not options.sh:
    json.dump(cluster, sys.stdout)
  else:
    for line in shellify(cluster, options.export, prefix="AURORA_CLUSTER_"):
      print(line)