Skip to content

Commit

Permalink
Force fbcdn only for cpe devices
Browse files Browse the repository at this point in the history
Summary: ```

Differential Revision: D60636881

fbshipit-source-id: ac8e07e1708c61e1ed2d692d8725e58af5c2ea01
  • Loading branch information
Greg Batye authored and facebook-github-bot committed Aug 5, 2024
1 parent ca5774e commit 7502045
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions itchef/cookbooks/cpe_remote/attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@
'base_url' => 'MY DISTRO SERVER/chef',
'server_accessible' => true,
'additional_headers' => {},
'force_cpe_distro' => false,
}
19 changes: 12 additions & 7 deletions itchef/cookbooks/cpe_remote/libraries/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,21 @@
module CPE
module Remote
def gen_url(path, file)
http = node['cpe_remote']['http']
http = ::Chef.node['cpe_remote']['http']

uri = http ? 'http' : 'https'
url = "#{uri}://#{node['cpe_remote']['base_url']}/#{path}/#{file}"
if defined?(CPE::Distro)
cdn_url = CPE::Distro.gen_url_from_api(path, file)
unless cdn_url.nil?
url = cdn_url
end
url = "#{uri}://#{::Chef.node['cpe_remote']['base_url']}/#{path}/#{file}"
if ::Chef.node['cpe_remote']['force_cpe_distro']

url = CPE::Distro.gen_url_from_api(path, file)
end
Chef::Log.info("Source URL: #{url}")
if url.include?('cpespace.thefacebook.com')
Chef::Log.warn(
'[cpe_remote] cpespace.thefacebook.com is being deprecated. Use another source instead',

)
end
url
end

Expand Down
1 change: 1 addition & 0 deletions itchef/cookbooks/cpe_remote/metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@

depends 'cpe_helpers'
depends 'cpe_logger'
depends 'cpe_utils'

0 comments on commit 7502045

Please sign in to comment.