shieldproject / shield-boshrelease

BOSH Release for shield
MIT License
11 stars 17 forks source link

Dynamically specify job-name when merging templates #46

Closed bodymindarts closed 8 years ago

bodymindarts commented 8 years ago

We have shield deployed to multiple environments and configure the agent job at site level as follows:

properties:
  shield:
    job:
      name: (( grab name))
      <etc>

Now that only plural version of jobs key is supported we cannot dynamically determin the job name when merging the templates via spruce / genesis.

jhunt commented 8 years ago

Can you provide more of your templates? I have a feeling you can do this with (( inline ))

bodymindarts commented 8 years ago

yeah I didn’t explain it well sorry (writting tickets while on client call)… the issue is we can do:

job:
  name: (( grab <some-name> ))

but with the pluralized version it needs to be:

jobs:
  <some-name>:
    (etc)

is there a way to use spruce to get a grabbed field and have it be the key of a map (instead of a value)

jhunt commented 8 years ago

Sadly, there is not. Feel free to open a PR against https://github.com/geofffranks/spruce to see if it can be modified to do so.

In the meantime, what if we added an optional name: attribute to all of the entries, and have that 'default' to the key if not specified?

So:

properties:
  shield:
    jobs:
      default:
        name: (( grab name ))
        # etc.
bodymindarts commented 8 years ago

So when specifying many jobs like:

properties:
  shield:
    jobs:
      joba:
        name: a-job
      jobb:
        name: b-job

The value under the name: attribute would win over the key that the attrs are under?

jhunt commented 8 years ago

Yes. PR forthcoming.