Skip to content

Instantly share code, notes, and snippets.

@wcooley
Created March 25, 2015 07:18
Show Gist options
  • Save wcooley/84f3028a1ecf04e36e1c to your computer and use it in GitHub Desktop.
Save wcooley/84f3028a1ecf04e36e1c to your computer and use it in GitHub Desktop.
Puppet => alignment
# Starts like this...
class strictly_following_style_guide {
yumrepo { 'puppetlabs-products':
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
}
}
# Dammit, I've added another param that's long. Better move everything over
# to line up!
class strictly_following_style_guide {
yumrepo { 'puppetlabs-products':
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
metadata_expire => '3h',
}
}
# And you get a lovely, confusing diff...
@@ -1,8 +1,9 @@
class strictly_following_style_guide {
yumrepo { 'puppetlabs-products':
- descr => 'Puppet Labs Products El $releasever - $basearch',
- baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
- gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
- gpgcheck => '1',
+ descr => 'Puppet Labs Products El $releasever - $basearch',
+ baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
+ gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
+ gpgcheck => '1',
+ metadata_expire => '3h',
}
}
# Or you could've just given it a nice wide inner-indent to begin with...
class start_wide {
yumrepo { 'puppetlabs-products':
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
}
}
# And everything still lines up even after you add a long parameter
class start_wide {
yumrepo { 'puppetlabs-products':
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
metadata_expire => '3h',
}
}
# And you get a reasonable diff
@@ -4,5 +4,6 @@
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
+ metadata_expire => '3h',
}
}
# Or you could've started with a narrow inner-indent...
class grouped_indents {
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
}
# And just grouped into narrow and wide indents
class grouped_indents {
descr => 'Puppet Labs Products El $releasever - $basearch',
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
repo_gpgcheck => '1',
metadata_expire => '3h',
mirrorlist_expire => '30',
}
# And still get a reasonable diff
@@ -3,4 +3,7 @@
baseurl => 'http://yum.puppetlabs.com/el/$releasever/products/$basearch',
gpgkey => 'file:///etc/pki/rpm-gpg/PUPPETLABS_GPG_KEY',
gpgcheck => '1',
+ repo_gpgcheck => '1',
+ metadata_expire => '3h',
+ mirrorlist_expire => '30',
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment