hako-etcenv 0.1.0

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cd2bf1cdaeff9c4684e2e228cab8b25f0212d399
4
+ data.tar.gz: e3d9927b8de71138f369c9bccca31d803f150607
5
+ SHA512:
6
+ metadata.gz: a589d23fb997eaf9f6b6145161890194ffca1df100a8406396fb4f2c0efc823e6f9053c0d6c65cb51489329a65e6412166b5c9f6f6255e7332f429dabda04137
7
+ data.tar.gz: 4b6834a5511e67679c79c98a836c65db60eb620fe6d31e3b43460e1ae6bc762077ab62b5269630bb8831026e37cb666ebb9fdb38ba0739c2fc7fc5cc5829eef5
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Style/HashSyntax:
4
+ Exclude:
5
+ - 'Rakefile'
6
+
7
+ Style/IfUnlessModifier:
8
+ Enabled: false
9
+
10
+ Style/SignalException:
11
+ Enabled: false
12
+
13
+ Style/TrailingComma:
14
+ Enabled: false
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,11 @@
1
+ Metrics/AbcSize:
2
+ Enabled: false
3
+
4
+ Metrics/LineLength:
5
+ Enabled: false
6
+
7
+ Metrics/MethodLength:
8
+ Enabled: false
9
+
10
+ Style/Documentation:
11
+ Enabled: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in hako-etcenv.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # Hako::EnvProviders::Etcenv
2
+ Provide variables from [etcd](https://github.com/coreos/etcd) to [hako](https://github.com/eagletmt/hako) using [etcenv](https://github.com/sorah/etcenv).
3
+
4
+ ## Installation
5
+
6
+ Add this line to your application's Gemfile:
7
+
8
+ ```ruby
9
+ gem 'hako-etcenv'
10
+ ```
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install hako-etcenv
19
+
20
+ ## Usage
21
+
22
+ ```yaml
23
+ image: ryotarai/hello-sinatra
24
+ env:
25
+ $providers:
26
+ - type: etcenv
27
+ url: https://127.0.0.1:2379
28
+ ca_file: /etc/etcd/ca.crt
29
+ ssl_cert: /etc/etcd/client.crt
30
+ ssl_key: /etc/etcd/client.key
31
+ root: /hako/hello-sinatra
32
+ PORT: 3000
33
+ MESSAGE: '#{username}-san!'
34
+ port: 3000
35
+ scheduler:
36
+ type: echo
37
+ ```
38
+
39
+ It pulls `username` variable from etcd with `/hako/hello-sinatra/username` key.
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/hako-etcenv.
50
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ task :default => [:rubocop]
4
+
5
+ require 'rubocop/rake_task'
6
+ RuboCop::RakeTask.new(:rubocop)
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'hako/etcenv'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'hako-etcenv'
7
+ spec.version = '0.1.0'
8
+ spec.authors = ['Kohei Suzuki']
9
+ spec.email = ['eagletmt@gmail.com']
10
+
11
+ spec.summary = 'Provide variables from etcd to hako using etcenv'
12
+ spec.description = 'Provide variables from etcd to hako using etcenv'
13
+ spec.homepage = 'https://github.com/eagletmt/hako-etcenv'
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
+
20
+ spec.add_dependency 'etcenv'
21
+ spec.add_dependency 'hako'
22
+ spec.add_development_dependency 'bundler'
23
+ spec.add_development_dependency 'rake'
24
+ spec.add_development_dependency 'rubocop'
25
+ end
@@ -0,0 +1,40 @@
1
+ require 'etcd'
2
+ require 'etcenv/environment'
3
+ require 'hako/env_provider'
4
+ require 'openssl'
5
+ require 'uri'
6
+
7
+ module Hako
8
+ module EnvProviders
9
+ class Etcenv < EnvProvider
10
+ def initialize(options)
11
+ unless options['url']
12
+ validation_error!('url must be set')
13
+ end
14
+ unless options['root']
15
+ validation_error!('root must be set')
16
+ end
17
+ uri = URI.parse(options.fetch('url'))
18
+ @etcd = Etcd.client(
19
+ host: uri.host,
20
+ port: uri.port,
21
+ use_ssl: uri.scheme == 'https',
22
+ ca_file: options.fetch('ca_file', nil),
23
+ ssl_cert: OpenSSL::X509::Certificate.new(::File.read(options.fetch('ssl_cert', nil))),
24
+ ssl_key: OpenSSL::PKey::RSA.new(::File.read(options.fetch('ssl_key', nil))),
25
+ )
26
+ @root = options.fetch('root')
27
+ end
28
+
29
+ def ask(variables)
30
+ env = {}
31
+ ::Etcenv::Environment.new(@etcd, @root).expanded_env.each do |key, val|
32
+ if variables.include?(key)
33
+ env[key] = val
34
+ end
35
+ end
36
+ env
37
+ end
38
+ end
39
+ end
40
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hako-etcenv
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kohei Suzuki
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: etcenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: hako
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ description: Provide variables from etcd to hako using etcenv
84
+ email:
85
+ - eagletmt@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rubocop.yml"
92
+ - ".rubocop_todo.yml"
93
+ - Gemfile
94
+ - README.md
95
+ - Rakefile
96
+ - bin/console
97
+ - bin/setup
98
+ - hako-etcenv.gemspec
99
+ - lib/hako/env_providers/etcenv.rb
100
+ homepage: https://github.com/eagletmt/hako-etcenv
101
+ licenses: []
102
+ metadata: {}
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ version: '0'
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ requirements: []
118
+ rubyforge_project:
119
+ rubygems_version: 2.4.5.1
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: Provide variables from etcd to hako using etcenv
123
+ test_files: []