If variables are defined like mortar --var port.foo=80 --var port.bar=8080, we could loop over all the defined ports with:
ports:
<% port.to_h.each do |name, value| %>
- containerPort: <%= name %>
name: <%= value %>
<% end %>
For non-Ruby developer, the to_h is not so intuitive. We could simplify this by extending the RecursiveOpenStruct so it could be written as port.each do |k,v| ...
If variables are defined like
mortar --var port.foo=80 --var port.bar=8080
, we could loop over all the defined ports with:For non-Ruby developer, the
to_h
is not so intuitive. We could simplify this by extending theRecursiveOpenStruct
so it could be written asport.each do |k,v| ...