diff options
author | Tim Smith <tsmith@chef.io> | 2020-04-10 15:56:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-10 15:56:14 -0700 |
commit | 9e408e78a02a968ea0c1f699c0ca2e0bd98320ac (patch) | |
tree | 967ac46ed33619a79b6fceebe480b50b80c6927d | |
parent | e9edd60143ecebd592450eec4a22a1d7909cd8fc (diff) | |
parent | 4c2ad6e5ad3e3b3f12370a708b900ead8a6c2c55 (diff) | |
download | chef-9e408e78a02a968ea0c1f699c0ca2e0bd98320ac.tar.gz |
Merge pull request #9651 from chef/arm_helper
Add arm? helper to chef-utils
-rw-r--r-- | chef-utils/README.md | 11 | ||||
-rw-r--r-- | chef-utils/lib/chef-utils/dsl/architecture.rb | 10 | ||||
-rw-r--r-- | chef-utils/spec/unit/dsl/architecture_spec.rb | 8 |
3 files changed, 20 insertions, 9 deletions
diff --git a/chef-utils/README.md b/chef-utils/README.md index 36ca1810d4..b93cfe5214 100644 --- a/chef-utils/README.md +++ b/chef-utils/README.md @@ -108,17 +108,18 @@ The OS helpers provide an alternative to comparing data from `node['os']`. Architecture Helpers allow you to determine the processor architecture of your node. -* `_64_bit?` * `_32_bit?` +* `_64_bit?` +* `arm?` +* `armhf?` * `i386?` * `intel?` -* `sparc?` +* `powerpc?` * `ppc64?` * `ppc64le?` -* `powerpc?` -* `armhf?` -* `s390x?` * `s390?` +* `s390x?` +* `sparc?` ### Cloud Helpers diff --git a/chef-utils/lib/chef-utils/dsl/architecture.rb b/chef-utils/lib/chef-utils/dsl/architecture.rb index d20c6c5a76..03f2756ab1 100644 --- a/chef-utils/lib/chef-utils/dsl/architecture.rb +++ b/chef-utils/lib/chef-utils/dsl/architecture.rb @@ -103,6 +103,16 @@ module ChefUtils %w{powerpc}.include?(node["kernel"]["machine"]) end + # Determine if the current architecture is arm + # + # @since 15.10 + # + # @return [Boolean] + # + def arm?(node = __getnode) + %w{armhf aarch64 arm64 arch64}.include?(node["kernel"]["machine"]) + end + # Determine if the current architecture is 32-bit ARM. # # @since 15.5 diff --git a/chef-utils/spec/unit/dsl/architecture_spec.rb b/chef-utils/spec/unit/dsl/architecture_spec.rb index a2ce300fe0..c43b2d0733 100644 --- a/chef-utils/spec/unit/dsl/architecture_spec.rb +++ b/chef-utils/spec/unit/dsl/architecture_spec.rb @@ -84,17 +84,17 @@ RSpec.describe ChefUtils::DSL::Architecture do context "on aarch64" do let(:arch) { "aarch64" } - arch_reports_true_for(:_64_bit?) + arch_reports_true_for(:_64_bit?, :arm?) end context "on arch64" do let(:arch) { "arch64" } - arch_reports_true_for(:_64_bit?) + arch_reports_true_for(:_64_bit?, :arm?) end context "on arm64" do let(:arch) { "arm64" } - arch_reports_true_for(:_64_bit?) + arch_reports_true_for(:_64_bit?, :arm?) end context "on sun4v" do let(:arch) { "sun4v" } @@ -129,7 +129,7 @@ RSpec.describe ChefUtils::DSL::Architecture do context "on armhf" do let(:arch) { "armhf" } - arch_reports_true_for(:armhf?, :_32_bit?) + arch_reports_true_for(:armhf?, :_32_bit?, :arm?) end context "on s390" do let(:arch) { "s390" } |