Skip to content

Commit

Permalink
Fix issue with s390x support on sensor API (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosmmatos authored Dec 22, 2022
1 parent baa6867 commit 1b0ee50
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@ def build_sensor_installer_query(platform_name:, os_name: nil, version: nil, os_
unless os_version.nil?
query += "+os_version:'#{os_version}'"
end
query += if node['cpu']['architecture'].casecmp('arm64').zero?
query += case node['kernel']['machine']
when 'x86_64'
"+os_version:!~'arm64'+os_version:!~'zLinux'"
when 'aarch64'
"+os_version:~'arm64'"
when 's390x'
"+os_version:~'zLinux'"
else
"+os_version:!~'arm64'"
Chef::Log.error("Unsupported architecture: #{node['kernel']['machine']}")
raise
end

unless version.nil?
query += "+version:'#{version}'"
end
Expand Down Expand Up @@ -73,13 +80,13 @@ def sensor_download_info(client_id, client_secret, options)
if options.key?(:version) && !options[:version].nil?
query = build_sensor_installer_query(platform_name: platform_name, version: options[:version], os_name: os_name, os_version: os_version)
installer = falcon_api.falcon_installers(query)[0]
# If update_policy is provided, use it to get the sensor package info
# If update_policy is provided, use it to get the sensor package info
elsif options.key?(:update_policy) && !options[:update_policy].nil?
falcon_api.update_policy = options[:update_policy]
version = falcon_api.version_from_update_policy
query = build_sensor_installer_query(platform_name: platform_name, version: version, os_name: os_name, os_version: os_version)
installer = falcon_api.falcon_installers(query)[0]
# If neither are provided, use the `version_decrement` to pull the n-x version for the platform and os`
# If neither are provided, use the `version_decrement` to pull the n-x version for the platform and os`
else
query = build_sensor_installer_query(platform_name: platform_name, os_name: os_name, os_version: os_version)
version_decrement = options[:version_decrement]
Expand All @@ -97,7 +104,7 @@ def sensor_download_info(client_id, client_secret, options)

version = installer['version'].gsub(/(\d+\.\d+)\.(\d+)/, '\1.0-\2') if platform_name.casecmp('Linux').zero?
version += ".el#{os_version}".delete('*') if os_name.casecmp('*RHEL*').zero?
version += ".amzn#{os_version}".delete('*') if os_name.casecmp('Amazon Linux').zero?
version += ".amzn#{os_version}".delete('*') if os_name.casecmp('Amazon Linux').zero?

{
'bearer_token' => falcon_api.bearer_token,
Expand Down

0 comments on commit 1b0ee50

Please sign in to comment.