chaostoolkit / chaostoolkit-lib

The Chaos Toolkit core library
https://chaostoolkit.org/
Apache License 2.0
77 stars 46 forks source link

Secrets should allow for arbitrary levels of nesting #209

Closed Tam-Lin closed 2 years ago

Tam-Lin commented 3 years ago

Is your feature request related to a problem? Please describe. For the chaos toolkit plugin I'm working into, there are multiple ways of connecting to a device and authenticating. I'd like to hide that as much as possible in the toolkit, by allowing the extension to figure things out and connect appropriately. Right now, though, you can't pass in multiple levels of json that get resolved out of the environment or I'm assuming vaults. For example,


    "zos_console": {
      "M89 S5C": {
        "method": "hmc",
        "hostname": "ioshmc3.pok.stglabs.ibm.com",
        "userid": {
          "type": "env",
          "key": "IOSHMC3_USERID"
        },
        "password": {
          "type": "env",
          "key": "IOSHMC3_PASSWORD"
        }
      }
    }

doesn't work, but

    "zos_console": {
      "M89 S5C": {
        "method": "hmc",
        "hostname": "ioshmc3.pok.stglabs.ibm.com",
        "userid": "<userid>",
        "password": "<mypassword>"

      }
    }

does work.

Describe the solution you'd like

You should be able to include environmental or vault keys at any level of JSON nesting. The Secrets object is supposed to be able to be an arbitrary JSON object; there's no reason I know of to restrict where keys can be pulled from the environment.

Describe alternatives you've considered I can restructure the plugin, but I'd prefer not to. And, again, it doesn't make sense to allow arbitrary of nesting of JSON objects, but not to allow variables to be held externally only 2 levels deep.

Additional context Add any other context or screenshots about the feature request here.

Lawouach commented 3 years ago

Hey, thanks for the report. This migt be a bug or a limitation to fix indeed.

Tam-Lin commented 3 years ago

I'm going to try to fix it; I just need some time to work on it. Expect a pull request in a few days.

ciaransweet commented 2 years ago

Closing as @Tam-Lin provided a PR which solves this