cloudfoundry-attic / bosh-notes

Collection of proposals for BOSH
Apache License 2.0
51 stars 23 forks source link

Using "partial templates" inside bosh templates in releases #6

Closed allomov closed 6 years ago

allomov commented 9 years ago

I think that templates for jobs would be easier to create if bosh-template library had something like "partial templates" helpers.

For instance you can look at director.yml.erb.erb. It has a large block for each IaaS it supports. If we could use partials, we are able to extract this IaaS specific settings to distinct templates. The resulting code will be much cleaner, something like this:

<% if_p('aws') do %>
  <%= render 'cpi/aws' %>
<% end %>
<% if_p('openstack') do %>
  <%= render 'cpi/openstack' %>
<% end %>
...

What do you think?

cppforlife commented 9 years ago

I think this will mask the actual problem -- why is the template file so complicated? Specifically talking about the director.yml.erb: since we are pulling out CPIs from the bosh release that file will significantly shrink and splitting it up will not be necessary.

Do you have other concrete examples where you think render will be helpful?

allomov commented 9 years ago

Agree with you.

But sometimes this functionality is preferable for a config with large amount of options. For instance, in logsearch/logsearch-boshrelease you can see how in _ctl file, that is aimed to run service, a large config file is concatenated from smaller pieces. This smaller pieces are easier to maintain, but _ctl script doesn't seem to be the right place to render it.

dpb587-pivotal commented 6 years ago

Closing due to age - feel free to follow up if this continues to be a significant issue and you would like to continue discussion.