configgin 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.rubocop_todo.yml +4 -1
- data/Gemfile.lock +37 -6
- data/LICENSE.md +1 -1
- data/Makefile +2 -2
- data/bin/configgin +49 -17
- data/configgin.gemspec +14 -12
- data/lib/cli.rb +8 -3
- data/lib/configgin.rb +4 -3
- data/lib/configgin/version.rb +1 -3
- data/lib/environment_config_transmogrifier.rb +2 -2
- data/lib/exceptions.rb +1 -0
- data/lib/{generate.rb → job.rb} +35 -8
- data/lib/kube_link_generator.rb +126 -0
- data/make/include/darwin-support +1 -1
- data/update-stemcell.sh +110 -0
- metadata +27 -12
- data/make/include/versioning +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a14ee686893a48901c83384fa342249dabd5ece
|
4
|
+
data.tar.gz: 2f3ace7fcc6446438e0696c7c71e9593ac838437
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 39fc144f17f7d07ea07449319f9be330f4b446dd1b71def1af6bb100da1c18ed168c47bf13118fbc278d1ded3c59120eb2c7825942dc848309d1f73fe5ba60d9
|
7
|
+
data.tar.gz: 6289287531569d97c1020b8e798b5fee52183f25d37301ffd8918a0845228e950973661a127fb65b6087e2636d0cc6c35b4130c54eba803af2d12541dff60dc3
|
data/.gitignore
CHANGED
data/.rubocop_todo.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,26 +1,54 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
configgin (0.12.
|
5
|
-
bosh-template (~>
|
6
|
-
deep_merge (~> 1.
|
4
|
+
configgin (0.12.1)
|
5
|
+
bosh-template (~> 2.0)
|
6
|
+
deep_merge (~> 1.1)
|
7
|
+
kubeclient (~> 2.0)
|
7
8
|
mustache (~> 1.0)
|
8
9
|
rainbow (~> 2.0, != 2.2.1)
|
9
10
|
|
10
11
|
GEM
|
11
12
|
remote: https://rubygems.org/
|
12
13
|
specs:
|
14
|
+
addressable (2.5.2)
|
15
|
+
public_suffix (>= 2.0.2, < 4.0)
|
13
16
|
ast (2.3.0)
|
14
|
-
bosh-template (
|
17
|
+
bosh-template (2.0.0)
|
15
18
|
semi_semantic (~> 1.2.0)
|
16
|
-
deep_merge (1.
|
19
|
+
deep_merge (1.1.1)
|
17
20
|
diff-lcs (1.3)
|
21
|
+
domain_name (0.5.20170404)
|
22
|
+
unf (>= 0.0.5, < 1.0.0)
|
23
|
+
http (0.9.8)
|
24
|
+
addressable (~> 2.3)
|
25
|
+
http-cookie (~> 1.0)
|
26
|
+
http-form_data (~> 1.0.1)
|
27
|
+
http_parser.rb (~> 0.6.0)
|
28
|
+
http-cookie (1.0.3)
|
29
|
+
domain_name (~> 0.5)
|
30
|
+
http-form_data (1.0.3)
|
31
|
+
http_parser.rb (0.6.0)
|
32
|
+
kubeclient (2.4.0)
|
33
|
+
http (= 0.9.8)
|
34
|
+
recursive-open-struct (= 1.0.0)
|
35
|
+
rest-client
|
36
|
+
mime-types (3.1)
|
37
|
+
mime-types-data (~> 3.2015)
|
38
|
+
mime-types-data (3.2016.0521)
|
18
39
|
mustache (1.0.5)
|
40
|
+
netrc (0.11.0)
|
19
41
|
parser (2.4.0.0)
|
20
42
|
ast (~> 2.2)
|
21
43
|
powerpack (0.1.1)
|
44
|
+
public_suffix (3.0.0)
|
22
45
|
rainbow (2.1.0)
|
23
46
|
rake (10.4.2)
|
47
|
+
recursive-open-struct (1.0.0)
|
48
|
+
rest-client (2.0.2)
|
49
|
+
http-cookie (>= 1.0.2, < 2.0)
|
50
|
+
mime-types (>= 1.16, < 4.0)
|
51
|
+
netrc (~> 0.8)
|
24
52
|
rspec (3.5.0)
|
25
53
|
rspec-core (~> 3.5.0)
|
26
54
|
rspec-expectations (~> 3.5.0)
|
@@ -42,13 +70,16 @@ GEM
|
|
42
70
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
43
71
|
ruby-progressbar (1.8.1)
|
44
72
|
semi_semantic (1.2.0)
|
73
|
+
unf (0.1.4)
|
74
|
+
unf_ext
|
75
|
+
unf_ext (0.0.7.4)
|
45
76
|
unicode-display_width (1.2.1)
|
46
77
|
|
47
78
|
PLATFORMS
|
48
79
|
ruby
|
49
80
|
|
50
81
|
DEPENDENCIES
|
51
|
-
bundler (~> 1.
|
82
|
+
bundler (~> 1.10)
|
52
83
|
configgin!
|
53
84
|
rake (~> 10.0)
|
54
85
|
rspec
|
data/LICENSE.md
CHANGED
data/Makefile
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env make
|
2
2
|
|
3
|
-
GIT_ROOT
|
3
|
+
GIT_ROOT := $(shell git rev-parse --show-toplevel)
|
4
4
|
|
5
5
|
.PHONY: lint test dist
|
6
6
|
|
@@ -16,4 +16,4 @@ dist:
|
|
16
16
|
gem build ${GIT_ROOT}/configgin.gemspec
|
17
17
|
|
18
18
|
clean:
|
19
|
-
rm -rf
|
19
|
+
rm -rf configgin-*.gem
|
data/bin/configgin
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
|
3
|
+
require 'json'
|
4
|
+
require_relative '../lib/configgin'
|
4
5
|
|
5
6
|
options = {}
|
6
7
|
parser = Cli.make_option_parser(options)
|
@@ -14,23 +15,54 @@ rescue ArgMissingError => e
|
|
14
15
|
exit(1)
|
15
16
|
end
|
16
17
|
|
17
|
-
|
18
|
+
job_configs = JSON.parse(File.read(options[:jobs]))
|
18
19
|
templates = YAML.load_file(options[:env2conf])
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
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_namespace = File.read("#{SVC_ACC_PATH}/namespace")
|
37
|
+
|
38
|
+
jobs = {}
|
39
|
+
job_configs.each do |job, job_config|
|
40
|
+
base_config = JSON.parse(File.read(job_config['base']))
|
41
|
+
|
42
|
+
begin
|
43
|
+
bosh_spec = EnvironmentConfigTransmogrifier.transmogrify(base_config,
|
44
|
+
templates,
|
45
|
+
secrets: '/etc/secrets')
|
46
|
+
rescue NonHashValueOverride => e
|
47
|
+
STDERR.puts e.to_s
|
48
|
+
STDERR.puts "Error generating #{job}: #{outfile} from #{infile}"
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
|
52
|
+
jobs[job] = Job.new(bosh_spec, kube_namespace, kube_client)
|
53
|
+
end
|
54
|
+
|
55
|
+
exported_properties = Hash[jobs.map { |name, job| [name, job.exported_properties] }]
|
56
|
+
kube_client.patch_pod(
|
57
|
+
ENV['HOSTNAME'],
|
58
|
+
{ metadata: { annotations: { :'skiff-exported-properties' => exported_properties.to_json } } },
|
59
|
+
kube_namespace
|
60
|
+
)
|
61
|
+
|
62
|
+
jobs.each do |job_name, job|
|
63
|
+
dns_encoder = KubeDNSEncoder.new(job.spec['links'])
|
64
|
+
|
65
|
+
job_configs[job_name]['files'].each do |infile, outfile|
|
66
|
+
job.generate(infile, outfile, dns_encoder)
|
35
67
|
end
|
36
68
|
end
|
data/configgin.gemspec
CHANGED
@@ -1,30 +1,32 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
|
2
3
|
lib = File.expand_path('../lib', __FILE__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'configgin/version'
|
5
6
|
|
6
7
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
8
|
+
spec.name = 'configgin'
|
8
9
|
spec.version = Configgin::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.license = "Apache-2.0"
|
10
|
+
spec.authors = ['SUSE']
|
11
11
|
|
12
|
-
spec.summary =
|
13
|
-
spec.description =
|
14
|
-
spec.homepage =
|
12
|
+
spec.summary = 'A simple cli app in Ruby to generate configurations using BOSH ERB templates and a BOSH spec.'
|
13
|
+
spec.description = 'A simple cli app in Ruby to generate configurations using BOSH ERB templates and a BOSH spec, but also using configurations based on environment variables, processed using a set of templates.'
|
14
|
+
spec.homepage = 'https://github.com/SUSE/configgin'
|
15
|
+
spec.licenses = ['Apache-2.0']
|
15
16
|
|
16
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
18
|
f.match(%r{^(test|spec|features)/})
|
18
19
|
end
|
19
|
-
spec.bindir =
|
20
|
+
spec.bindir = 'bin'
|
20
21
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
21
|
-
spec.require_paths = [
|
22
|
+
spec.require_paths = ['lib']
|
22
23
|
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
25
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
25
26
|
|
26
|
-
spec.add_dependency 'bosh-template', '~>
|
27
|
+
spec.add_dependency 'bosh-template', '~> 2.0'
|
27
28
|
spec.add_dependency 'rainbow', '~>2.0', '!=2.2.1'
|
28
|
-
spec.add_dependency 'deep_merge', '~> 1.
|
29
|
+
spec.add_dependency 'deep_merge', '~> 1.1'
|
29
30
|
spec.add_dependency 'mustache', '~> 1.0'
|
31
|
+
spec.add_dependency 'kubeclient', '~>2.0'
|
30
32
|
end
|
data/lib/cli.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'optparse'
|
2
|
-
|
3
|
-
|
2
|
+
require_relative 'exceptions'
|
3
|
+
require_relative 'configgin/version'
|
4
4
|
|
5
5
|
# Cli is a helper module for dealing with command line flags
|
6
6
|
module Cli
|
@@ -8,7 +8,7 @@ module Cli
|
|
8
8
|
#
|
9
9
|
# @param options [Hash] The options to check
|
10
10
|
def self.check_opts(options)
|
11
|
-
[
|
11
|
+
%i[jobs env2conf].each do |key|
|
12
12
|
if options[key].nil? || options[key].empty?
|
13
13
|
raise ArgMissingError, key.to_s
|
14
14
|
end
|
@@ -33,6 +33,11 @@ module Cli
|
|
33
33
|
'Environment to configuration templates YAML') do |e|
|
34
34
|
options[:env2conf] = e
|
35
35
|
end
|
36
|
+
|
37
|
+
opts.on('--version', 'Print the configgin version') do
|
38
|
+
puts Configgin::VERSION
|
39
|
+
exit 0
|
40
|
+
end
|
36
41
|
end
|
37
42
|
end
|
38
43
|
end
|
data/lib/configgin.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
require_relative 'cli'
|
2
|
+
require_relative 'job'
|
3
|
+
require_relative 'environment_config_transmogrifier'
|
4
|
+
require_relative 'kube_link_generator'
|
data/lib/configgin/version.rb
CHANGED
@@ -46,7 +46,7 @@ module EnvironmentConfigTransmogrifier
|
|
46
46
|
inject_value(base_config, key.split('.'), value, key)
|
47
47
|
end
|
48
48
|
|
49
|
-
base_config['bootstrap'] = (base_config['index'] || 0)
|
49
|
+
base_config['bootstrap'] = (base_config['index'] || 0).zero?
|
50
50
|
|
51
51
|
base_config
|
52
52
|
end
|
@@ -61,7 +61,7 @@ module EnvironmentConfigTransmogrifier
|
|
61
61
|
# replace new lines with double new lines for proper new-line YAML parsing
|
62
62
|
mustache_value = mustache_value.to_s.gsub("\n", "\n\n")
|
63
63
|
@@memoize_mustache[value] ||= {}
|
64
|
-
@@memoize_mustache[value][input_hash] = YAML.
|
64
|
+
@@memoize_mustache[value][input_hash] = YAML.safe_load(mustache_value)
|
65
65
|
rescue => e
|
66
66
|
msg = mustacheMessageFromError(e)
|
67
67
|
raise LoadYamlFromMustacheError, "Could not load config key '#{key}': #{msg}"
|
data/lib/exceptions.rb
CHANGED
data/lib/{generate.rb → job.rb}
RENAMED
@@ -1,17 +1,44 @@
|
|
1
1
|
require 'bosh/template/renderer'
|
2
2
|
require 'json'
|
3
|
+
require_relative 'kube_link_generator'
|
3
4
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
# Job describes a single BOSH job
|
6
|
+
class Job
|
7
|
+
def initialize(spec, namespace, client)
|
8
|
+
@spec = spec
|
9
|
+
@namespace = namespace
|
10
|
+
@client = client
|
11
|
+
@spec['links'] = KubeLinkSpecs.new(@spec, @namespace, @client)
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :spec
|
15
|
+
|
16
|
+
def exported_properties
|
17
|
+
return @exported_propertes if @exported_properties
|
18
|
+
exported_properties = {}
|
19
|
+
spec['exported_properties'].each do |prop|
|
20
|
+
src = spec['properties']
|
21
|
+
dst = exported_properties
|
22
|
+
keys = prop.split('.')
|
23
|
+
leaf = keys.pop
|
24
|
+
keys.each do |key|
|
25
|
+
dst[key] ||= {}
|
26
|
+
dst = dst[key]
|
27
|
+
src = src.fetch(key, {})
|
28
|
+
end
|
29
|
+
dst[leaf] = src[leaf]
|
30
|
+
end
|
31
|
+
@exported_properties = exported_properties
|
32
|
+
end
|
33
|
+
|
34
|
+
# Process the given template using a provided spec and output filename
|
8
35
|
#
|
9
|
-
# @param bosh_spec [Hash] The input data as a hash
|
10
36
|
# @param input_file_path [String] The input filepath for the template
|
11
37
|
# @param output_file_path [String] The output filepath
|
12
|
-
|
38
|
+
# @param dns_encoder [KubeDNSEncoder] BOSH DNS encoder
|
39
|
+
def generate(input_file_path, output_file_path, dns_encoder)
|
13
40
|
# Make sure we're getting all the parameters we need
|
14
|
-
raise NoDataProvided if
|
41
|
+
raise NoDataProvided if spec.nil?
|
15
42
|
raise NoInputFileProvided if input_file_path.nil?
|
16
43
|
raise NoOutputFileProvided if output_file_path.nil?
|
17
44
|
|
@@ -25,7 +52,7 @@ module Generate
|
|
25
52
|
end
|
26
53
|
|
27
54
|
# Create a BOSH evaluation context
|
28
|
-
evaluation_context = Bosh::Template::EvaluationContext.new(
|
55
|
+
evaluation_context = Bosh::Template::EvaluationContext.new(spec, dns_encoder)
|
29
56
|
# Process the Template
|
30
57
|
output = erb_template.result(evaluation_context.get_binding)
|
31
58
|
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require 'kubeclient'
|
2
|
+
require 'uri'
|
3
|
+
require_relative 'exceptions'
|
4
|
+
|
5
|
+
# KubeLinkSpecs provides the information required to generate BOSH links by
|
6
|
+
# pretending to be a hash.
|
7
|
+
class KubeLinkSpecs
|
8
|
+
# ANNOTATION_AZ is the Kube annotation for the (availability) zone
|
9
|
+
ANNOTATION_AZ = 'failure-domain.beta.kubernetes.io/zone'.freeze
|
10
|
+
|
11
|
+
def initialize(spec, namespace, kube_client)
|
12
|
+
@links = {}
|
13
|
+
@client = kube_client
|
14
|
+
@namespace = namespace
|
15
|
+
@spec = spec || {}
|
16
|
+
end
|
17
|
+
|
18
|
+
def this_name
|
19
|
+
@spec['job']['name']
|
20
|
+
end
|
21
|
+
|
22
|
+
# pod_index returns a number for the given mod name. The number is expected to
|
23
|
+
# be unique across all pods for the role.
|
24
|
+
def pod_index(name)
|
25
|
+
index = name.rpartition('-').last
|
26
|
+
return index.to_i if /^\d+$/ =~ index
|
27
|
+
# The pod name is something like role-abcxyz
|
28
|
+
# Derive the index from the randomness that went into the suffix.
|
29
|
+
# chars are the characters kubernetes might use to generate names
|
30
|
+
# Copied from https://github.com/kubernetes/kubernetes/blob/52a6ad0acb26/staging/src/k8s.io/client-go/pkg/util/rand/rand.go#L73
|
31
|
+
chars = 'bcdfghjklmnpqrstvwxz0123456789'
|
32
|
+
index.chars.map { |c| chars.index(c) }.reduce(0) { |v, c| v * chars.length + c }
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_pods_for_role(role_name, wait_for_ip)
|
36
|
+
loop do
|
37
|
+
# The 30.times loop exists to print out status messages
|
38
|
+
30.times do
|
39
|
+
1.times do
|
40
|
+
pods = @client.get_pods(namespace: @namespace, label_selector: "skiff-role-name=#{role_name}")
|
41
|
+
if wait_for_ip
|
42
|
+
# Wait until all pods have IP addresses and properties
|
43
|
+
break unless pods.all? { |pod| pod.status.podIP }
|
44
|
+
break unless pods.all? { |pod| pod.metadata.annotations['skiff-exported-properties'] }
|
45
|
+
else
|
46
|
+
# We just need one pod with exported properties
|
47
|
+
pods.select! { |pod| pod.status.podIP }
|
48
|
+
pods.select! { |pod| pod.metadata.annotations['skiff-exported-properties'] }
|
49
|
+
end
|
50
|
+
return pods unless pods.empty?
|
51
|
+
end
|
52
|
+
sleep 1
|
53
|
+
end
|
54
|
+
$stdout.puts "Waiting for pods for role #{role_name} (at #{Time.now})..."
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def get_pod_instance_info(pod, job)
|
59
|
+
index = pod_index(pod.metadata.name)
|
60
|
+
properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
|
61
|
+
{
|
62
|
+
'name' => pod.metadata.name,
|
63
|
+
'index' => index,
|
64
|
+
'id' => pod.metadata.name,
|
65
|
+
'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
|
66
|
+
'address' => pod.status.podIP,
|
67
|
+
'properties' => properties.fetch(job, {}),
|
68
|
+
'bootstrap' => index.zero?
|
69
|
+
}
|
70
|
+
end
|
71
|
+
|
72
|
+
def get_svc_instance_info(role_name, job)
|
73
|
+
svc = @client.get_service(role_name, @namespace)
|
74
|
+
pod = get_pods_for_role(role_name, false).first
|
75
|
+
properties = JSON.parse(pod.metadata.annotations['skiff-exported-properties'])
|
76
|
+
{
|
77
|
+
'name' => svc.metadata.name,
|
78
|
+
'index' => 0, # Completely made up index; there is only ever one service
|
79
|
+
'id' => svc.metadata.name,
|
80
|
+
'az' => pod.metadata.annotations['failure-domain.beta.kubernetes.io/zone'] || 'az0',
|
81
|
+
'address' => svc.spec.clusterIP,
|
82
|
+
'properties' => properties.fetch(job, {}),
|
83
|
+
'bootstrap' => true
|
84
|
+
}
|
85
|
+
end
|
86
|
+
|
87
|
+
def [](key)
|
88
|
+
return @links[key] if @links.key? key
|
89
|
+
|
90
|
+
# Resolve the role we're looking for
|
91
|
+
provider = @spec['consumes'][key]
|
92
|
+
unless provider
|
93
|
+
$stderr.puts "No link provider found for #{key}"
|
94
|
+
@links[key] = nil
|
95
|
+
return @links[key]
|
96
|
+
end
|
97
|
+
|
98
|
+
if provider['role'] == this_name
|
99
|
+
$stderr.puts "Resolving link #{key} via self provider #{provider}"
|
100
|
+
pods = get_pods_for_role(provider['role'], true)
|
101
|
+
instances = pods.map { |p| get_pod_instance_info(p, provider['job']) }
|
102
|
+
else
|
103
|
+
# Getting pods for a different service; since we have kube services, we don't handle it in configgin
|
104
|
+
$stderr.puts "Resolving link #{key} via service #{provider}"
|
105
|
+
instances = [get_svc_instance_info(provider['role'], provider['job'])]
|
106
|
+
end
|
107
|
+
|
108
|
+
@links[key] = {
|
109
|
+
'address' => "#{provider['role']}.#{ENV['KUBE_SERVICE_DOMAIN_SUFFIX']}",
|
110
|
+
'instance_group' => '',
|
111
|
+
'default_network' => '',
|
112
|
+
'deployment_name' => @namespace,
|
113
|
+
'domain' => ENV['KUBE_SERVICE_DOMAIN_SUFFIX'],
|
114
|
+
'root_domain' => ENV['KUBE_SERVICE_DOMAIN_SUFFIX'],
|
115
|
+
'instances' => instances,
|
116
|
+
'properties' => instances.first['properties']
|
117
|
+
}
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
# KubeDNSEncoder is a BOSH DNS encoder object. It is unclear at this point what it does.
|
122
|
+
class KubeDNSEncoder
|
123
|
+
def initialize(link_specs)
|
124
|
+
@link_specs = link_specs
|
125
|
+
end
|
126
|
+
end
|
data/make/include/darwin-support
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
set -o errexit
|
4
4
|
|
5
5
|
if [ "$(uname)" == "Darwin" ]; then
|
6
|
-
DOCKER_RUNTIME=${DOCKER_RUNTIME:-'
|
6
|
+
DOCKER_RUNTIME=${DOCKER_RUNTIME:-'splatform/bosh-cli'}
|
7
7
|
|
8
8
|
# We need to mount the enclosing repo in case we are just a submodule
|
9
9
|
# (still doesn't support being a nested submodule though)
|
data/update-stemcell.sh
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
|
3
|
+
# This script will replace the stemcell on a vagrant box with one that has a
|
4
|
+
# copy of configgin built from the current directory. This is (obviously) only
|
5
|
+
# meant as a testing tool.
|
6
|
+
|
7
|
+
# Pre-requisites:
|
8
|
+
# - SCF checkout (preferably in ../scf, override in $REPO)
|
9
|
+
# - vagrant VM running for that checkout
|
10
|
+
# - docker daemon running on the host (requires volumes)
|
11
|
+
|
12
|
+
set -o errexit -o nounset
|
13
|
+
|
14
|
+
REPO="${REPO:-scf}"
|
15
|
+
|
16
|
+
IMAGE="$( cd "../${REPO}" && source .envrc && echo "${FISSILE_STEMCELL}" )"
|
17
|
+
|
18
|
+
name="${IMAGE%%:*}"
|
19
|
+
tag="${IMAGE##*:}"
|
20
|
+
|
21
|
+
unset container
|
22
|
+
unset KUBECONFIG
|
23
|
+
|
24
|
+
cleanup() {
|
25
|
+
if test -n "${container:-}" ; then
|
26
|
+
docker rm -f "${container}"
|
27
|
+
fi
|
28
|
+
if test -n "${KUBECONFIG:-}" ; then
|
29
|
+
rm -f "${KUBECONFIG}"
|
30
|
+
fi
|
31
|
+
}
|
32
|
+
trap cleanup EXIT
|
33
|
+
|
34
|
+
# Force use the vagrant kubectl context
|
35
|
+
export KUBECONFIG="$(mktemp)"
|
36
|
+
kubectl config set-cluster vagrant --server=http://cf-dev.io:8080
|
37
|
+
kubectl config set-context vagrant --cluster=vagrant --user=""
|
38
|
+
kubectl config use-context vagrant
|
39
|
+
|
40
|
+
vagrant_ready=""
|
41
|
+
if test -z "${NO_RUN:-}" ; then
|
42
|
+
if ( cd "$(dirname "$0")/../${REPO}" && (vagrant status 2>/dev/null | grep --quiet running) ) ; then
|
43
|
+
vagrant_ready="true"
|
44
|
+
releases=$(helm list --short)
|
45
|
+
if test -n "${releases}" ; then
|
46
|
+
helm delete --purge ${releases}
|
47
|
+
fi
|
48
|
+
kubectl delete ns cf ||:
|
49
|
+
kubectl delete ns uaa ||:
|
50
|
+
fi
|
51
|
+
fi
|
52
|
+
|
53
|
+
if test -z "$(docker images --quiet "${name}:${tag}-orig" 2>/dev/null)" ; then
|
54
|
+
docker pull "${IMAGE}"
|
55
|
+
container=$(docker run --detach "${IMAGE}" /bin/bash -c "sleep 1d")
|
56
|
+
docker exec -t "${container}" zypper install -y git
|
57
|
+
docker commit "${container}" "${name}:${tag}-orig"
|
58
|
+
fi
|
59
|
+
|
60
|
+
container=$(docker run \
|
61
|
+
--volume "${PWD}:/src" \
|
62
|
+
--detach \
|
63
|
+
"${name}:${tag}-orig" \
|
64
|
+
/bin/bash -c "sleep 1d")
|
65
|
+
docker exec -t "${container}" /bin/bash -c "source /usr/local/rvm/scripts/rvm && make -C /src all"
|
66
|
+
docker exec -t "${container}" /bin/bash -c "source /usr/local/rvm/scripts/rvm && gem install /src/configgin-*.gem"
|
67
|
+
docker commit "${container}" "${IMAGE}"
|
68
|
+
|
69
|
+
test -z "${NO_RUN:-}" || exit
|
70
|
+
|
71
|
+
if command -v docker-credential-osxkeychain >/dev/null 2>/dev/null ; then
|
72
|
+
docker_user=$(docker-credential-osxkeychain list | jq -r '."https://index.docker.io/v1/"')
|
73
|
+
else
|
74
|
+
docker_user=$(docker system info | awk -F: '{ if ($1 == "Username") { print $2} }' | tr -d '[:space:]' ||:)
|
75
|
+
fi
|
76
|
+
|
77
|
+
if test -z "${docker_user:-}" ; then
|
78
|
+
echo "Can't determine docker user. Are you logged in?"
|
79
|
+
exit
|
80
|
+
fi
|
81
|
+
|
82
|
+
docker tag "${IMAGE}" "${docker_user}/${name##*/}:${tag}"
|
83
|
+
docker push "${docker_user}/${name##*/}:${tag}"
|
84
|
+
|
85
|
+
test -n "${vagrant_ready}" || exit
|
86
|
+
|
87
|
+
cd "$(dirname "$0")/../${REPO}"
|
88
|
+
|
89
|
+
vagrant ssh -- -tt <<EOF
|
90
|
+
set -o errexit -o nounset
|
91
|
+
docker pull ${docker_user}/${name##*/}:${tag}
|
92
|
+
docker tag ${docker_user}/${name##*/}:${tag} ${IMAGE}
|
93
|
+
cd scf
|
94
|
+
source .envrc
|
95
|
+
while kubectl get namespace cf >/dev/null 2>/dev/null ; do
|
96
|
+
sleep 1
|
97
|
+
done
|
98
|
+
while kubectl get namespace uaa >/dev/null 2>/dev/null ; do
|
99
|
+
sleep 1
|
100
|
+
done
|
101
|
+
docker images --format={{.Repository}}:{{.Tag}} | \
|
102
|
+
grep -E '/scf-|role-packages' | \
|
103
|
+
xargs --no-run-if-empty docker rmi -f
|
104
|
+
docker images | \
|
105
|
+
awk '/<none>/ { print \$3 }' | \
|
106
|
+
xargs --no-run-if-empty docker rmi -f || \
|
107
|
+
:
|
108
|
+
make compile images helm kube run </dev/null
|
109
|
+
exit 0
|
110
|
+
EOF
|
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.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- SUSE
|
7
|
+
- SUSE
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '1.
|
19
|
+
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '1.
|
26
|
+
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version:
|
47
|
+
version: '2.0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: '2.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rainbow
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -78,14 +78,14 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 1.
|
81
|
+
version: '1.1'
|
82
82
|
type: :runtime
|
83
83
|
prerelease: false
|
84
84
|
version_requirements: !ruby/object:Gem::Requirement
|
85
85
|
requirements:
|
86
86
|
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.
|
88
|
+
version: '1.1'
|
89
89
|
- !ruby/object:Gem::Dependency
|
90
90
|
name: mustache
|
91
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: kubeclient
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.0'
|
103
117
|
description: A simple cli app in Ruby to generate configurations using BOSH ERB templates
|
104
118
|
and a BOSH spec, but also using configurations based on environment variables, processed
|
105
119
|
using a set of templates.
|
@@ -130,11 +144,12 @@ files:
|
|
130
144
|
- lib/configgin/version.rb
|
131
145
|
- lib/environment_config_transmogrifier.rb
|
132
146
|
- lib/exceptions.rb
|
133
|
-
- lib/
|
147
|
+
- lib/job.rb
|
148
|
+
- lib/kube_link_generator.rb
|
134
149
|
- make/include/darwin-support
|
135
|
-
- make/include/versioning
|
136
150
|
- make/lint
|
137
151
|
- make/test
|
152
|
+
- update-stemcell.sh
|
138
153
|
- vendor/github.com/hpe-cloud-garage/git-notary/.gitignore
|
139
154
|
- vendor/github.com/hpe-cloud-garage/git-notary/LICENSE.txt
|
140
155
|
- vendor/github.com/hpe-cloud-garage/git-notary/README.org
|
@@ -142,7 +157,7 @@ files:
|
|
142
157
|
- vendor/github.com/hpe-cloud-garage/git-notary/git-notary.gemspec
|
143
158
|
- vendor/github.com/hpe-cloud-garage/git-notary/hooks/pre-push/branch-has-notes
|
144
159
|
- vendor/github.com/hpe-cloud-garage/git-notary/hooks/pre-push/sync-notes
|
145
|
-
homepage: https://github.com/
|
160
|
+
homepage: https://github.com/SUSE/configgin
|
146
161
|
licenses:
|
147
162
|
- Apache-2.0
|
148
163
|
metadata: {}
|
data/make/include/versioning
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
#!/bin/sh
|
2
|
-
|
3
|
-
test -n "${XTRACE}" && set -o xtrace
|
4
|
-
|
5
|
-
set -o errexit -o nounset
|
6
|
-
|
7
|
-
GIT_ROOT=${GIT_ROOT:-$(git rev-parse --show-toplevel)}
|
8
|
-
GIT_DESCRIBE=${GIT_DESCRIBE:-$(git describe --tags --long)}
|
9
|
-
GIT_BRANCH=${GIT_BRANCH:-$(git name-rev --name-only HEAD)}
|
10
|
-
|
11
|
-
GIT_TAG=${GIT_TAG:-$(echo ${GIT_DESCRIBE} | awk -F - '{ print $1 }' )}
|
12
|
-
GIT_COMMITS=${GIT_COMMITS:-$(echo ${GIT_DESCRIBE} | awk -F - '{ print $2 }' )}
|
13
|
-
GIT_SHA=${GIT_SHA:-$(echo ${GIT_DESCRIBE} | awk -F - '{ print $3 }' )}
|
14
|
-
|
15
|
-
ARTIFACT_NAME=${ARTIFACT_NAME:-$(basename $(git config --get remote.origin.url) .git | sed s/^hcf-//)}
|
16
|
-
ARTIFACT_VERSION=${GIT_TAG}+${GIT_COMMITS}.${GIT_SHA}
|
17
|
-
|
18
|
-
APP_VERSION=${ARTIFACT_NAME}-${ARTIFACT_VERSION}
|
19
|
-
|
20
|
-
set +o errexit +o nounset +o xtrace
|