From 7e005aad1baa7cc5de18f36346a2547f5013d32f Mon Sep 17 00:00:00 2001 From: Sven Fuchs Date: Sun, 10 Feb 2013 19:50:01 +0100 Subject: [PATCH] use travis-core/sf-log-models --- Gemfile | 2 +- Gemfile.lock | 17 +++++++++-------- lib/travis/api/app/endpoint/artifacts.rb | 12 +++--------- lib/travis/api/app/endpoint/jobs.rb | 2 +- lib/travis/api/app/endpoint/logs.rb | 21 +++++++++++++++++++++ lib/travis/api/app/responders/plain.rb | 4 ++-- 6 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 lib/travis/api/app/endpoint/logs.rb diff --git a/Gemfile b/Gemfile index b0810ca4..d28ce3bb 100644 --- a/Gemfile +++ b/Gemfile @@ -3,7 +3,7 @@ ruby '1.9.3' rescue nil source :rubygems gemspec -gem 'travis-core', github: 'travis-ci/travis-core' +gem 'travis-core', github: 'travis-ci/travis-core', branch: 'sf-log-models' gem 'travis-support', github: 'travis-ci/travis-support' gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: 'cde9741' gem 'sinatra' #github: 'sinatra/sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index 37d09bf7..57646ac4 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,8 +1,8 @@ GIT remote: git://github.com/getsentry/raven-ruby.git - revision: 0bf46f9e957b179a5d0ce1295840eaff89d8146a + revision: f6a97f1544480645c4dfdb4d1e9e97ede1e737a9 specs: - sentry-raven (0.4.2) + sentry-raven (0.4.3) faraday (>= 0.7.6) hashie multi_json (~> 1.0) @@ -45,7 +45,8 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 4d4fc4f4d18624278ad552d037a574ce8fdd77b0 + revision: 258d823c367a13db76db87d2f42942ee7af8a041 + branch: sf-log-models specs: travis-core (0.0.1) actionmailer (~> 3.2.11) @@ -161,7 +162,7 @@ GEM hashie (1.2.0) hashr (0.0.22) hike (1.2.1) - hitimes (1.1.1) + hitimes (1.2.0) hubble (0.1.2) yajl-ruby (~> 1.1) i18n (0.6.1) @@ -178,7 +179,7 @@ GEM atomic (~> 1.0) avl_tree (~> 1.1.2) hitimes (~> 1.1) - mime-types (1.20.1) + mime-types (1.21) mocha (0.13.2) metaclass (~> 0.0.1) multi_json (1.5.0) @@ -204,7 +205,7 @@ GEM pusher (0.11.3) multi_json (~> 1.0) signature (~> 0.1.6) - rack (1.4.4) + rack (1.4.5) rack-cache (1.2) rack (>= 0.4) rack-protection (1.3.2) @@ -228,7 +229,7 @@ GEM redis (3.0.2) redis-namespace (1.2.1) redis (~> 3.0.0) - rerun (0.7.1) + rerun (0.8.0) listen rollout (1.1.0) rspec (2.12.0) @@ -276,7 +277,7 @@ GEM tzinfo (0.3.35) uuidtools (2.1.3) yajl-ruby (1.1.0) - yard (0.8.3) + yard (0.8.4.1) PLATFORMS ruby diff --git a/lib/travis/api/app/endpoint/artifacts.rb b/lib/travis/api/app/endpoint/artifacts.rb index 1c718e81..4f465f97 100644 --- a/lib/travis/api/app/endpoint/artifacts.rb +++ b/lib/travis/api/app/endpoint/artifacts.rb @@ -4,18 +4,12 @@ class Travis::Api::App class Endpoint # Artifacts are generated by builds. Currently we only expose logs as # artifacts + # + # DEPRECATED will be removed as soon as the client uses /logs/:id class Artifacts < Endpoint # Fetches an artifact by it's *id*. get '/:id' do |id| - respond_with service(:find_artifact, params) - end - - put '/:id' do |id| - # TODO @rkh ... rather lost in the auth/scopes code. - token = env['HTTP_TOKEN'] - halt 403, 'no token' unless token - halt 403, 'internal' unless token == Travis.config.tokens.internal - respond_with service(:update_artifact, params) + respond_with service(:find_log, params) end end end diff --git a/lib/travis/api/app/endpoint/jobs.rb b/lib/travis/api/app/endpoint/jobs.rb index 3759316c..966ef7cd 100644 --- a/lib/travis/api/app/endpoint/jobs.rb +++ b/lib/travis/api/app/endpoint/jobs.rb @@ -12,7 +12,7 @@ class Travis::Api::App end get '/:job_id/log' do - resource = service(:find_artifact, params).run + resource = service(:find_log, params).run if !resource || resource.archived? archived_log_path = archive_url("/jobs/#{params[:job_id]}/log.txt") diff --git a/lib/travis/api/app/endpoint/logs.rb b/lib/travis/api/app/endpoint/logs.rb new file mode 100644 index 00000000..83692be5 --- /dev/null +++ b/lib/travis/api/app/endpoint/logs.rb @@ -0,0 +1,21 @@ +require 'travis/api/app' + +class Travis::Api::App + class Endpoint + # Logs are generated by builds. + class Logs < Endpoint + # Fetches a log by it's *id*. + get '/:id' do |id| + respond_with service(:find_log, params) + end + + put '/:id' do |id| + # TODO @rkh ... rather lost in the auth/scopes code. + token = env['HTTP_TOKEN'] + halt 403, 'no token' unless token + halt 403, 'internal' unless token == Travis.config.tokens.internal + respond_with service(:update_log, params) + end + end + end +end diff --git a/lib/travis/api/app/responders/plain.rb b/lib/travis/api/app/responders/plain.rb index 89328c96..c1bc0dfa 100644 --- a/lib/travis/api/app/responders/plain.rb +++ b/lib/travis/api/app/responders/plain.rb @@ -1,12 +1,12 @@ module Travis::Api::App::Responders class Plain < Base def apply? - # make sure that we don't leak anything by processing only Artifact::Log + # make sure that we don't leak anything by processing only Log # instances here. I don't want to create entire new API builder just # for log's content for now. # # TODO: think how to handle other formats correctly - options[:format] == 'txt' && resource.is_a?(Artifact::Log) + options[:format] == 'txt' && resource.is_a?(Log) end def apply