Skip to content

Commit

Permalink
Remove Google Analytics and upgrade Ruby to 3.2 (#78)
Browse files Browse the repository at this point in the history
* Remove Google Analytics

* Bump Ruby version to 3.3

- Remove explicit stack version from manifest, this shouldn't
be necessary since cflinuxfs4 is now the default and supported
by this app

* Bump Ruby Version in Github Action

* Use Ruby 3.2

- This Ruby version has more support in our dev envs
and aligns with capi-release
  • Loading branch information
tcdowney authored Apr 12, 2024
1 parent 88c2788 commit ee8b129
Show file tree
Hide file tree
Showing 10 changed files with 4 additions and 46 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.6']
ruby-version: ['3.2']

steps:
- uses: actions/checkout@v3
Expand Down
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.2.3
3 changes: 1 addition & 2 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# frozen_string_literal: true
ruby '~>2.6'
ruby '~>3.2'

source 'http://rubygems.org'

gem 'gabba'
gem 'rake'
gem 'semantic'
gem 'sinatra'
Expand Down
4 changes: 1 addition & 3 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
GEM
remote: http://rubygems.org/
specs:
gabba (1.0.1)
kgio (2.11.4)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
Expand Down Expand Up @@ -31,7 +30,6 @@ PLATFORMS
ruby

DEPENDENCIES
gabba
rack-test
rake
semantic
Expand All @@ -40,7 +38,7 @@ DEPENDENCIES
unicorn

RUBY VERSION
ruby 2.6.8p205
ruby 3.3.0p0

BUNDLED WITH
2.1.4
26 changes: 0 additions & 26 deletions claw.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# frozen_string_literal: true

require 'sinatra'
require 'gabba'
require 'semantic'
require 'json'

Expand Down Expand Up @@ -69,11 +68,6 @@
RPM_REPO = 'https://cf-cli-dev.s3.amazonaws.com/cf-cli-rpm-repo'
end

unless ENV.key?('GA_TRACKING_ID') && ENV.key?('GA_DOMAIN')
puts 'Expected a Google Analytics env vars but they were not set'
exit 1
end

unless ENV.key?('GPG_KEY')
puts 'Expected a GPG_KEY env var but it was not set'
exit 1
Expand All @@ -95,17 +89,6 @@
end

class Claw < Sinatra::Base
before do
@google_analytics = Gabba::Gabba.new(ENV['GA_TRACKING_ID'], ENV['GA_DOMAIN'], request.user_agent)
accept_language = request.env['HTTP_ACCEPT_LANGUAGE']
@google_analytics.utmul = accept_language if accept_language

@google_analytics.set_custom_var(1, 'ip', request.ip, 3)
@google_analytics.set_custom_var(2, 'source', params['source'], 3)
@google_analytics.set_custom_var(3, 'referer', request.referer, 3)
@google_analytics.set_custom_var(4, 'host', request.host, 3)
end

get '/ping' do
'pong'
end
Expand All @@ -117,48 +100,40 @@ class Claw < Sinatra::Base

get '/edge' do
redirect_link = get_edge_redirect_link(params['version'], params['arch'])
@google_analytics.page_view('edge', "edge/#{params['arch']}")
redirect redirect_link, 302
end

get '/stable' do
redirect_url = get_stable_redirect_link(params['version'], params['release'])
@google_analytics.page_view('stable', "stable/#{params['release']}/#{params['version']}")
redirect redirect_url, 302
end

get '/homebrew' do
@google_analytics.set_custom_var(2, 'source', 'homebrew', 3)

unless AVAILABLE_VERSIONS.include?(params['version'])
halt 412, "Invalid version, please select one of the following versions: #{AVAILABLE_VERSIONS.join(', ')}"
end

@google_analytics.page_view('stable', "stable/#{params['arch']}-binary/#{params['version']}")

redirect get_versioned_release_link(params['version'], release_to_filename("#{params['arch']}-binary", params['version'])), 302
end

get '/debian/dists/*' do
page = File.join('dists', params['splat'].first)
@google_analytics.page_view('debian', page)
redirect File.join(APT_REPO, page), 302
end

get '/fedora/cloudfoundry-cli.repo' do
@google_analytics.page_view('fedora', 'cloudfoundry-cli.repo')
redirect File.join(RPM_REPO, 'cloudfoundry-cli.repo'), 302
end

get '/fedora/repodata/*' do
page = File.join('repodata', params['splat'].first)
@google_analytics.page_view('fedora', page)
redirect File.join(RPM_REPO, page), 302
end

get '/debian/pool/*' do
page = File.join('pool', params['splat'].first)
@google_analytics.page_view('debian', page)

filename = page.split('/').last
version = get_version_from_filename(filename)
Expand All @@ -172,7 +147,6 @@ class Claw < Sinatra::Base

get '/fedora/releases/*' do
page = File.join('releases', params['splat'].first)
@google_analytics.page_view('fedora', page)

filename = page.split('/').last
version = get_version_from_filename(filename)
Expand Down
2 changes: 0 additions & 2 deletions claw_test.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

ENV['RACK_ENV'] = 'test'
ENV['GA_TRACKING_ID'] = 'dummy_id'
ENV['GA_DOMAIN'] = 'dummy.domain.example.com'
ENV['GPG_KEY'] = 'dummy-key'
ENV['AVAILABLE_VERSIONS'] = '["6.12.4", "6.13.0", "7.0.0-beta.24", "8.0.0", "8.0.1"]'
ENV['CURRENT_MAJOR_VERSION'] = 'v7'
Expand Down
3 changes: 0 additions & 3 deletions manifest-oss-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ applications:
- name: claw-dev
buildpack: ruby_buildpack
instances: 2
stack: cflinuxfs3
env:
AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS))
CURRENT_MAJOR_VERSION: v7
ENVIRONMENT: dev
GA_DOMAIN: pivotal.io
GA_TRACKING_ID: UA-52116311-1
GPG_KEY: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Expand Down
3 changes: 0 additions & 3 deletions manifest-oss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ applications:
- name: claw
buildpack: ruby_buildpack
instances: 2
stack: cflinuxfs3
env:
AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS))
CURRENT_MAJOR_VERSION: v6
ENVIRONMENT: prod
GA_DOMAIN: pivotal.io
GA_TRACKING_ID: UA-52116311-1
GPG_KEY: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Expand Down
3 changes: 0 additions & 3 deletions manifest-pivotal-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ applications:
- name: claw-dev
buildpack: ruby_buildpack
instances: 2
stack: cflinuxfs3
env:
AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS))
CURRENT_MAJOR_VERSION: v7
ENVIRONMENT: dev
GA_DOMAIN: pivotal.io
GA_TRACKING_ID: UA-52116311-1
GPG_KEY: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Expand Down
3 changes: 0 additions & 3 deletions manifest-pivotal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,10 @@ applications:
- name: claw
buildpack: ruby_buildpack
instances: 2
stack: cflinuxfs3
env:
AVAILABLE_VERSIONS: ((AVAILABLE_VERSIONS))
CURRENT_MAJOR_VERSION: v6
ENVIRONMENT: prod
GA_DOMAIN: pivotal.io
GA_TRACKING_ID: UA-52116311-1
GPG_KEY: |
-----BEGIN PGP PUBLIC KEY BLOCK-----
Expand Down

0 comments on commit ee8b129

Please sign in to comment.