diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-02-03 17:15:39 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-02-05 09:10:47 -0800 |
commit | e0c3ee021f5fd41f52a4376b017346bdf8344895 (patch) | |
tree | e35e221919b5d7aff0770001fa231582c90b4e53 | |
parent | 71e3e52a207b673f3a9e0b6d6e523f591ed1bc20 (diff) | |
download | chef-e0c3ee021f5fd41f52a4376b017346bdf8344895.tar.gz |
Swap the methods and the aliases in the chef-utils platforms
X_platform? is the name we want to eventually use so make that the real
method name as make the alias the name we want people to stop using.
That way we document the right thing in yard and can skip all the
aliases when we generate the vscode snippets.
Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/introspection.rb | 1 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/platform.rb | 133 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/platform_family.rb | 9 |
3 files changed, 83 insertions, 60 deletions
diff --git a/chef-utils/lib/chef-utils/dsl/introspection.rb b/chef-utils/lib/chef-utils/dsl/introspection.rb index 07c77aa3a8..ba65cf2881 100644 --- a/chef-utils/lib/chef-utils/dsl/introspection.rb +++ b/chef-utils/lib/chef-utils/dsl/introspection.rb @@ -113,6 +113,7 @@ module ChefUtils def includes_recipe?(recipe_name, node = __getnode) node.recipe?(recipe_name) end + # chef-sugar backcompat method alias_method :include_recipe?, :includes_recipe? extend self diff --git a/chef-utils/lib/chef-utils/dsl/platform.rb b/chef-utils/lib/chef-utils/dsl/platform.rb index d719f5de1c..8ea486b268 100644 --- a/chef-utils/lib/chef-utils/dsl/platform.rb +++ b/chef-utils/lib/chef-utils/dsl/platform.rb @@ -34,39 +34,43 @@ module ChefUtils # # @return [Boolean] # - def linuxmint?(node = __getnode) + def linuxmint_platform?(node = __getnode) node["platform"] == "linuxmint" end - # chef-sugar backcompat methods - alias_method :mint?, :linuxmint? - alias_method :linux_mint?, :linuxmint? - alias_method :linuxmint_platform?, :linuxmint? + # chef-sugar backcompat method + alias_method :mint?, :linuxmint_platform? + # chef-sugar backcompat method + alias_method :linux_mint?, :linuxmint_platform? + # chef-sugar backcompat method + alias_method :linuxmint?, :linuxmint_platform? - # Determine if the current node is ubuntu. + # Determine if the current node is Ubuntu. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def ubuntu?(node = __getnode) + def ubuntu_platform?(node = __getnode) node["platform"] == "ubuntu" end - alias_method :ubuntu_platform?, :ubuntu? + # chef-sugar backcompat method + alias_method :ubuntu?, :ubuntu_platform? - # Determine if the current node is raspbian. + # Determine if the current node is Raspbian. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def raspbian?(node = __getnode) + def raspbian_platform?(node = __getnode) node["platform"] == "raspbian" end - alias_method :raspbian_platform?, :raspbian? + # chef-sugar backcompat method + alias_method :raspbian?, :raspbian_platform? - # Determine if the current node is debian. + # Determine if the current node is Debian. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -77,7 +81,7 @@ module ChefUtils node["platform"] == "debian" end - # Determine if the current node is amazon linux. + # Determine if the current node is Amazon Linux. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -88,74 +92,80 @@ module ChefUtils node["platform"] == "amazon" end - # Determine if the current node is redhat enterprise. + # Determine if the current node is Red Hat Enterprise Linux. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def redhat?(node = __getnode) + def redhat_platform?(node = __getnode) node["platform"] == "redhat" end - # chef-sugar backcompat methods - alias_method :redhat_enterprise?, :redhat? - alias_method :redhat_enterprise_linux?, :redhat? - alias_method :redhat_platform?, :redhat? + # chef-sugar backcompat method + alias_method :redhat_enterprise?, :redhat_platform? + # chef-sugar backcompat method + alias_method :redhat_enterprise_linux?, :redhat_platform? + # chef-sugar backcompat method + alias_method :redhat?, :redhat_platform? - # Determine if the current node is centos. + # Determine if the current node is CentOS. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def centos?(node = __getnode) + def centos_platform?(node = __getnode) node["platform"] == "centos" end - alias_method :centos_platform?, :centos? + # chef-sugar backcompat method + alias_method :centos?, :centos_platform? - # Determine if the current node is oracle linux. + # Determine if the current node is Oracle Linux. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def oracle?(node = __getnode) + def oracle_platform?(node = __getnode) node["platform"] == "oracle" end - # chef-sugar backcompat methods - alias_method :oracle_linux?, :oracle? - alias_method :oracle_platform?, :oracle? + # chef-sugar backcompat method + alias_method :oracle_linux?, :oracle_platform? + # chef-sugar backcompat method + alias_method :oracle?, :oracle_platform? - # Determine if the current node is scientific linux. + # Determine if the current node is Scientific Linux. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def scientific?(node = __getnode) + def scientific_platform?(node = __getnode) node["platform"] == "scientific" end - # chef-sugar backcompat methods - alias_method :scientific_linux?, :scientific? - alias_method :scientific_platform?, :scientific? + # chef-sugar backcompat method + alias_method :scientific_linux?, :scientific_platform? + # chef-sugar backcompat method + alias_method :scientific?, :scientific_platform? - # Determine if the current node is clearos. + # Determine if the current node is ClearOS. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def clearos?(node = __getnode) + def clearos_platform?(node = __getnode) node["platform"] == "clearos" end - alias_method :clearos_platform?, :clearos? + # chef-sugar backcompat method + alias_method :clearos?, :clearos_platform? - # Determine if the current node is fedora. + # Determine if the current node is Fedora. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -166,7 +176,7 @@ module ChefUtils node["platform"] == "fedora" end - # Determine if the current node is arch + # Determine if the current node is Arch Linux # # @param [Chef::Node] node the node to check # @since 15.5 @@ -177,7 +187,7 @@ module ChefUtils node["platform"] == "arch" end - # Determine if the current node is solaris2 + # Determine if the current node is Solaris2. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -188,7 +198,7 @@ module ChefUtils node["platform"] == "solaris2" end - # Determine if the current node is smartos + # Determine if the current node is SmartOS. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -199,43 +209,46 @@ module ChefUtils node["platform"] == "smartos" end - # Determine if the current node is omnios + # Determine if the current node is OmniOS. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def omnios?(node = __getnode) + def omnios_platform?(node = __getnode) node["platform"] == "omnios" end - alias_method :omnios_platform?, :omnios? + # chef-sugar backcompat method + alias_method :omnios?, :omnios_platform? - # Determine if the current node is openindiana + # Determine if the current node is OpenIndiana. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def openindiana?(node = __getnode) + def openindiana_platform?(node = __getnode) node["platform"] == "openindiana" end - alias_method :openindiana_platform?, :openindiana? + # chef-sugar backcompat method + alias_method :openindiana?, :openindiana_platform? - # Determine if the current node is nexentacore + # Determine if the current node is Nexenta Core Platform aka Nexenta OS. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def nexentacore?(node = __getnode) + def nexentacore_platform?(node = __getnode) node["platform"] == "nexentacore" end - alias_method :nexentacore_platform?, :nexentacore? + # chef-sugar backcompat method + alias_method :nexentacore?, :nexentacore_platform? - # Determine if the current node is aix + # Determine if the current node is AIX. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -246,7 +259,7 @@ module ChefUtils node["platform"] == "aix" end - # Determine if the current node is freebsd + # Determine if the current node is FreeBSD. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -257,7 +270,7 @@ module ChefUtils node["platform"] == "freebsd" end - # Determine if the current node is openbsd + # Determine if the current node is OpenBSD. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -268,7 +281,7 @@ module ChefUtils node["platform"] == "openbsd" end - # Determine if the current node is netbsd + # Determine if the current node is NetBSD. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -279,7 +292,7 @@ module ChefUtils node["platform"] == "netbsd" end - # Determine if the current node is dragonflybsd + # Determine if the current node is DragonFly BSD. # # @param [Chef::Node] node the node to check # @since 15.5 @@ -300,6 +313,7 @@ module ChefUtils def macos_platform?(node = __getnode) node["platform"] == "mac_os_x" end + # chef-sugar backcompat method alias_method :mac_os_x_platform?, :macos_platform? # Determine if the current node is gentoo @@ -335,19 +349,22 @@ module ChefUtils node["platform"] == "suse" end - # Determine if the current node is OpenSuSE. + # Determine if the current node is OpenSUSE. # # @param [Chef::Node] node the node to check # @since 15.5 # # @return [Boolean] # - def opensuse?(node = __getnode) + def opensuse_platform?(node = __getnode) node["platform"] == "opensuse" || node["platform"] == "opensuseleap" end - alias_method :opensuse_platform?, :opensuse? - alias_method :opensuseleap_platform?, :opensuse? - alias_method :leap_platform?, :opensuse? + # chef-sugar backcompat method + alias_method :opensuse?, :opensuse_platform? + # chef-sugar backcompat method + alias_method :opensuseleap_platform?, :opensuse_platform? + # chef-sugar backcompat method + alias_method :leap_platform?, :opensuse_platform? # NOTE: to anyone adding :tumbleweed_platform? - :[opensuse]leap_platform? should be false on tumbleweed, :opensuse[_platform]? should be true # Determine if the current node is Windows. diff --git a/chef-utils/lib/chef-utils/dsl/platform_family.rb b/chef-utils/lib/chef-utils/dsl/platform_family.rb index 8efbfd4d4f..f9bc4d299d 100644 --- a/chef-utils/lib/chef-utils/dsl/platform_family.rb +++ b/chef-utils/lib/chef-utils/dsl/platform_family.rb @@ -32,7 +32,7 @@ module ChefUtils def arch?(node = __getnode) node["platform_family"] == "arch" end - # chef-sugar backcompat methods + # chef-sugar backcompat method alias_method :arch_linux?, :arch? # Determine if the current node is a member of the 'aix' platform family. @@ -78,8 +78,11 @@ module ChefUtils def macos?(node = __getnode) node["platform_family"] == "mac_os_x" end + # chef-sugar backcompat method alias_method :osx?, :macos? + # chef-sugar backcompat method alias_method :mac?, :macos? + # chef-sugar backcompat method alias_method :mac_os_x?, :macos? # Determine if the current node is a member of the 'rhel' platform family (Red Hat, CentOS, Oracle or Scientific Linux, but NOT Amazon Linux or Fedora). @@ -92,6 +95,7 @@ module ChefUtils def rhel?(node = __getnode) node["platform_family"] == "rhel" end + # chef-sugar backcompat method alias_method :el?, :rhel? # Determine if the current node is a rhel6 compatible build (Red Hat, CentOS, Oracle or Scientific Linux) @@ -137,6 +141,7 @@ module ChefUtils def amazon?(node = __getnode) node["platform_family"] == "amazon" end + # chef-sugar backcompat method alias_method :amazon_linux?, :amazon? # Determine if the current node is a member of the 'solaris2' platform family. @@ -149,7 +154,7 @@ module ChefUtils def solaris2?(node = __getnode) node["platform_family"] == "solaris2" end - # chef-sugar backcompat methods + # chef-sugar backcompat method alias_method :solaris?, :solaris2? # Determine if the current node is a member of the 'smartos' platform family. |