Skip to content

Commit

Permalink
Drop JsonSchema and use Membrane / vcap_common-2.0.0.
Browse files Browse the repository at this point in the history
Change-Id: Idc12d214d3cd4a05ab875f04dd1b3c738b16efbb
  • Loading branch information
Kowshik Prakasam committed Jul 16, 2012
1 parent 91b8cd6 commit ab96005
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 28 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Expand Up @@ -5,9 +5,9 @@ gem 'nats'
gem 'rake'
gem 'yajl-ruby', '>= 0.7.9'

gem 'vcap_common', '~> 1.0.8', :git => 'https://github.com/cloudfoundry/vcap-common.git', :ref => 'f6ffe9ad'
gem 'vcap_common', '2.0.0', :git => 'https://github.com/cloudfoundry/vcap-common.git'
gem 'vcap_logging', '>= 0.1.3', :git => 'https://github.com/cloudfoundry/common.git', :ref => 'b96ec119'
gem 'vcap_staging', '~> 0.1.60', :git => 'https://github.com/cloudfoundry/vcap-staging.git', :ref => '0b9a6c47'
gem 'vcap_staging', '~> 0.1.61', :git => 'https://github.com/cloudfoundry/vcap-staging.git'
gem 'vcap-concurrency', '~> 0.1.0', :git => 'https://github.com/cloudfoundry/vcap-concurrency.git', :ref => 'be2bdb9f'
gem 'stager-client', '~> 0.0.2', :git => 'https://github.com/cloudfoundry/stager-client.git', :ref => 'fdaae720'

Expand Down
20 changes: 10 additions & 10 deletions Gemfile.lock
Expand Up @@ -25,11 +25,11 @@ GIT

GIT
remote: https://github.com/cloudfoundry/vcap-common.git
revision: f6ffe9add54b55eaf428556147d61f3d64508cd8
ref: f6ffe9ad
revision: 5334b662238f14ed2ddbb80f524dcf8cdd0eaadf
specs:
vcap_common (1.0.9)
eventmachine (~> 0.12.11.cloudfoundry.3)
vcap_common (2.0.0)
eventmachine
membrane
nats (~> 0.4.22.beta.8)
posix-spawn (~> 0.3.6)
thin (~> 1.3.1)
Expand All @@ -44,10 +44,9 @@ GIT

GIT
remote: https://github.com/cloudfoundry/vcap-staging.git
revision: 0b9a6c47b42783e10e071328a25150df6943a385
ref: 0b9a6c47
revision: 910bda9fa69504fbe2202edceb8d0b7d1d253fb7
specs:
vcap_staging (0.1.60)
vcap_staging (0.1.61)
nokogiri (>= 1.4.4)
rake
rspec
Expand All @@ -65,6 +64,7 @@ GEM
daemons (1.1.8)
diff-lcs (1.1.3)
json_pure (1.6.5)
membrane (0.0.1)
nats (0.4.22)
daemons (>= 1.1.4)
eventmachine (>= 0.12.10)
Expand All @@ -90,7 +90,7 @@ GEM
eventmachine (>= 0.12.6)
rack (>= 1.0.0)
tilt (1.3.2)
uuidtools (2.1.2)
uuidtools (2.1.3)
webmock (1.7.4)
addressable (~> 2.2, > 2.2.5)
crack (>= 0.1.7)
Expand All @@ -108,8 +108,8 @@ DEPENDENCIES
sinatra
stager-client (~> 0.0.2)!
vcap-concurrency (~> 0.1.0)!
vcap_common (~> 1.0.8)!
vcap_common (= 2.0.0)!
vcap_logging (>= 0.1.3)!
vcap_staging (~> 0.1.60)!
vcap_staging (~> 0.1.61)!
webmock
yajl-ruby (>= 0.7.9)
3 changes: 2 additions & 1 deletion bin/stager
Expand Up @@ -6,6 +6,7 @@ require 'bundler/setup'

$LOAD_PATH.unshift(File.expand_path('../../lib', __FILE__))

