vagrant-docker-login 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: daf53667890676875403171525f4fbe42f1680d4
4
+ data.tar.gz: 825dfb86bc29f86c19fbbebd988ca0a99e3c0daf
5
+ SHA512:
6
+ metadata.gz: 1dabc43366e1f6a0558539efb0f83844589fc5ef54682ff614e5fb2d75cf93ddcd99f6049b55dbe9322141ef17150042137c4314f500899a3b78f4c82aeb787a
7
+ data.tar.gz: 7d3379721f1d06362072fb3c7e2f0569493254f5b0f448bd35e3eaf47ff442c4fa3db909f53f8cf191a5a04aec2bbdddc1ebfa47fb8aea2137070622673f3fa9
@@ -0,0 +1,7 @@
1
+ Gemfile.lock
2
+ coverage
3
+ .ruby-version
4
+ *.sublime-*
5
+ *.gem
6
+ pkg
7
+ .vagrant
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "https://rubygems.org"
2
+ gemspec
3
+
4
+ group :development do
5
+ gem "vagrant", git: "https://github.com/mitchellh/vagrant.git", tag: "v1.7.4"
6
+ gem "rake"
7
+ end
8
+
9
+ group :plugins do
10
+ gem "vagrant-docker-login", path: "."
11
+ end
data/LICENSE ADDED
@@ -0,0 +1,5 @@
1
+ Copyright (c) 2016, Leigh McCulloch
2
+
3
+ Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
4
+
5
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
@@ -0,0 +1,42 @@
1
+ # Vagrant Provisioner: Docker Login
2
+
3
+ A Vagrant provisioner for [Docker's login command](https://docs.docker.com/engine/reference/commandline/login/). Login to a Docker compose registry automatically.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ vagrant plugin install vagrant-docker-login
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ### Install docker and login configured with environment variables
14
+
15
+ Define environment variables:
16
+ * `DOCKER_USERNAME` or `DOCKER_EMAIL`
17
+ * `DOCKER_PASSWORD`
18
+ * `DOCKER_SERVER` optional, will use the main Docker registry if not set
19
+
20
+ ```ruby
21
+ Vagrant.configure("2") do |config|
22
+ config.vm.box = "ubuntu/wily64"
23
+
24
+ config.vm.provision :docker
25
+ config.vm.provision :docker_login
26
+ end
27
+ ```
28
+
29
+ ### Install docker and login with credentials and to server provided in Vagrantfile
30
+
31
+ ```ruby
32
+ Vagrant.configure("2") do |config|
33
+ config.vm.box = "ubuntu/wily64"
34
+
35
+ config.vm.provision :docker
36
+ config.vm.provision :docker_login, username: "username", password: "password", server: "localhost:8080"
37
+ end
38
+ ```
39
+
40
+ ## Example
41
+
42
+ See `example` in the repository for a full working example.
@@ -0,0 +1,3 @@
1
+ require "rubygems"
2
+ require "bundler/setup"
3
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,21 @@
1
+ # -*- mode: ruby -*-
2
+ # vi: set ft=ruby :
3
+
4
+ # unless Vagrant.has_plugin?("vagrant-docker-login")
5
+ # system("vagrant plugin install vagrant-docker-login")
6
+ # puts "Dependencies installed, please try the command again."
7
+ # exit
8
+ # end
9
+
10
+ unless ENV["DOCKER_USERNAME"] && ENV["DOCKER_PASSWORD"]
11
+ puts "Set your DOCKER_USERNAME and DOCKER_PASSWORD environment variable."
12
+ exit
13
+ end
14
+
15
+ Vagrant.configure("2") do |config|
16
+ config.vm.box = "hashicorp/precise64"
17
+
18
+ config.vm.provision :shell, inline: "apt-get update"
19
+ config.vm.provision :docker
20
+ config.vm.provision :docker_login
21
+ end
@@ -0,0 +1,11 @@
1
+ require "pathname"
2
+
3
+ require "vagrant-docker-login/plugin"
4
+
5
+ module VagrantPlugins
6
+ module DockerLoginProvisioner
7
+ def self.source_root
8
+ @source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ module VagrantPlugins
2
+ module DockerLoginProvisioner
3
+ class Config < Vagrant.plugin("2", :config)
4
+ attr_accessor :username, :email, :password, :server
5
+
6
+ def initialize
7
+ @username = UNSET_VALUE
8
+ @email = UNSET_VALUE
9
+ @password = UNSET_VALUE
10
+ @server = UNSET_VALUE
11
+ end
12
+
13
+ def finalize!
14
+ @username = ENV["DOCKER_USERNAME"] if @username == UNSET_VALUE
15
+ @email = ENV["DOCKER_EMAIL"] if @email == UNSET_VALUE
16
+ @password = ENV["DOCKER_PASSWORD"] if @password == UNSET_VALUE
17
+ @server = ENV["DOCKER_SERVER"] if @server == UNSET_VALUE
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,39 @@
1
+ require "pathname"
2
+
3
+ module VagrantPlugins
4
+ module DockerLoginProvisioner
5
+ class DockerLogin
6
+ def initialize(machine, config)
7
+ @machine = machine
8
+ @config = config
9
+ end
10
+
11
+ def login
12
+ @machine.ui.detail(I18n.t(:docker_login_logging_in, server: @config.server))
13
+ @machine.communicate.tap do |comm|
14
+ components = []
15
+ components << "docker login"
16
+ components << "--username=\"#{@config.username}\"" if @config.username
17
+ components << "--email=\"#{@config.email}\"" if @config.email
18
+ components << "--password=\"#{@config.password}\"" if @config.password
19
+ components << "#{@config.server}" if @config.server
20
+ command = components.join(" ")
21
+ comm.sudo(command) do |type, data|
22
+ handle_comm(type, data)
23
+ end
24
+ end
25
+ end
26
+
27
+ protected
28
+
29
+ def handle_comm(type, data)
30
+ data.chomp!
31
+ return if data.empty?
32
+ case type
33
+ when :stdout; @machine.ui.detail(data)
34
+ when :stderr; @machine.ui.error(data)
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,2 @@
1
+ en:
2
+ docker_login_logging_in: Logging into Docker server %{server}
@@ -0,0 +1,23 @@
1
+ module VagrantPlugins
2
+ module DockerLoginProvisioner
3
+ class Plugin < Vagrant.plugin("2")
4
+ name "docker-login-provisioner"
5
+ description <<-DESC
6
+ Provides support for provisioning your virtual machines that run Docker, by logging them into a Docker repository automatically.
7
+ DESC
8
+
9
+ I18n.load_path << File.expand_path("../locales/en.yml", __FILE__)
10
+ I18n.reload!
11
+
12
+ config(:docker_login, :provisioner) do
13
+ require_relative "config"
14
+ Config
15
+ end
16
+
17
+ provisioner(:docker_login) do
18
+ require_relative "provisioner"
19
+ Provisioner
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ require_relative "docker_login"
2
+
3
+ module VagrantPlugins
4
+ module DockerLoginProvisioner
5
+ class Provisioner < Vagrant.plugin("2", :provisioner)
6
+ def initialize(machine, config, docker_login = nil)
7
+ super(machine, config)
8
+
9
+ @docker_login = docker_login || DockerLogin.new(@machine, @config)
10
+ end
11
+
12
+ def provision
13
+ @docker_login.login
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,5 @@
1
+ module VagrantPlugins
2
+ module DockerLoginProvisioner
3
+ VERSION = "1.0.0"
4
+ end
5
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ lib = File.expand_path("../lib", __FILE__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+
6
+ require "vagrant-docker-login/version"
7
+
8
+ Gem::Specification.new do |s|
9
+ s.name = "vagrant-docker-login"
10
+ s.version = VagrantPlugins::DockerLoginProvisioner::VERSION
11
+ s.platform = Gem::Platform::RUBY
12
+ s.authors = ["Leigh McCulloch"]
13
+ s.homepage = "https://github.com/leighmcculloch/vagrant-docker-login"
14
+ s.summary = %q{A Vagrant provisioner for logging into docker.}
15
+ s.description = %q{A Vagrant provisioner for logging into docker.}
16
+
17
+ s.files = `git ls-files -z`.split("\0")
18
+ s.require_path = "lib"
19
+ end
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: vagrant-docker-login
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Leigh McCulloch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-08 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A Vagrant provisioner for logging into docker.
14
+ email:
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - ".gitignore"
20
+ - Gemfile
21
+ - LICENSE
22
+ - README.md
23
+ - Rakefile
24
+ - example/Vagrantfile
25
+ - lib/vagrant-docker-login.rb
26
+ - lib/vagrant-docker-login/config.rb
27
+ - lib/vagrant-docker-login/docker_login.rb
28
+ - lib/vagrant-docker-login/locales/en.yml
29
+ - lib/vagrant-docker-login/plugin.rb
30
+ - lib/vagrant-docker-login/provisioner.rb
31
+ - lib/vagrant-docker-login/version.rb
32
+ - vagrant-docker-login.gemspec
33
+ homepage: https://github.com/leighmcculloch/vagrant-docker-login
34
+ licenses: []
35
+ metadata: {}
36
+ post_install_message:
37
+ rdoc_options: []
38
+ require_paths:
39
+ - lib
40
+ required_ruby_version: !ruby/object:Gem::Requirement
41
+ requirements:
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '0'
45
+ required_rubygems_version: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ requirements: []
51
+ rubyforge_project:
52
+ rubygems_version: 2.4.8
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: A Vagrant provisioner for logging into docker.
56
+ test_files: []