Skip to content

Commit

Permalink
[sigh] fix cache parameters validation (fastlane#21766)
Browse files Browse the repository at this point in the history
* fix: sigh cache validation parameters

* fix: needs_profiles_devices resoling in portal cache

* chore: fix nil devices and certificates
  • Loading branch information
nekrich authored and SubhrajyotiSen committed Jan 17, 2024
1 parent afab881 commit 26a4a44
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions match/lib/match/portal_cache.rb
Expand Up @@ -18,8 +18,8 @@ def self.build(params:, bundle_id_identifiers:)
profile_type: profile_type,
additional_cert_types: params[:additional_cert_types],
bundle_id_identifiers: bundle_id_identifiers,
needs_profiles_devices: ProfileIncludes.can_force_include?(params: params, notify: true) && !params[:force] && !params[:readonly],
needs_profiles_certificate_content: !ProfileIncludes.can_force_include_all_certificates?(params: params),
needs_profiles_devices: ProfileIncludes.can_force_include_all_devices?(params: params, notify: true),
needs_profiles_certificate_content: !ProfileIncludes.can_force_include_all_certificates?(params: params, notify: true),
include_mac_in_profiles: params[:include_mac_in_profiles]
)

Expand Down
4 changes: 2 additions & 2 deletions match/lib/match/profile_includes.rb
Expand Up @@ -46,7 +46,7 @@ def self.can_force_include_all_devices?(params:, notify: false)
def self.devices_differ?(portal_profile:, platform:, include_mac_in_profiles:, cached_devices:)
return false unless portal_profile

profile_devices = portal_profile.devices
profile_devices = portal_profile.devices || []

portal_devices = cached_devices
portal_devices ||= Match::Portal::Fetcher.devices(platform: platform, include_mac_in_profiles: include_mac_in_profiles)
Expand Down Expand Up @@ -102,7 +102,7 @@ def self.can_force_include_all_certificates?(params:, notify: false)
def self.certificates_differ?(portal_profile:, platform:, cached_certificates:)
return false unless portal_profile

profile_certs = portal_profile.certificates
profile_certs = portal_profile.certificates || []

portal_certs = cached_certificates
portal_certs ||= Match::Portal::Fetcher.certificates(platform: platform, profile_type: portal_profile.profile_type)
Expand Down
16 changes: 8 additions & 8 deletions sigh/lib/sigh/options.rb
Expand Up @@ -205,10 +205,10 @@ def self.available_options
is_string: false,
default_value: nil,
verify_block: proc do |value|
next if value.nil?
if !value.kind_of?(Array) ||
value.empty? ||
!value.all?(Spaceship::ConnectAPI::Certificate)
UI.user_error!("cached_certificates parameter must be a non-empty array of Spaceship::ConnectAPI::Certificate") unless value.kind_of?(Array)
UI.user_error!("cached_certificates parameter must be an array of Spaceship::ConnectAPI::Certificate") unless value.kind_of?(Array)
end
end),
FastlaneCore::ConfigItem.new(key: :cached_devices,
Expand All @@ -217,10 +217,10 @@ def self.available_options
is_string: false,
default_value: nil,
verify_block: proc do |value|
next if value.nil?
if !value.kind_of?(Array) ||
value.empty? ||
!value.all?(Spaceship::ConnectAPI::Device)
UI.user_error!("cached_devices parameter must be a non-empty array of Spaceship::ConnectAPI::Device")
UI.user_error!("cached_devices parameter must be an array of Spaceship::ConnectAPI::Device")
end
end),
FastlaneCore::ConfigItem.new(key: :cached_bundle_ids,
Expand All @@ -229,10 +229,10 @@ def self.available_options
is_string: false,
default_value: nil,
verify_block: proc do |value|
next if value.nil?
if !value.kind_of?(Array) ||
value.empty? ||
!value.all?(Spaceship::ConnectAPI::BundleId)
UI.user_error!("cached_bundle_ids parameter must be a non-empty array of Spaceship::ConnectAPI::BundleId")
UI.user_error!("cached_bundle_ids parameter must be an array of Spaceship::ConnectAPI::BundleId")
end
end),
FastlaneCore::ConfigItem.new(key: :cached_profiles,
Expand All @@ -241,10 +241,10 @@ def self.available_options
is_string: false,
default_value: nil,
verify_block: proc do |value|
next if value.nil?
if !value.kind_of?(Array) ||
value.empty? ||
!value.all?(Spaceship::ConnectAPI::Profile)
UI.user_error!("cached_profiles parameter must be a non-empty array of Spaceship::ConnectAPI::Profile")
UI.user_error!("cached_profiles parameter must be an array of Spaceship::ConnectAPI::Profile")
end
end)
]
Expand Down

0 comments on commit 26a4a44

Please sign in to comment.