bosh_lastpass_plugin 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb635e104d8c932f0c7ae6c36c546c77a98104ac
4
- data.tar.gz: e7f2b38b2d6f7e3f959e5a271ff68ef7ba72ddf3
3
+ metadata.gz: d92addaf3520acd8e27ace4bfa4686302f79f886
4
+ data.tar.gz: b9b5df33d5ceeca8fb1d8aa7f694cfe8a2ca56bd
5
5
  SHA512:
6
- metadata.gz: a5b8b6ac9e42ab7aac6ccc7a4d2cd2e9bfda761f7ad9505ac3995c69f6c66153a3e784497de1ba63f4091e4bfe0433c8da30c3b7158f7557f39bc1b693f425a9
7
- data.tar.gz: dd8084398426df03cac21bd7c207bce0e8e497ed2d65192deafcc7d6ac33a447e0a65fdb2d30722f8e42905ad7773641fb4e2dee1f3a4e80f46aa4a852e14453
6
+ metadata.gz: f629a89153ee7242e52d63fd221c26cadf29d9f87208255a3be74a981c4bc91879ce25860e6ff4524d4ceefcff9ebbdcede8d8a76b06d33a68e875b6aae5d88b
7
+ data.tar.gz: 5fbe716b7725433812773c048be5e87de04f167b4e8ca5380edf7da4de61a48c495acbc4fce4eb0db741b988a0c3a5b5473168140d6a5ff92ebb492473ae7c35
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.2
@@ -1,12 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bosh_lastpass_plugin (0.0.1)
4
+ bosh_lastpass_plugin (0.0.4)
5
5
  bosh_cli (>= 1.2682.0)
6
6
  bosh_common (>= 1.2682.0)
7
- git (~> 1.2.6)
8
- membrane (~> 1.1.0)
9
- semi_semantic (~> 1.1.0)
7
+ git (>= 1.2.6)
8
+ membrane (>= 1.1.0)
9
+ semi_semantic (>= 1.1.0)
10
10
 
11
11
  GEM
12
12
  remote: https://rubygems.org/
@@ -16,17 +16,17 @@ GEM
16
16
  jmespath (~> 1.0)
17
17
  aws-sdk-resources (2.2.0)
18
18
  aws-sdk-core (= 2.2.0)
19
- blobstore_client (1.3232.0)
19
+ blobstore_client (1.3262.0)
20
20
  aws-sdk-resources (= 2.2.0)
21
- bosh_common (~> 1.3232.0)
21
+ bosh_common (~> 1.3262.0)
22
22
  httpclient (= 2.7.1)
23
23
  multi_json (~> 1.1)
24
- bosh-template (1.3232.0)
25
- semi_semantic (~> 1.1.0)
26
- bosh_cli (1.3232.0)
27
- blobstore_client (~> 1.3232.0)
28
- bosh-template (~> 1.3232.0)
29
- bosh_common (~> 1.3232.0)
24
+ bosh-template (1.3262.0)
25
+ semi_semantic (~> 1.2.0)
26
+ bosh_cli (1.3262.0)
27
+ blobstore_client (~> 1.3262.0)
28
+ bosh-template (~> 1.3262.0)
29
+ bosh_common (~> 1.3262.0)
30
30
  cf-uaa-lib (~> 3.2.1)
31
31
  highline (~> 1.6.2)
32
32
  httpclient (= 2.7.1)
@@ -39,13 +39,13 @@ GEM
39
39
  progressbar (~> 0.9.0)
40
40
  sshkey (~> 1.7.0)
41
41
  terminal-table (~> 1.4.3)
42
- bosh_common (1.3232.0)
42
+ bosh_common (1.3262.0)
43
43
  logging (~> 1.8.2)
44
- semi_semantic (~> 1.1.0)
44
+ semi_semantic (~> 1.2.0)
45
45
  cf-uaa-lib (3.2.5)
46
46
  multi_json
47
47
  diff-lcs (1.2.5)
48
- git (1.2.9.1)
48
+ git (1.3.0)
49
49
  highline (1.6.21)
50
50
  httpclient (2.7.1)
51
51
  jmespath (1.2.4)
@@ -57,7 +57,7 @@ GEM
57
57
  multi_json (>= 1.8.4)
58
58
  membrane (1.1.0)
59
59
  minitar (0.5.4)
60
- multi_json (1.12.0)
60
+ multi_json (1.12.1)
61
61
  net-scp (1.1.2)
62
62
  net-ssh (>= 2.6.5)
63
63
  net-ssh (2.9.2)
@@ -92,7 +92,7 @@ GEM
92
92
  ruby-progressbar (~> 1.7)
93
93
  unicode-display_width (~> 1.0, >= 1.0.1)
94
94
  ruby-progressbar (1.8.1)
95
- semi_semantic (1.1.0)
95
+ semi_semantic (1.2.0)
96
96
  sshkey (1.7.0)
97
97
  terminal-table (1.4.5)
98
98
  unicode-display_width (1.0.5)
@@ -109,4 +109,4 @@ DEPENDENCIES
109
109
  rubocop
110
110
 
111
111
  BUNDLED WITH
