Sha256: a2ee8e2a37cf2d62be42084e16c026e8c1401db76711be186d35f0fdaa7c32b2

Contents?: true

Size: 697 Bytes

Versions: 82

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

82 entries across 82 versions & 1 rubygems

Version Path
foreman_rh_cloud-5.0.39 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.38 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.35 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.37 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.36 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.35 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.34 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.33 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.32 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.32 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.32 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.31 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.31 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.30 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.30 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.29 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-4.0.29 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.29 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-3.0.28 app/controllers/concerns/insights_cloud/candlepin_cache.rb
foreman_rh_cloud-5.0.28 app/controllers/concerns/insights_cloud/candlepin_cache.rb