Class: ConfigKit::Manager
- Inherits:
-
Object
- Object
- ConfigKit::Manager
- Defined in:
- lib/config_kit/manager.rb
Defined Under Namespace
Classes: IDCEnvMissing
Class Method Summary collapse
- .bootstrap(app, from, uri_kls, version, opts = {}) ⇒ Object
- .deploy(app, version, opts = {}) ⇒ Object
- .describe(app, version, opts = {}) ⇒ Object
- .get(app, opts = {}) ⇒ Object
- .init(name, env = 'int0', codename = 'int0', opts = {}) ⇒ Object
- .rollback(app, version, opts = {}) ⇒ Object
Instance Method Summary collapse
- #bootstrap ⇒ Object
- #change_default ⇒ Object
- #create(extra = :no_default) ⇒ Object
- #deploy ⇒ Object
- #describe ⇒ Object
- #get ⇒ Object
- #get_deploy_info(config_data) ⇒ Object
- #init ⇒ Object
-
#initialize(app, opts) ⇒ Manager
constructor
A new instance of Manager.
- #rollback ⇒ Object
Constructor Details
#initialize(app, opts) ⇒ Manager
Returns a new instance of Manager.
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/config_kit/manager.rb', line 41 def initialize(app, opts) @app = app @opts = opts @tool = ConfigKit::Tool.new unless opts['skip_codename_check'] == true codename = @tool.get_idc_codename env = @tool.get_idc_env raise ConfigKit::Manager::IDCEnvMissing.new 'IDC environment/codename missing, pls init it first!' if codename.nil? && env.nil? @opts['codename'] = codename @opts['env'] = env end end |
Class Method Details
.bootstrap(app, from, uri_kls, version, opts = {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/config_kit/manager.rb', line 6 def self.bootstrap(app, from, uri_kls, version, opts={}) opts['uri_kls'] = uri_kls opts['version'] = version opts['from'] = from new(app, opts).bootstrap end |
.deploy(app, version, opts = {}) ⇒ Object
23 24 25 26 |
# File 'lib/config_kit/manager.rb', line 23 def self.deploy(app, version, opts={}) opts['version'] = version new(app, opts).deploy end |
.describe(app, version, opts = {}) ⇒ Object
13 14 15 16 |
# File 'lib/config_kit/manager.rb', line 13 def self.describe(app, version, opts={}) opts['version'] = version new(app, opts).describe end |
.get(app, opts = {}) ⇒ Object
37 38 39 |
# File 'lib/config_kit/manager.rb', line 37 def self.get(app,opts={}) new(app, opts).get end |
.init(name, env = 'int0', codename = 'int0', opts = {}) ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/config_kit/manager.rb', line 28 def self.init(name, env='int0', codename='int0', opts={}) app = 'idc' opts['name'] = name opts['env'] = env opts['codename'] = codename opts['skip_codename_check'] = true new(app,opts).init end |
.rollback(app, version, opts = {}) ⇒ Object
18 19 20 21 |
# File 'lib/config_kit/manager.rb', line 18 def self.rollback(app, version, opts={}) opts['version'] = version new(app, opts).rollback end |
Instance Method Details
#bootstrap ⇒ Object
68 69 70 71 |
# File 'lib/config_kit/manager.rb', line 68 def bootstrap create {app: @app, version: @opts['version']} end |
#change_default ⇒ Object
103 104 105 |
# File 'lib/config_kit/manager.rb', line 103 def change_default @tool.deploy_txn(@app, @opts['version'], :default_only) end |
#create(extra = :no_default) ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/config_kit/manager.rb', line 73 def create(extra=:no_default) ConfigKit::Data::Loader.load(@app, @opts['from'], @opts['uri_kls'], @opts['env'], @opts['codename'], @opts['version']) do |data| @tool.init_txn data.each_pair do |k,v| @tool.bootstrap_txn(v, k) version, cs = get_deploy_info(@tool.config_data) @tool.deploy_txn(k, version, extra,cs) end @tool.perform_txn end end |
#deploy ⇒ Object
95 96 97 |
# File 'lib/config_kit/manager.rb', line 95 def deploy change_default end |
#describe ⇒ Object
63 64 65 66 |
# File 'lib/config_kit/manager.rb', line 63 def describe version = @opts['version'] @tool.describe(@app, version) end |
#get ⇒ Object
90 91 92 93 |
# File 'lib/config_kit/manager.rb', line 90 def get data = @tool.get(@app)[@app] data || {} end |
#get_deploy_info(config_data) ⇒ Object
85 86 87 88 |
# File 'lib/config_kit/manager.rb', line 85 def get_deploy_info(config_data) return [] unless config_data.kind_of?(ConfigKit::ConfigData) [config_data.data_version, config_data.data_cs] end |
#init ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/config_kit/manager.rb', line 54 def init name = @opts.delete('name') env = @opts.delete('env') codename = @opts.delete('codename') @tool.init_txn @tool.idc_init_txn(name, env, codename, @opts) @tool.perform_txn end |
#rollback ⇒ Object
99 100 101 |
# File 'lib/config_kit/manager.rb', line 99 def rollback change_default end |