Skip to content

Commit

Permalink
Point claw to github instead of AWS
Browse files Browse the repository at this point in the history
- Remove edge endpoint given that it was pointing to versions from 2022
  which means there are no usages of it.

Signed-off-by: João Pereira <[email protected]>
  • Loading branch information
joaopapereira authored and a-b committed Nov 13, 2024
1 parent 045db9d commit d218117
Show file tree
Hide file tree
Showing 2 changed files with 112 additions and 298 deletions.
73 changes: 3 additions & 70 deletions claw.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,6 @@
windows64-exe
].freeze

EDGE_ARCHITECTURES = %w[
linux32
linux64
linuxarm64
macosx64
macosarm
windows32
windows64
].freeze

SUPPORTED_CLI_VERSIONS = [
'v6',
'v7',
Expand All @@ -61,13 +51,8 @@
.max
.to_s

if ENV['ENVIRONMENT'] == "prod"
APT_REPO = 'https://cf-cli-debian-repo.s3.amazonaws.com/'
RPM_REPO = 'https://cf-cli-rpm-repo.s3.amazonaws.com/'
else
APT_REPO = 'https://cf-cli-dev.s3.amazonaws.com/cf-cli-debian-repo'
RPM_REPO = 'https://cf-cli-dev.s3.amazonaws.com/cf-cli-rpm-repo'
end
APT_REPO = 'https://cf-cli-debian-repo.s3.amazonaws.com/'
RPM_REPO = 'https://cf-cli-rpm-repo.s3.amazonaws.com/'

unless ENV.key?('GPG_KEY')
puts 'Expected a GPG_KEY env var but it was not set'
Expand Down Expand Up @@ -99,11 +84,6 @@ class Claw < Sinatra::Base
ENV['GPG_KEY']
end

get '/edge' do
redirect_link = get_edge_redirect_link(params['version'], params['arch'])
redirect redirect_link, 302
end

get '/stable' do
redirect_url = get_stable_redirect_link(params['version'], params['release'])
redirect redirect_url, 302
Expand Down Expand Up @@ -159,46 +139,6 @@ def get_version_from_filename(filename)
match[:version]
end

def get_edge_redirect_link(query_param_version, query_param_arch)
cli_version = query_param_version || ENV['CURRENT_MAJOR_VERSION']

unless SUPPORTED_CLI_VERSIONS.include?(cli_version)
halt 400, "Invalid 'version' query parameter, only #{SUPPORTED_CLI_VERSIONS.join(', ')} or null are allowed"
end

unless EDGE_ARCHITECTURES.include?(query_param_arch)
halt 412, "Invalid 'arch' value, please select one of the following edge: #{EDGE_ARCHITECTURES.join(', ')}"
end

version = cli_version.delete('^0-9')
filename = architecture_to_filename(version, query_param_arch)
link = get_versioned_edge_link(version, filename)
end

def architecture_to_filename(version, architecture)
suffix = version == '6' ? '' : version

{
'linux32' => "cf#{suffix}-cli_edge_linux_i686.tgz",
'linux64' => "cf#{suffix}-cli_edge_linux_x86-64.tgz",
'linuxarm64' => "cf#{suffix}-cli_edge_linux_arm64.tgz",
'macosx64' => "cf#{suffix}-cli_edge_osx.tgz",
'macosarm' => "cf#{suffix}-cli_edge_macosarm.tgz",
'windows32' => "cf#{suffix}-cli_edge_win32.zip",
'windows64' => "cf#{suffix}-cli_edge_winx64.zip"
}[architecture]
end

def get_versioned_edge_link(version, file_name)
bucket_prefix = version == '6' ? '' : "v#{version}-"

if ENV['ENVIRONMENT'] == "prod"
"https://#{bucket_prefix}cf-cli-releases.s3.amazonaws.com/master/#{file_name}"
else
"https://cf-cli-dev.s3.amazonaws.com/#{bucket_prefix}cf-cli-releases/master/#{file_name}"
end
end

def get_stable_redirect_link(query_param_version, query_param_release)
cli_version = query_param_version || ENV['CURRENT_MAJOR_VERSION']

Expand Down Expand Up @@ -252,14 +192,7 @@ def release_to_filename(release, version)
end

def get_versioned_release_link(version, release)
major_version = Semantic::Version.new(version).major
bucket_prefix = major_version == 6 ? '' : "v#{major_version}-"

if ENV['ENVIRONMENT'] == "prod"
"https://s3-us-west-1.amazonaws.com/#{bucket_prefix}cf-cli-releases/releases/v#{version}/#{release}"
else
"https://cf-cli-dev.s3.amazonaws.com/#{bucket_prefix}cf-cli-releases/releases/v#{version}/#{release}"
end
"https://github.com/cloudfoundry/cli/releases/download/v#{version}/#{release}"
end

run! if app_file == $PROGRAM_NAME
Expand Down
Loading

0 comments on commit d218117

Please sign in to comment.