foreman icon indicating copy to clipboard operation
foreman copied to clipboard

Fixes #37433 - Set indentation when calling subscription_manager_setup

Open jpasqualetto opened this issue 9 months ago • 3 comments

Adding proper indentation when calling snippet subscription_manager_setup

jpasqualetto avatar May 09 '24 17:05 jpasqualetto

The problem I'm trying to solve is the final rendered result of cloud_init_default.erb.

subscription_manager_setup.erb is fine.

redhat_register.erb is also fine and generates valid bash script.

However, when rendered, redhat_register.erb result does not have the same indentation. Code that comes from redhat_register.rb have 2 space indentation, but what is generated by the snippet has no indentation at all. That's fine if that result is simply being processed by bash.

The problem is that cloud_init_default.erb (which consumes redhat_register.erb) is supposed to generate a valid yaml as result. With that difference on indentation coming from redhat_register.erb its result is not a valid yaml.

I wouldn't mind if we removed all the indentation from redhat_register.erb. That would do the trick too. What matters is that the rendered result should have the same indentation.

jpasqualetto avatar May 10 '24 12:05 jpasqualetto

@ekohl , this is how the template looks like when it's rendered without the indentation: image

If we indent the internal snippet, it will pass the validation: image

ShimShtein avatar May 20 '24 09:05 ShimShtein

@jpasqualetto can you update the snapshots of templates as well?

The rails command is RAILS_ENV=test bundle exec rails snapshots:generate

stejskalleos avatar Jun 05 '24 06:06 stejskalleos

I messed up while trying to push the snapshots. I rebased my code to run the generate snapshots and pushed it into the issue branch. Trying to fix this mess now.

jpasqualetto avatar Jul 23 '24 20:07 jpasqualetto

I added the snapshots and fixed my mess. Let me know if you need anything else.

jpasqualetto avatar Jul 23 '24 21:07 jpasqualetto

@ekohl Apparently the indentation breaks templates that have heredoc in them. Created a ticket for it: https://projects.theforeman.org/issues/37741

ShimShtein avatar Aug 18 '24 12:08 ShimShtein

Given my concern in https://github.com/theforeman/foreman/pull/10153#pullrequestreview-2049931982 I'm leaning to reverting the change. Or are you working on a fix @ShimShtein?

ekohl avatar Aug 19 '24 10:08 ekohl