require 'membrane'
require 'vcap/common'
require 'vcap/component'
require 'vcap/concurrency'
Expand All @@ -30,7 +31,7 @@ end.parse!

begin
config = VCAP::Stager::Config.from_file(config_file)
rescue VCAP::JsonSchema::ValidationError => ve
rescue Membrane::SchemaValidationError => ve
puts "ERROR: There was a problem validating the supplied config: #{ve}"
exit 1
rescue => e
Expand Down
4 changes: 2 additions & 2 deletions lib/vcap/stager/config.rb
@@ -1,5 +1,5 @@
require 'vcap/config'
require 'vcap/json_schema'
require 'membrane'
require 'vcap/staging/plugin/common'

module VCAP
Expand Down Expand Up @@ -28,7 +28,7 @@ class VCAP::Stager::Config < VCAP::Config
optional(:tmp) => String, # Default is /tmp
},

:secure => VCAP::JsonSchema::BoolSchema.new,
:secure => bool,

optional(:index) => Integer, # Component index (stager-0, stager-1, etc)
optional(:ruby_path) => String, # Full path to the ruby executable that should execute the run plugin script
Expand Down
1 change: 0 additions & 1 deletion lib/vcap/stager/server.rb
Expand Up @@ -2,7 +2,6 @@
require 'yajl'

require 'vcap/component'
require 'vcap/json_schema'
require 'vcap/logging'

require 'vcap/stager/task'
Expand Down
15 changes: 9 additions & 6 deletions lib/vcap/stager/task_error.rb
@@ -1,6 +1,7 @@
require 'yajl'

require 'vcap/json_schema'
require 'membrane'
require 'vcap/common'

module VCAP
module Stager
Expand All @@ -10,9 +11,10 @@ module Stager
# state. All other errors thrown during VCAP::Stager::Task#perform will be
# logged and re-raised (probably causing the program to crash).
class TaskError < StandardError
SCHEMA = VCAP::JsonSchema.build do
{ :class => String,
optional(:details) => String,
SCHEMA = Membrane::SchemaParser.parse do
{
:class => String,
optional(:details) => String
}
end

Expand All @@ -29,9 +31,10 @@ def set_desc(desc)

def decode(enc_err)
dec_err = Yajl::Parser.parse(enc_err)
dec_err = VCAP.symbolize_keys(dec_err)
SCHEMA.validate(dec_err)
err_class = dec_err['class'].split('::').last
VCAP::Stager.const_get(err_class.to_sym).new(dec_err['details'])
err_class = dec_err[:class].split('::').last
VCAP::Stager.const_get(err_class.to_sym).new(dec_err[:details])
end
end

Expand Down
11 changes: 6 additions & 5 deletions lib/vcap/stager/task_result.rb
@@ -1,14 +1,14 @@
require 'yajl'

require 'vcap/json_schema'
require 'membrane'
require 'vcap/common'

module VCAP
module Stager
end
end

class VCAP::Stager::TaskResult
SCHEMA = VCAP::JsonSchema.build do
SCHEMA = Membrane::SchemaParser.parse do
{ :task_id => String,
:task_log => String,
optional(:error) => String,
Expand All @@ -18,9 +18,10 @@ class VCAP::Stager::TaskResult
class << self
def decode(enc_res)
dec_res = Yajl::Parser.parse(enc_res)
dec_res = VCAP.symbolize_keys(dec_res)
SCHEMA.validate(dec_res)
dec_res['error'] = VCAP::Stager::TaskError.decode(dec_res['error']) if dec_res['error']
VCAP::Stager::TaskResult.new(dec_res['task_id'], dec_res['task_log'], dec_res['error'])
dec_res[:error] = VCAP::Stager::TaskError.decode(dec_res[:error]) if dec_res[:error]
VCAP::Stager::TaskResult.new(dec_res[:task_id], dec_res[:task_log], dec_res[:error])
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/vcap/stager/version.rb
@@ -1,5 +1,5 @@
module VCAP
module Stager
VERSION = '0.1.14'
VERSION = '0.1.15'
end
end

0 comments on commit ab96005

Please sign in to comment.