1.0.0-rc.1 Complex structure injections ie. Terraform issues

Looks like using plugins with more complex injections is no longer injecting it in.

Specifically in the terraform plugin it uses

init_options:
      backend-config:
      - "bucket=bucket-value"
      - "key=terraform/terraform.tfstate"
      - "region=us-east-1"
      - "dynamodb_table=dynamo-table"

to be able to configure the backend however trying

settings:
  init_options:
      backend-config:
      - "bucket=bucket-value"
      - "key=terraform/terraform.tfstate"
      - "region=us-east-1"
      - "dynamodb_table=dynamo-table"

and

environment:
  PLUGIN_INIT_OPTIONS:
      backend-config:
      - "bucket=bucket-value"
      - "key=terraform/terraform.tfstate"
      - "region=us-east-1"
      - "dynamodb_table=dynamo-table"

Currently the plugin assumes that the init_options is being sent in as a stringFlag and then maps backend-config to a string list that gets added to a list of options. I’m going to dig deeper but I didn’t know if anything changed in 1.0.0 to would have changed the environment variable injections

Thanks

I tested with this yaml:

kind: pipeline
type: default

steps:
- name: foo
  image: plugins/bar
  settings:
    baz:
    - qux
    - quux
    corge:
      grault: garply

I used the drone-yaml convert command this is provided in the drone-yml package for debugging and testing purposes.

I see the following plugin environment variables generated:

{
  "PLUGIN_BAZ": "qux,quux",
  "PLUGIN_CORGE": "null"
}

I am therefore able to confirm the issue exists for map types. Unfortunately my backlog is quite long so I don’t have any time to dig into code and create a patch, but if you are open to sending a pull request I can point you in the right direction.

The code responsible for encoding complex types is here: https://github.com/drone/drone-yaml/blob/master/yaml/compiler/encode.go

You should be able to use the drone-yaml compile command and then inspect the environment variables in the result to test any changes you make. Thanks!

ah cool, thanks for verifying and pointing me in the right direction. I’ll take a look at it and see if I can get a PR out :slight_smile:

great and thanks, hit me up in chat if you have any questions

PR is in :slight_smile: https://github.com/drone/drone-yaml/pull/3 and took way more time then I’d like to admit for how simple the fix was. Also, I have https://github.com/drone/drone-yaml/pull/4 that’s related if it makes sense for you Brad :slight_smile: