vagrant-secret 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 777b4895849126e5718075029874200fa11ba7f3
4
+ data.tar.gz: 6ec180af2f9cf889fdc05792452d119af8dd75e5
5
+ SHA512:
6
+ metadata.gz: 124751e598dcf420efef5207ab26e7cea948213ef930c8f3ed3779ee3efef6fe6c05aa11ff1326963ce29253ee0871cf71a9fe302fe1177eae523b42cf94c200
7
+ data.tar.gz: 533f4da933b5437050e92b391172bce86e486ea8c246dbba75269f1020606e0a9e80777c7c05972750a19eda632af115fe495bc8a70914c349251882cccdf5ad
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .vagrant
19
+ vendor/bundle
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in vagrant-pushover.gemspec
4
+ gemspec
5
+
6
+ group :development do
7
+ gem "vagrant", :git => "git://github.com/mitchellh/vagrant.git"
8
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 tcnksm
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,53 @@
1
+ # Vagrant-Secret
2
+
3
+ You don't want to write your secret variable like `api_key` or `token` directly in your Vagrantfile.
4
+
5
+ This plugin enables,
6
+
7
+ 1. Generate `secret.yaml` and write your secret keys
8
+ 1. Use secret variable in your Vagrantfile
9
+
10
+ ## Installation
11
+
12
+ Install it as a Vagrant plugin.
13
+
14
+ ```bash
15
+ $ vagrant plugin install vagrant-secret
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ Generate `secret.yaml`
21
+
22
+ ```bash
23
+ $ vagrant secret-init
24
+ ```
25
+
26
+ Edit your `.vagrant.secret.yaml`
27
+
28
+ ```
29
+ client_id: "*******"
30
+ api_key: "********"
31
+ ```
32
+
33
+ Use it in your Vagrantfile (for example when you use [DigitalOcean](https://cloud.digitalocean.com/)).
34
+
35
+ ```ruby
36
+ Vagrant.configure('2') do |config|
37
+ config.vm.provider :digital_ocean do |provider, override|
38
+ provider.client_id = Secret.client_id
39
+ provider.api_key = Secret.api_key
40
+ end
41
+ end
42
+ ```
43
+
44
+ You can use your yaml key as `Secret` class variable.
45
+
46
+
47
+ ## Contributing
48
+
49
+ 1. Fork it ( http://github.com/<my-github-username>/vagrant-secret/fork )
50
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
51
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
52
+ 4. Push to the branch (`git push origin my-new-feature`)
53
+ 5. Create new Pull Request
@@ -0,0 +1,20 @@
1
+ require "vagrant-secret"
2
+ require "bundler/gem_tasks"
3
+
4
+ version = VagrantPlugins::Secret::VERSION
5
+
6
+ desc "Install your plugin to your system vagrant."
7
+ task :install_plugin do
8
+ system("git add -u")
9
+ Rake::Task[:build].execute
10
+ system("/usr/bin/vagrant plugin install pkg/vagrant-secret-#{version}.gem")
11
+ end
12
+
13
+ task :uninstall_plugin do
14
+ system("/usr/bin/vagrant plugin uninstall vagrant-pushover")
15
+ end
16
+
17
+ # alias
18
+ task :i => :install_plugin
19
+ task :u => :uninstall_plugin
20
+
@@ -0,0 +1,4 @@
1
+ Vagrant.configure("2") do |config|
2
+ config.vm.box = "precise64"
3
+ config.vm.box_url = "http://files.vagrantup.com/precise64.box"
4
+ end
@@ -0,0 +1,30 @@
1
+ require "pathname"
2
+ require "vagrant-secret/version"
3
+ require "vagrant-secret/plugin"
4
+
5
+ module VagrantPlugins
6
+ module Secret
7
+
8
+ def self.secret_file
9
+ called_root.join(".vagrant/secret.yaml")
10
+ end
11
+
12
+ def self.called_root
13
+ Pathname.pwd
14
+ end
15
+
16
+ def self.generate_secret
17
+ content = <<-EOF
18
+ # Write your secret settings here.
19
+ password: "*****"
20
+ EOF
21
+ File.open(secret_file,'w') do |f|
22
+ f.puts content
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+ # Load secret file and register it as class variable
30
+ require "vagrant-secret/loader"
@@ -0,0 +1,22 @@
1
+ require "net/https"
2
+
3
+ module VagrantPlugins
4
+ module Secret
5
+ class Command < Vagrant.plugin("2", :command)
6
+
7
+ def self.synopsis
8
+ "generates secret file"
9
+ end
10
+
11
+ def execute
12
+ secret_file = ::VagrantPlugins::Secret.secret_file
13
+ if secret_file.exist?
14
+ @env.ui.info("[vagrant-secret] Secret key file (.vagrant/secret.rb) is already exist.")
15
+ else
16
+ ::VagrantPlugins::Secret.generate_secret
17
+ @env.ui.info("[vagrant-secret] Generated secret key file (.vagrant/secret.rb).")
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,11 @@
1
+ require "ostruct"
2
+ require "yaml"
3
+
4
+ Secret = OpenStruct.new
5
+ if File.exist? (VagrantPlugins::Secret.secret_file)
6
+ YAML.load_file(VagrantPlugins::Secret.secret_file).each do |k,v|
7
+ Secret.send("#{k}=",v)
8
+ end
9
+ end
10
+
11
+
@@ -0,0 +1,23 @@
1
+ begin
2
+ require "vagrant"
3
+ rescue LoadError
4
+ raise "The Vagrant secret plugin must be run within Vagrant."
5
+ end
6
+
7
+ module VagrantPlugins
8
+ module Secret
9
+
10
+ class Plugin < Vagrant.plugin("2")
11
+ name "Secret"
12
+ description <<-DESC
13
+ Enable secret variable and use it in Vagrantfile
14
+ DESC
15
+
16
+ command "secret-init" do
17
+ require_relative "command"
18
+ Command
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module Secret
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'vagrant-secret/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "vagrant-secret"
8
+ spec.version = VagrantPlugins::Secret::VERSION
9
+ spec.authors = ["tcnksm"]
10
+ spec.email = ["nsd22843@gmail.com"]
11
+ spec.summary = %q{Write secret-key in Vagrantfile}
12
+ spec.description = %q{Enable to read external secret-key file}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.5"
22
+ spec.add_development_dependency "rake"
23
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-secret
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - tcnksm
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-02-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Enable to read external secret-key file
42
+ email:
43
+ - nsd22843@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - .gitignore
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - Vagrantfile
54
+ - lib/vagrant-secret.rb
55
+ - lib/vagrant-secret/command.rb
56
+ - lib/vagrant-secret/loader.rb
57
+ - lib/vagrant-secret/plugin.rb
58
+ - lib/vagrant-secret/version.rb
59
+ - vagrant-secret.gemspec
60
+ homepage: ''
61
+ licenses:
62
+ - MIT
63
+ metadata: {}
64
+ post_install_message:
65
+ rdoc_options: []
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - '>='
71
+ - !ruby/object:Gem::Version
72
+ version: '0'
73
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
+ requirements:
75
+ - - '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ requirements: []
79
+ rubyforge_project:
80
+ rubygems_version: 2.0.14
81
+ signing_key:
82
+ specification_version: 4
83
+ summary: Write secret-key in Vagrantfile
84
+ test_files: []