Sha256: a2ee8e2a37cf2d62be42084e16c026e8c1401db76711be186d35f0fdaa7c32b2

Contents?: true

Size: 697 Bytes

Versions: 81

Compression:

Stored size: 697 Bytes

Contents

module InsightsCloud
  module CandlepinCache
    extend ActiveSupport::Concern

    def upstream_owner(org)
      # We use a cache because owner_details is a call to Candlepin
      Rails.cache.fetch("rh_cloud_upstream_owner_#{org.id}", expires_in: 1.minute) do
        org.owner_details['upstreamConsumer']
      end
    end

    def cp_owner_id(org)
      owner = upstream_owner(org)
      owner['uuid'] if owner
    end

    def candlepin_id_cert(org)
      owner = upstream_owner(org)
      return unless owner
      id_cert = {
        cert: owner.dig('idCert', 'cert'),
        key: owner.dig('idCert', 'key'),
      }
      return unless id_cert.values.all?
      id_cert
    end
  end
end

Version data entries

81 entries across 81 versions & 1 rubygems

Version Path
foreman_rh_cloud-3.0.26 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.26 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.25.1 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.25 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.25 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.24.1 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.24.1 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.24 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.24 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.23 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.23 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.22 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.22 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.21.1 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.21.1 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.21 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.20 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.19 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.18.1 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.18 app/controllers/concerns/insights_cloud/candlepin_cache.rb