configgin 0.17.0 → 0.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +67 -24
- data/Guardfile +14 -0
- data/bin/configgin +1 -65
- data/lib/base_transmogrifier.rb +31 -0
- data/lib/bosh_deployment_manifest.rb +40 -0
- data/lib/bosh_deployment_manifest_config_transmogrifier.rb +13 -0
- data/lib/cli.rb +5 -0
- data/lib/configgin.rb +108 -0
- data/lib/configgin/version.rb +2 -2
- data/lib/environment_config_transmogrifier.rb +4 -30
- data/lib/job.rb +2 -2
- data/lib/kube_link_generator.rb +1 -1
- data/make/include/darwin-support +1 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2fd6e663cebb90b482b7d3672a7247c0045c0f03
|
4
|
+
data.tar.gz: c3d44b7a474628a4ee744779a0e266ce600efa97
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 50fc06f1a221322027a8b8e8a3765efbeefe072e1c7496362cee129ea2c09d2e57ab9bffeb079f688f9fd4b0ad0e3e88134d4e21fcbf263ec43730d6e6bc6648
|
7
|
+
data.tar.gz: f5994ae6ef79a9e97f0466ced1e8c1c8f4b5bff0fa457be66359a3904fc090c51848238a9530927f659ebe41677108e7774bfb62bf1f47ee8ee1678e61989fc1
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.1
|
1
|
+
2.3.1
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
configgin (0.
|
4
|
+
configgin (0.18.0)
|
5
5
|
bosh-template (~> 2.0)
|
6
6
|
deep_merge (~> 1.1)
|
7
7
|
kubeclient (~> 2.0)
|
@@ -13,13 +13,30 @@ GEM
|
|
13
13
|
specs:
|
14
14
|
addressable (2.5.2)
|
15
15
|
public_suffix (>= 2.0.2, < 4.0)
|
16
|
-
ast (2.
|
16
|
+
ast (2.4.0)
|
17
17
|
bosh-template (2.2.0)
|
18
18
|
semi_semantic (~> 1.2.0)
|
19
|
+
coderay (1.1.2)
|
19
20
|
deep_merge (1.2.1)
|
20
21
|
diff-lcs (1.3)
|
21
22
|
domain_name (0.5.20180417)
|
22
23
|
unf (>= 0.0.5, < 1.0.0)
|
24
|
+
ffi (1.9.25)
|
25
|
+
formatador (0.2.5)
|
26
|
+
guard (2.14.2)
|
27
|
+
formatador (>= 0.2.4)
|
28
|
+
listen (>= 2.7, < 4.0)
|
29
|
+
lumberjack (>= 1.0.12, < 2.0)
|
30
|
+
nenv (~> 0.1)
|
31
|
+
notiffany (~> 0.0)
|
32
|
+
pry (>= 0.9.12)
|
33
|
+
shellany (~> 0.0)
|
34
|
+
thor (>= 0.18.1)
|
35
|
+
guard-compat (1.2.1)
|
36
|
+
guard-rspec (4.7.3)
|
37
|
+
guard (~> 2.1)
|
38
|
+
guard-compat (~> 1.1)
|
39
|
+
rspec (>= 2.99.0, < 4.0)
|
23
40
|
http (2.2.2)
|
24
41
|
addressable (~> 2.3)
|
25
42
|
http-cookie (~> 1.0)
|
@@ -29,51 +46,75 @@ GEM
|
|
29
46
|
domain_name (~> 0.5)
|
30
47
|
http-form_data (1.0.3)
|
31
48
|
http_parser.rb (0.6.0)
|
49
|
+
jaro_winkler (1.5.1)
|
32
50
|
kubeclient (2.5.2)
|
33
51
|
http (>= 0.98, < 3)
|
34
52
|
recursive-open-struct (~> 1.0.0)
|
35
53
|
rest-client
|
54
|
+
listen (3.1.5)
|
55
|
+
rb-fsevent (~> 0.9, >= 0.9.4)
|
56
|
+
rb-inotify (~> 0.9, >= 0.9.7)
|
57
|
+
ruby_dep (~> 1.2)
|
58
|
+
lumberjack (1.0.13)
|
59
|
+
method_source (0.9.0)
|
36
60
|
mime-types (3.2.2)
|
37
61
|
mime-types-data (~> 3.2015)
|
38
62
|
mime-types-data (3.2018.0812)
|
39
63
|
mustache (1.0.5)
|
64
|
+
nenv (0.3.0)
|
40
65
|
netrc (0.11.0)
|
41
|
-
|
42
|
-
|
43
|
-
|
66
|
+
notiffany (0.1.1)
|
67
|
+
nenv (~> 0.1)
|
68
|
+
shellany (~> 0.0)
|
69
|
+
parallel (1.12.1)
|
70
|
+
parser (2.5.1.2)
|
71
|
+
ast (~> 2.4.0)
|
72
|
+
powerpack (0.1.2)
|
73
|
+
pry (0.11.3)
|
74
|
+
coderay (~> 1.1.0)
|
75
|
+
method_source (~> 0.9.0)
|
44
76
|
public_suffix (3.0.3)
|
45
|
-
rainbow (2.
|
46
|
-
|
77
|
+
rainbow (2.2.2)
|
78
|
+
rake
|
79
|
+
rake (10.5.0)
|
80
|
+
rb-fsevent (0.10.3)
|
81
|
+
rb-inotify (0.9.10)
|
82
|
+
ffi (>= 0.5.0, < 2)
|
47
83
|
recursive-open-struct (1.0.5)
|
48
84
|
rest-client (2.0.2)
|
49
85
|
http-cookie (>= 1.0.2, < 2.0)
|
50
86
|
mime-types (>= 1.16, < 4.0)
|
51
87
|
netrc (~> 0.8)
|
52
|
-
rspec (3.
|
53
|
-
rspec-core (~> 3.
|
54
|
-
rspec-expectations (~> 3.
|
55
|
-
rspec-mocks (~> 3.
|
56
|
-
rspec-core (3.
|
57
|
-
rspec-support (~> 3.
|
58
|
-
rspec-expectations (3.
|
88
|
+
rspec (3.8.0)
|
89
|
+
rspec-core (~> 3.8.0)
|
90
|
+
rspec-expectations (~> 3.8.0)
|
91
|
+
rspec-mocks (~> 3.8.0)
|
92
|
+
rspec-core (3.8.0)
|
93
|
+
rspec-support (~> 3.8.0)
|
94
|
+
rspec-expectations (3.8.1)
|
59
95
|
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
-
rspec-support (~> 3.
|
61
|
-
rspec-mocks (3.
|
96
|
+
rspec-support (~> 3.8.0)
|
97
|
+
rspec-mocks (3.8.0)
|
62
98
|
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
-
rspec-support (~> 3.
|
64
|
-
rspec-support (3.
|
65
|
-
rubocop (0.
|
66
|
-
|
99
|
+
rspec-support (~> 3.8.0)
|
100
|
+
rspec-support (3.8.0)
|
101
|
+
rubocop (0.59.2)
|
102
|
+
jaro_winkler (~> 1.5.1)
|
103
|
+
parallel (~> 1.10)
|
104
|
+
parser (>= 2.5, != 2.5.1.1)
|
67
105
|
powerpack (~> 0.1)
|
68
|
-
rainbow (>=
|
106
|
+
rainbow (>= 2.2.2, < 4.0)
|
69
107
|
ruby-progressbar (~> 1.7)
|
70
108
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
71
|
-
ruby-progressbar (1.
|
109
|
+
ruby-progressbar (1.10.0)
|
110
|
+
ruby_dep (1.5.0)
|
72
111
|
semi_semantic (1.2.0)
|
112
|
+
shellany (0.0.1)
|
113
|
+
thor (0.20.0)
|
73
114
|
unf (0.1.4)
|
74
115
|
unf_ext
|
75
116
|
unf_ext (0.0.7.5)
|
76
|
-
unicode-display_width (1.
|
117
|
+
unicode-display_width (1.4.0)
|
77
118
|
|
78
119
|
PLATFORMS
|
79
120
|
ruby
|
@@ -81,9 +122,11 @@ PLATFORMS
|
|
81
122
|
DEPENDENCIES
|
82
123
|
bundler (~> 1.10)
|
83
124
|
configgin!
|
125
|
+
guard
|
126
|
+
guard-rspec
|
84
127
|
rake (~> 10.0)
|
85
128
|
rspec
|
86
129
|
rubocop
|
87
130
|
|
88
131
|
BUNDLED WITH
|
89
|
-
1.16.
|
132
|
+
1.16.4
|
data/Guardfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
2
|
+
require "guard/rspec/dsl"
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
4
|
+
|
5
|
+
# RSpec files
|
6
|
+
rspec = dsl.rspec
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_files)
|
10
|
+
|
11
|
+
# Ruby files
|
12
|
+
ruby = dsl.ruby
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
14
|
+
end
|
data/bin/configgin
CHANGED
@@ -15,68 +15,4 @@ rescue ArgMissingError => e
|
|
15
15
|
exit(1)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
templates = YAML.load_file(options[:env2conf])
|
20
|
-
|
21
|
-
# SVC_ACC_PATH is the location of the service account secrets
|
22
|
-
SVC_ACC_PATH = '/var/run/secrets/kubernetes.io/serviceaccount'.freeze
|
23
|
-
|
24
|
-
kube_client = Kubeclient::Client.new(
|
25
|
-
URI::HTTPS.build(host: ENV['KUBERNETES_SERVICE_HOST'],
|
26
|
-
port: ENV['KUBERNETES_SERVICE_PORT_HTTPS']),
|
27
|
-
'v1',
|
28
|
-
ssl_options: {
|
29
|
-
ca_file: "#{SVC_ACC_PATH}/ca.crt",
|
30
|
-
verify_ssl: OpenSSL::SSL::VERIFY_PEER
|
31
|
-
},
|
32
|
-
auth_options: {
|
33
|
-
bearer_token: File.read("#{SVC_ACC_PATH}/token")
|
34
|
-
}
|
35
|
-
)
|
36
|
-
kube_client_stateful_set = Kubeclient::Client.new(
|
37
|
-
URI::HTTPS.build(host: ENV['KUBERNETES_SERVICE_HOST'],
|
38
|
-
port: ENV['KUBERNETES_SERVICE_PORT_HTTPS'],
|
39
|
-
path: '/apis/apps'),
|
40
|
-
'v1beta1',
|
41
|
-
ssl_options: {
|
42
|
-
ca_file: "#{SVC_ACC_PATH}/ca.crt",
|
43
|
-
verify_ssl: OpenSSL::SSL::VERIFY_PEER
|
44
|
-
},
|
45
|
-
auth_options: {
|
46
|
-
bearer_token: File.read("#{SVC_ACC_PATH}/token")
|
47
|
-
}
|
48
|
-
)
|
49
|
-
kube_namespace = File.read("#{SVC_ACC_PATH}/namespace")
|
50
|
-
|
51
|
-
jobs = {}
|
52
|
-
job_configs.each do |job, job_config|
|
53
|
-
base_config = JSON.parse(File.read(job_config['base']))
|
54
|
-
|
55
|
-
begin
|
56
|
-
bosh_spec = EnvironmentConfigTransmogrifier.transmogrify(base_config,
|
57
|
-
templates,
|
58
|
-
secrets: '/etc/secrets')
|
59
|
-
rescue NonHashValueOverride => e
|
60
|
-
STDERR.puts e.to_s
|
61
|
-
STDERR.puts "Error generating #{job}: #{outfile} from #{infile}"
|
62
|
-
exit 1
|
63
|
-
end
|
64
|
-
|
65
|
-
jobs[job] = Job.new(bosh_spec, kube_namespace, kube_client, kube_client_stateful_set)
|
66
|
-
end
|
67
|
-
|
68
|
-
jobs.each do |name, job|
|
69
|
-
kube_client.patch_pod(
|
70
|
-
ENV['HOSTNAME'],
|
71
|
-
{ metadata: { annotations: { :"skiff-exported-properties-#{name}" => job.exported_properties.to_json } } },
|
72
|
-
kube_namespace
|
73
|
-
)
|
74
|
-
end
|
75
|
-
|
76
|
-
jobs.each do |job_name, job|
|
77
|
-
dns_encoder = KubeDNSEncoder.new(job.spec['links'])
|
78
|
-
|
79
|
-
job_configs[job_name]['files'].each do |infile, outfile|
|
80
|
-
job.generate(infile, outfile, dns_encoder)
|
81
|
-
end
|
82
|
-
end
|
18
|
+
Configgin.new(options).run
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# BaseTransmogrifier holds shared code for the transmogrifier classes
|
2
|
+
class BaseTransmogrifier
|
3
|
+
def self.inject_value(hash, key_grams, value, original_key)
|
4
|
+
# if we only have 1 gram, we can set the value
|
5
|
+
if key_grams.size == 1
|
6
|
+
# If the new value is nil, and the old value was a hash, it's because
|
7
|
+
# somebody didn't provide a full default value; ignore it.
|
8
|
+
unless value.nil? && hash[key_grams[0]].is_a?(Hash)
|
9
|
+
hash[key_grams[0]] = value
|
10
|
+
end
|
11
|
+
return
|
12
|
+
end
|
13
|
+
|
14
|
+
# if there's more than one gram, keep going
|
15
|
+
|
16
|
+
# Initialize a hash if we're going deeper than what's currently available;
|
17
|
+
# sometimes we want to override when the old value is nil (i.e. no default)
|
18
|
+
# but the new value is a hash.
|
19
|
+
hash[key_grams[0]] = {} if hash[key_grams[0]].nil?
|
20
|
+
# error out if we're trying to override
|
21
|
+
# an existing value that's not a hash
|
22
|
+
unless hash[key_grams[0]].is_a?(Hash)
|
23
|
+
raise NonHashValueOverride, \
|
24
|
+
"Refusing to override non-hash value #{hash[key_grams[0]].inspect} " \
|
25
|
+
"with #{value.inspect}: '#{key_grams.join('.')}'" \
|
26
|
+
" - Complete key: '#{original_key}'"
|
27
|
+
end
|
28
|
+
# keep going deeper
|
29
|
+
inject_value(hash[key_grams[0]], key_grams.drop(1), value, original_key)
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
# BoshDeploymentManifest is used to parse BOSH manifests
|
4
|
+
class BoshDeploymentManifest
|
5
|
+
def initialize(path)
|
6
|
+
@manifest = YAML.load_file(path)
|
7
|
+
end
|
8
|
+
|
9
|
+
def properties_for_instance_group(instance_group_name)
|
10
|
+
return @properties[instance_group] if @properties && @properties[instance_group]
|
11
|
+
|
12
|
+
instance_group = @manifest['instance_groups'].find { |group| group['name'] == instance_group_name }
|
13
|
+
return [] unless instance_group
|
14
|
+
|
15
|
+
properties = {}
|
16
|
+
instance_group['jobs'].each do |job|
|
17
|
+
next unless job.key?('properties')
|
18
|
+
|
19
|
+
job['properties'].each do |key, value|
|
20
|
+
inject_properties(properties, job, key, value)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
@properties ||= {}
|
25
|
+
@properties[instance_group] = properties
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def inject_properties(properties, job, key, value)
|
31
|
+
case value
|
32
|
+
when Hash
|
33
|
+
value.each do |sub_key, sub_value|
|
34
|
+
inject_properties(properties, job, "#{key}.#{sub_key}", sub_value)
|
35
|
+
end
|
36
|
+
else
|
37
|
+
properties["#{job['name']}.#{key}"] = value
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require_relative 'base_transmogrifier'
|
2
|
+
|
3
|
+
# BoshDeploymentManifestConfigTransmogrifier extracts property values from a bosh
|
4
|
+
# manifest and updates the config accordingly.
|
5
|
+
class BoshDeploymentManifestConfigTransmogrifier < BaseTransmogrifier
|
6
|
+
def self.transmogrify(base_config, instance_group, bosh_deployment_manifest)
|
7
|
+
bosh_deployment_manifest.properties_for_instance_group(instance_group).each do |key, value|
|
8
|
+
full_key = 'properties.' + key
|
9
|
+
inject_value(base_config, full_key.split('.'), value, full_key)
|
10
|
+
end
|
11
|
+
base_config
|
12
|
+
end
|
13
|
+
end
|
data/lib/cli.rb
CHANGED
@@ -34,6 +34,11 @@ module Cli
|
|
34
34
|
options[:env2conf] = e
|
35
35
|
end
|
36
36
|
|
37
|
+
# Bosh deployment manifest
|
38
|
+
opts.on('-b', '--bosh-deployment-manifest', 'Bosh deployment manifest') do |b|
|
39
|
+
options[:bosh_deployment_manifest] = b
|
40
|
+
end
|
41
|
+
|
37
42
|
opts.on('--version', 'Print the configgin version') do
|
38
43
|
puts Configgin::VERSION
|
39
44
|
exit 0
|
data/lib/configgin.rb
CHANGED
@@ -1,4 +1,112 @@
|
|
1
1
|
require_relative 'cli'
|
2
2
|
require_relative 'job'
|
3
3
|
require_relative 'environment_config_transmogrifier'
|
4
|
+
require_relative 'bosh_deployment_manifest_config_transmogrifier'
|
4
5
|
require_relative 'kube_link_generator'
|
6
|
+
require_relative 'bosh_deployment_manifest'
|
7
|
+
|
8
|
+
# Configgin is the main class which puts all the pieces together and configures
|
9
|
+
# the container according to the options.
|
10
|
+
class Configgin
|
11
|
+
# SVC_ACC_PATH is the location of the service account secrets
|
12
|
+
SVC_ACC_PATH = '/var/run/secrets/kubernetes.io/serviceaccount'.freeze
|
13
|
+
|
14
|
+
def initialize(options)
|
15
|
+
@job_configs = JSON.parse(File.read(options[:jobs]))
|
16
|
+
@templates = YAML.load_file(options[:env2conf])
|
17
|
+
@bosh_deployment_manifest = options[:bosh_deployment_manifest]
|
18
|
+
end
|
19
|
+
|
20
|
+
def run
|
21
|
+
jobs = generate_jobs(@job_configs, @templates)
|
22
|
+
set_job_metadata(jobs)
|
23
|
+
render_job_templates(jobs, @job_configs)
|
24
|
+
end
|
25
|
+
|
26
|
+
def generate_jobs(job_configs, templates)
|
27
|
+
jobs = {}
|
28
|
+
job_configs.each do |job, job_config|
|
29
|
+
base_config = JSON.parse(File.read(job_config['base']))
|
30
|
+
|
31
|
+
begin
|
32
|
+
bosh_spec = EnvironmentConfigTransmogrifier.transmogrify(base_config, templates, secrets: '/etc/secrets')
|
33
|
+
|
34
|
+
if @bosh_deployment_manifest
|
35
|
+
manifest = BoshDeploymentManifest.new(@bosh_deployment_manifest)
|
36
|
+
bosh_spec = BoshDeploymentManifestConfigTransmogrifier.transmogrify(bosh_spec, ENV['HOSTNAME'], manifest)
|
37
|
+
end
|
38
|
+
rescue NonHashValueOverride => e
|
39
|
+
STDERR.puts e.to_s
|
40
|
+
STDERR.puts "Error generating #{job}: #{outfile} from #{infile}"
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
|
44
|
+
jobs[job] = Job.new(bosh_spec, @kube_namespace, kube_client, kube_client_stateful_set)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def set_job_metadata(jobs)
|
49
|
+
jobs.each do |name, job|
|
50
|
+
kube_client.patch_pod(
|
51
|
+
ENV['HOSTNAME'],
|
52
|
+
{ metadata: { annotations: { :"skiff-exported-properties-#{name}" => job.exported_properties.to_json } } },
|
53
|
+
@kube_namespace
|
54
|
+
)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def render_job_templates(jobs, job_configs)
|
59
|
+
jobs.each do |job_name, job|
|
60
|
+
dns_encoder = KubeDNSEncoder.new(job.spec['links'])
|
61
|
+
|
62
|
+
job_configs[job_name]['files'].each do |infile, outfile|
|
63
|
+
job.generate(infile, outfile, dns_encoder)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def kube_namespace
|
69
|
+
@kube_namespace ||= File.read("#{SVC_ACC_PATH}/namespace")
|
70
|
+
end
|
71
|
+
|
72
|
+
def kube_token
|
73
|
+
@kube_token ||= File.read("#{SVC_ACC_PATH}/token")
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
def kube_client
|
79
|
+
@kube_client ||= Kubeclient::Client.new(
|
80
|
+
URI::HTTPS.build(
|
81
|
+
host: ENV['KUBERNETES_SERVICE_HOST'],
|
82
|
+
port: ENV['KUBERNETES_SERVICE_PORT_HTTPS']
|
83
|
+
),
|
84
|
+
'v1',
|
85
|
+
ssl_options: {
|
86
|
+
ca_file: "#{SVC_ACC_PATH}/ca.crt",
|
87
|
+
verify_ssl: OpenSSL::SSL::VERIFY_PEER
|
88
|
+
},
|
89
|
+
auth_options: {
|
90
|
+
bearer_token: kube_token
|
91
|
+
}
|
92
|
+
)
|
93
|
+
end
|
94
|
+
|
95
|
+
def kube_client_stateful_set
|
96
|
+
@kube_client_stateful_set ||= Kubeclient::Client.new(
|
97
|
+
URI::HTTPS.build(
|
98
|
+
host: ENV['KUBERNETES_SERVICE_HOST'],
|
99
|
+
port: ENV['KUBERNETES_SERVICE_PORT_HTTPS'],
|
100
|
+
path: '/apis/apps'
|
101
|
+
),
|
102
|
+
'v1beta1',
|
103
|
+
ssl_options: {
|
104
|
+
ca_file: "#{SVC_ACC_PATH}/ca.crt",
|
105
|
+
verify_ssl: OpenSSL::SSL::VERIFY_PEER
|
106
|
+
},
|
107
|
+
auth_options: {
|
108
|
+
bearer_token: kube_token
|
109
|
+
}
|
110
|
+
)
|
111
|
+
end
|
112
|
+
end
|
data/lib/configgin/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
|
2
|
-
VERSION = '0.
|
1
|
+
class Configgin
|
2
|
+
VERSION = '0.18.0'.freeze
|
3
3
|
end
|
@@ -1,10 +1,13 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'mustache'
|
3
3
|
require 'shellwords'
|
4
|
+
require 'tmpdir'
|
5
|
+
|
6
|
+
require_relative 'base_transmogrifier'
|
4
7
|
|
5
8
|
# EnvironmentConfigTransmogrifier uses environment variables to generate config values
|
6
9
|
# for specific keys.
|
7
|
-
|
10
|
+
class EnvironmentConfigTransmogrifier < BaseTransmogrifier
|
8
11
|
@@memoize_mustache = {}
|
9
12
|
|
10
13
|
# NoEscapeMustache does not escape these characters: & \ " < > '
|
@@ -98,33 +101,4 @@ module EnvironmentConfigTransmogrifier
|
|
98
101
|
hash[key.upcase.tr('-', '_')] = value
|
99
102
|
end
|
100
103
|
end
|
101
|
-
|
102
|
-
def self.inject_value(hash, key_grams, value, original_key)
|
103
|
-
# if we only have 1 gram, we can set the value
|
104
|
-
if key_grams.size == 1
|
105
|
-
# If the new value is nil, and the old value was a hash, it's because
|
106
|
-
# somebody didn't provide a full default value; ignore it.
|
107
|
-
unless value.nil? && hash[key_grams[0]].is_a?(Hash)
|
108
|
-
hash[key_grams[0]] = value
|
109
|
-
end
|
110
|
-
return
|
111
|
-
end
|
112
|
-
|
113
|
-
# if there's more than one gram, keep going
|
114
|
-
|
115
|
-
# Initialize a hash if we're going deeper than what's currently available;
|
116
|
-
# sometimes we want to override when the old value is nil (i.e. no default)
|
117
|
-
# but the new value is a hash.
|
118
|
-
hash[key_grams[0]] = {} if hash[key_grams[0]].nil?
|
119
|
-
# error out if we're trying to override
|
120
|
-
# an existing value that's not a hash
|
121
|
-
unless hash[key_grams[0]].is_a?(Hash)
|
122
|
-
raise NonHashValueOverride, \
|
123
|
-
"Refusing to override non-hash value #{hash[key_grams[0]].inspect} " \
|
124
|
-
"with #{value.inspect}: '#{key_grams.join('.')}'" \
|
125
|
-
" - Complete key: '#{original_key}'"
|
126
|
-
end
|
127
|
-
# keep going deeper
|
128
|
-
inject_value(hash[key_grams[0]], key_grams.drop(1), value, original_key)
|
129
|
-
end
|
130
104
|
end
|
data/lib/job.rb
CHANGED
@@ -11,7 +11,7 @@ class Job
|
|
11
11
|
links = @spec['links'] = KubeLinkSpecs.new(@spec, @namespace, @client, client_stateful_set)
|
12
12
|
|
13
13
|
# Figure out whether _this_ should bootstrap
|
14
|
-
pods = @client.get_pods(namespace: @namespace, label_selector: "
|
14
|
+
pods = @client.get_pods(namespace: @namespace, label_selector: "app.kubernetes.io/component=#{self_role}")
|
15
15
|
pods_per_image = links.get_pods_per_image(pods)
|
16
16
|
@spec['bootstrap'] = pods_per_image[self_pod.metadata.uid] < 2
|
17
17
|
end
|
@@ -41,7 +41,7 @@ class Job
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self_role
|
44
|
-
self_pod['metadata']['labels']['
|
44
|
+
self_pod['metadata']['labels']['app.kubernetes.io/component']
|
45
45
|
end
|
46
46
|
|
47
47
|
# Process the given template using a provided spec and output filename
|
data/lib/kube_link_generator.rb
CHANGED
@@ -37,7 +37,7 @@ class KubeLinkSpecs
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def _get_pods_for_role(role_name)
|
40
|
-
client.get_pods(namespace: namespace, label_selector: "
|
40
|
+
client.get_pods(namespace: namespace, label_selector: "app.kubernetes.io/component=#{role_name}")
|
41
41
|
end
|
42
42
|
|
43
43
|
def get_pods_for_role(role_name, job, options = {})
|
data/make/include/darwin-support
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: configgin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SUSE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -132,6 +132,7 @@ files:
|
|
132
132
|
- ".ruby-version"
|
133
133
|
- Gemfile
|
134
134
|
- Gemfile.lock
|
135
|
+
- Guardfile
|
135
136
|
- LICENSE.md
|
136
137
|
- Makefile
|
137
138
|
- NOTICE
|
@@ -139,6 +140,9 @@ files:
|
|
139
140
|
- bin/configgin
|
140
141
|
- bin/setup
|
141
142
|
- configgin.gemspec
|
143
|
+
- lib/base_transmogrifier.rb
|
144
|
+
- lib/bosh_deployment_manifest.rb
|
145
|
+
- lib/bosh_deployment_manifest_config_transmogrifier.rb
|
142
146
|
- lib/cli.rb
|
143
147
|
- lib/configgin.rb
|
144
148
|
- lib/configgin/version.rb
|
@@ -177,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
181
|
version: '0'
|
178
182
|
requirements: []
|
179
183
|
rubyforge_project:
|
180
|
-
rubygems_version: 2.
|
184
|
+
rubygems_version: 2.6.13
|
181
185
|
signing_key:
|
182
186
|
specification_version: 4
|
183
187
|
summary: A simple cli app in Ruby to generate configurations using BOSH ERB templates
|