summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2020-04-08 12:11:54 -0700
committerGitHub <noreply@github.com>2020-04-08 12:11:54 -0700
commitbf72554155fc3e24f3f020ba6d7101d350502bb9 (patch)
treeb671ac43fba926fcc0894e23f04c0e97fcea96bc
parent8b7e30a57a726539dfc0e493913eee464597b8fd (diff)
parent647406699878d4c8ff89f211da04503778a19663 (diff)
downloadchef-bf72554155fc3e24f3f020ba6d7101d350502bb9.tar.gz
Merge pull request #9622 from chef/arm_helper
Add arm? helper to chef-utils
-rw-r--r--chef-utils/README.md11
-rw-r--r--chef-utils/lib/chef-utils/dsl/architecture.rb10
-rw-r--r--chef-utils/spec/unit/dsl/architecture_spec.rb8
3 files changed, 20 insertions, 9 deletions
diff --git a/chef-utils/README.md b/chef-utils/README.md
index e44d4d6937..18830d07c1 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" }