112
- 1.11.2
112
+ 1.12.5
data/README.md CHANGED
@@ -1,9 +1,8 @@
1
1
  # Bosh lastpass plugin
2
2
 
3
- Store bosh secrets in lastpass instead of the manifest.
3
+ [![Build Status](https://travis-ci.org/pivotal-cf/bosh_lastpass_plugin.svg?branch=master)](https://travis-ci.org/pivotal-cf/bosh_lastpass_plugin)
4
4
 
5
- ## What is BOSH?
6
- BOSH orchestrates initial deployments and ongoing updates that are: predictable, repeatable, reliable, self-healing, infrastructure-agnostic. You can take a look on [BOSH project on GitHub](https://github.com/cloudfoundry/bosh) and read more details in [docs](http://docs.cloudfoundry.org/bosh/).
5
+ Store bosh secrets in lastpass instead of the manifest.
7
6
 
8
7
  ## How to install
9
8
  ```
@@ -60,6 +59,9 @@ properties:
60
59
  4. Push to the branch (`git push origin my-new-feature`)
61
60
  5. Create new Pull Request
62
61
 
62
+ ## What is BOSH?
63
+ BOSH orchestrates initial deployments and ongoing updates that are: predictable, repeatable, reliable, self-healing, infrastructure-agnostic. You can take a look on [BOSH project on GitHub](https://github.com/cloudfoundry/bosh) and read more details in [docs](http://docs.cloudfoundry.org/bosh/).
64
+
63
65
  ## Notes
64
66
 
65
67
  Generated by [BOSH plugin generator](https://github.com/Altoros/bosh-plugin-generator)
@@ -22,9 +22,9 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.add_runtime_dependency "bosh_cli", ">= 1.2682.0"
24
24
  spec.add_runtime_dependency "bosh_common", ">= 1.2682.0"
25
- spec.add_runtime_dependency "semi_semantic", "~> 1.1.0"
26
- spec.add_runtime_dependency "membrane", "~> 1.1.0"
27
- spec.add_runtime_dependency "git", "~> 1.2.6"
25
+ spec.add_runtime_dependency "semi_semantic", ">= 1.1.0"
26
+ spec.add_runtime_dependency "membrane", ">= 1.1.0"
27
+ spec.add_runtime_dependency "git", ">= 1.2.6"
28
28
 
29
29
  spec.add_development_dependency "bundler", "~> 1.6"
30
30
  spec.add_development_dependency "rspec", "~> 3.1.0"
@@ -2,9 +2,7 @@ require "bosh/lastpass_plugin"
2
2
 
3
3
  module Bosh::Cli::Command
4
4
  class LastpassPlugin < Base
5
- extend Bosh::LastpassPlugin::Additions
6
-
7
- inject_into_yaml_parsing
5
+ Bosh::LastpassPlugin::Additions.inject_lastpass
8
6
 
9
7
  usage "lastpass show manifest"
10
8
  desc "display the manifest with lastpass keys substituted"
@@ -1,12 +1,13 @@
1
1
  module Bosh
2
2
  module LastpassPlugin
3
3
  module Additions
4
- def inject_into_yaml_parsing
4
+ def self.inject_lastpass
5
5
  ::BoshExtensions.module_eval do
6
6
  def lpass key,type
7
7
  output = `lpass show #{key} --#{type}`
8
8
  if $?.exitstatus != 0
9
9
  say "Error: BOSH Lastpass Error failed to fetch #{key}"
10
+ say "Error: #{output}"
10
11
  exit($?.exitstatus)
11
12
  end
12
13
  output
@@ -1,5 +1,5 @@
1
1
  module Bosh
2
2
  module LastpassPlugin
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
@@ -1,11 +1,58 @@
1
1
  describe "bosh say hello" do
2
+ let(:path) { create_path_with_executables("ruby", "git", "bosh", mock_lpass_path) }
2
3
 
3
- before do
4
- system("bosh say hello > /dev/null")
4
+ before(:each) do
5
+ @output = `PATH=#{path} bosh --config #{erb_fixtures("bosh_config.erb")} lastpass show manifest`
5
6
  end
7
+ after(:each) do
8
+ FileUtils.rm_rf path
9
+ end
10
+
11
+
12
+ context "substitutes the lpass passwords " do
13
+ let(:mock_lpass_path) { fixtures("stub_executables/success/lpass")}
14
+ it "exits without errors" do
15
+ expect($?.exitstatus).to eq(0)
16
+ end
17
+
18
+ it "successfully substitutes lpass entries" do
19
+ hash = YAML.load(@output.split("\n")[1..-1].join("\n"))
20
+ expect(hash["instance_groups"][0]["jobs"][0]["properties"]["username"]).to eql("entry_from_lastpass")
21
+ end
22
+ end
23
+
24
+ context "lpass key/value not found" do
25
+ let(:mock_lpass_path) { fixtures("stub_executables/key_not_found/lpass")}
26
+
27
+ it "exits with errors" do
28
+ expect($?.exitstatus).to eq(1)
29
+ end
6
30
 
7
- it "exits without errors" do
8
- expect($?.exitstatus).to eq(0)
31
+ it "displays a error message" do
32
+ expect(@output).to include("Could not find specified account")
33
+ end
9
34
  end
10
35
 
36
+ context "lpass command not found" do
37
+ let(:mock_lpass_path) { fixtures("stub_executables/command_not_found/lpass")}
38
+ it "exits with errors" do
39
+ expect($?.exitstatus).to eq(127)
40
+ end
41
+ it "displays a error message" do
42
+ expect(@output).to include("BOSH Lastpass Error lastpass cli not found")
43
+ end
44
+ end
45
+ end
46
+
47
+ def required_executables_path(*commands)
48
+ commands.collect{|command| File.dirname(`which #{command}`)}.uniq.join(":")
49
+ end
50
+
51
+
52
+ def create_path_with_executables(*commands)
53
+ dir = Dir.mktmpdir
54
+ commands.collect{|command| `which #{command}`.strip}.reject(&:empty?).each do |command|
55
+ `ln -s #{command} #{dir}`
56
+ end
57
+ dir
11
58
  end
@@ -0,0 +1,16 @@
1
+ ---
2
+ target: https://whatever.com:25555
3
+ target_name: Bosh Lite Director
4
+ target_version: 1.3215.0 (00000000)
5
+ target_uuid: 17a45148-1d00-43bc-af28-9882e5a6535a
6
+ ca_cert:
7
+ https://whatever.com:25555:
8
+ aliases:
9
+ target:
10
+ 17a45148-1d00-43bc-af28-9882e5a6535a: https://whatever.com:25555
11
+ auth:
12
+ https://whatever.com:25555:
13
+ username: admin
14
+ password: admin
15
+ deployment:
16
+ https://whatever.com:25555: "<%= File.dirname(__FILE__) %>/deployment.yml"
@@ -0,0 +1,22 @@
1
+ ---
2
+ name: fixture-deployment
3
+
4
+ director_uuid: 17a45148-1d00-43bc-af28-9882e5a6535a
5
+
6
+ releases:
7
+ - name: syslog
8
+ version: 7
9
+
10
+ stemcells:
11
+ - alias: trusty
12
+ os: ubuntu-trusty
13
+ version: latest
14
+
15
+ instance_groups:
16
+ - name: broker
17
+ instances: 1
18
+ jobs:
19
+ - name: syslog
20
+ release: syslog
21
+ properties:
22
+ username: <%= lpass "test_note", "test_field" %>
@@ -0,0 +1,2 @@
1
+ echo "Error: Could not find specified account(s)."
2
+ exit 1
@@ -0,0 +1,2 @@
1
+ echo "entry_from_lastpass"
2
+ exit 0
@@ -8,5 +8,23 @@ $:.unshift(File.expand_path("../../lib", __FILE__))
8
8
 
9
9
  require "rspec/core"
10
10
  require "rspec/its"
11
+ require "yaml"
12
+ require "erb"
13
+ require 'tempfile'
11
14
 
12
- require "bosh/lastpass_plugin"
15
+ def fixtures name
16
+ File.join(File.dirname(__FILE__), "fixtures", name)
17
+ end
18
+
19
+ def erb_fixtures name
20
+ file = Tempfile.new('bosh_lastpass_plugin')
21
+ file.write(erb_evaluate(fixtures(name)))
22
+ file.close
23
+ file.path
24
+ end
25
+
26
+ def erb_evaluate(filename)
27
+ erb = ERB.new(File.read(filename))
28
+ erb.filename = filename
29
+ erb.result
30
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosh_lastpass_plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jatin Naik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bosh_cli
@@ -42,42 +42,42 @@ dependencies:
42
42
  name: semi_semantic
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.1.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
54
  version: 1.1.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: membrane
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.1.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.1.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: git
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: 1.2.6
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: 1.2.6
83
83
  - !ruby/object:Gem::Dependency
@@ -159,6 +159,7 @@ extra_rdoc_files: []
159
159
  files:
160
160
  - ".gitignore"
161
161
  - ".rspec"
162
+ - ".travis.yml"
162
163
  - Gemfile
163
164
  - Gemfile.lock
164
165
  - README.md
@@ -169,6 +170,10 @@ files:
169
170
  - lib/bosh/lastpass_plugin/additions.rb
170
171
  - lib/bosh/lastpass_plugin/version.rb
171
172
  - spec/command_spec.rb
173
+ - spec/fixtures/bosh_config.erb
174
+ - spec/fixtures/deployment.yml
175
+ - spec/fixtures/stub_executables/key_not_found/lpass
176
+ - spec/fixtures/stub_executables/success/lpass
172
177
  - spec/spec_helper.rb
173
178
  homepage: https://github.com/cloudfoundry/bosh
174
179
  licenses: []
@@ -195,4 +200,8 @@ specification_version: 4
195
200
  summary: Short description.
196
201
  test_files:
197
202
  - spec/command_spec.rb
203
+ - spec/fixtures/bosh_config.erb
204
+ - spec/fixtures/deployment.yml
205
+ - spec/fixtures/stub_executables/key_not_found/lpass
206
+ - spec/fixtures/stub_executables/success/lpass
198
207
  - spec/spec_helper.rb