config_kit 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module ConfigKit
2
+ VERSION = '0.0.11'
3
+ end
@@ -0,0 +1,56 @@
1
+ require 'yaml'
2
+ require 'diplomat'
3
+
4
+ class SlashedHash < ::Hash
5
+ def initialize(hash, keep_nesting=false)
6
+ self.merge!(hash) if keep_nesting
7
+
8
+ self.merge!(dot_flattened(hash))
9
+ SlashedHash.symbolize(self)
10
+ end
11
+
12
+ def inspect
13
+ "#<#{self.class.name}:#{object_id} #{super}>"
14
+ end
15
+
16
+ def to_hash
17
+ {}.replace(self)
18
+ end
19
+
20
+ def self.symbolize(hash)
21
+ hash.keys.each do |key|
22
+ hash[key.to_sym] = hash.delete(key)
23
+ end
24
+ end
25
+
26
+ protected
27
+ # turns {'a' => {'b' => 'c'}} into {'a.b' => 'c'}
28
+ def dot_flattened(nested_hash, names=[], result={})
29
+ nested_hash.each do |key, val|
30
+ next if val == nil
31
+ if val.respond_to?(:has_key?)
32
+ dot_flattened(val, names + [key], result)
33
+ else
34
+ result[(names + [key]).join('/')] = val
35
+ end
36
+ end
37
+ result
38
+ end
39
+
40
+ end
41
+
42
+ files = Dir["/opt/workspace/project/open_platform/config_map/config/**/*.yml"]
43
+
44
+ Diplomat.configure do |config|
45
+ config.url = 'http://localhost:8500'
46
+ #config.url = 'http://pwd10_0_29_3-8500.host2.labs.play-with-docker.com/'
47
+ end
48
+ files.each do |f|
49
+ k_v = SlashedHash.new(YAML.load_file(f))
50
+
51
+ # k_v.each_pair do |k, v|
52
+ # puts "key: #{k}"
53
+ # puts "values: #{v}"
54
+ # Diplomat::Kv.put(k,v.to_s)
55
+ # end
56
+ end
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+
3
+ CONSUL_SERVER='http://pwd10_0_38_4-8500.host1.labs.play-with-docker.com/'
4
+
5
+ KEY="config/axle/data"
6
+ VALUE="config/default.yml"
7
+ curl -X PUT --data-binary @${VALUE} \
8
+ -H "Content-type: text/x-yaml" \
9
+ ${CONSUL_SERVER}v1/kv/${KEY}
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: config_kit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.11
5
+ platform: ruby
6
+ authors:
7
+ - Ben Wu
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rspec
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: diplomat
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 1.4.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.4.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: git
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.0
69
+ description: Write a longer description or delete this line.
70
+ email:
71
+ - ben.wu@laxino.com
72
+ executables:
73
+ - ck
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - ".gitignore"
78
+ - Gemfile
79
+ - Gemfile.lock
80
+ - README.md
81
+ - bin/ck
82
+ - cluster/consul.yml
83
+ - config/README.md
84
+ - config/int0/int0.axle.yml
85
+ - config/int0/int0.infra.yml
86
+ - config/stg0/stg0.axle.yml
87
+ - config/stg0/stg0.infra.yml
88
+ - config_kit.gemspec
89
+ - lib/config_kit.rb
90
+ - lib/config_kit/cli/command.rb
91
+ - lib/config_kit/cli/commands/bootstrap.rb
92
+ - lib/config_kit/cli/commands/deploy.rb
93
+ - lib/config_kit/cli/commands/describe.rb
94
+ - lib/config_kit/cli/commands/get.rb
95
+ - lib/config_kit/cli/commands/init.rb
96
+ - lib/config_kit/cli/commands/rollback.rb
97
+ - lib/config_kit/client.rb
98
+ - lib/config_kit/config_data.rb
99
+ - lib/config_kit/configuration.rb
100
+ - lib/config_kit/data/loader.rb
101
+ - lib/config_kit/data/loaders/file_loader.rb
102
+ - lib/config_kit/data/loaders/git_loader.rb
103
+ - lib/config_kit/deploy_data.rb
104
+ - lib/config_kit/error.rb
105
+ - lib/config_kit/ext/hash.rb
106
+ - lib/config_kit/ext/slashed_hash.rb
107
+ - lib/config_kit/idc_data.rb
108
+ - lib/config_kit/manager.rb
109
+ - lib/config_kit/tool.rb
110
+ - lib/config_kit/version.rb
111
+ - scripts/create_config_kit.rb
112
+ - scripts/profile_to_consul.sh
113
+ homepage: http://github.com/cheokman
114
+ licenses:
115
+ - MIT
116
+ - Ruby
117
+ metadata:
118
+ allowed_push_host: https://rubygems.org
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.6.8
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Write a short summary, because Rubygems requires one.
139
+ test_files: []