klarna / bec

The BitBucket Erlang Client
Apache License 2.0
47 stars 12 forks source link

Using lists in values file causes an error #21

Open gadiener opened 3 years ago

gadiener commented 3 years ago

Current Behavior

I get an error using a list in the .ymlv file. The error is as follows:

13:41:36.862 [info] Reading config file "/bitbucket-config/bitbucket.config".
escript: exception error: no function clause matching bec_yml:to_mustache([<<"admin_group">>]) (/home/jenkins/agent/workspace/tools-bec_3.2.0/src/bec_yml.erl, line 33)
  in function  bitbucket_repo_config:'-read_vars/1-fun-1-'/3 (/home/jenkins/agent/workspace/tools-bec_3.2.0/src/bitbucket_repo_config.erl, line 53)
  in call from maps:fold_1/3 (maps.erl, line 257)
  in call from lists:map/2 (lists.erl, line 1239)
  in call from bitbucket_repo_config:verify/2 (/home/jenkins/agent/workspace/tools-bec_3.2.0/src/bitbucket_repo_config.erl, line 25)
  in call from bec:do_main/1 (/home/jenkins/agent/workspace/tools-bec_3.2.0/src/bec.erl, line 40)

Steps to Reproduce

  1. Create the config.ymlt and config.ymlv:

config.ymlt

project: {{ project }}
repo: {{ repo }}

users:
  admin: []
  write: []
  read: []
groups:
  admin: {{ admin_groups }}
  write: []
  read: []

config.ymlv:

- project: test
  repo: test
  admin_groups:
    - admin_group
  1. Run bec.

Context

Tested on the docker with the current master state.

docker run --rm -v ${PWD}:/bitbucket-config -t ${BEC_DOCKER_IMAGE} -vv -c /bitbucket-config/bitbucket.config -r /bitbucket-config/config.ymlt

Tested with mustache directly I get the expected output:

project: test
repo: test

users:
  admin: []
  write: []
  read: []
groups:
  admin: [&quot;admin_group&quot;]
  write: []
  read: []
lilach commented 2 years ago

Any news on this? It would be very helpful for me

szaffarano commented 2 years ago

I found a workaround to make it works: main.ymlv

- project: test
  repo: test
  admin_groups: "[group1, group2]"

main.ymlt

project: {{ project }}
repo: {{ repo }}

users:
  admin: []
  write: []
  read: []
groups:
  admin: {{ admin_groups }}
  write: []
  read: []

Hope it helps