docker-env 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: f80475bc0268796101ce3daa47d31f65e1683f53
4
+ data.tar.gz: a3e6df30b2c4c5b41aef432d7d5cda80fa8b260a
5
+ SHA512:
6
+ metadata.gz: a9246fd45fca6f9e45b82b7a076347d8be2fb59ed30e12a06824615f77e1f01528ea9c27f9fc0aac9079dceaac4842ee8b8a8355bc15ee69574ece2d5047fb62
7
+ data.tar.gz: 290642b66307a88bf883da5bbfdffe43961dc0aa89d5ce0170c2ff0e6be6f40854890f20df7ce5d3193afe05c76c12d3d9c290e31d4e6c4f6489d4166a0db44f
@@ -0,0 +1 @@
1
+ /pkg
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
@@ -0,0 +1,36 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ docker-env (0)
5
+ gli (= 2.14.0)
6
+ version
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ byebug (9.0.6)
12
+ coderay (1.1.1)
13
+ gli (2.14.0)
14
+ method_source (0.8.2)
15
+ pry (0.10.4)
16
+ coderay (~> 1.1.0)
17
+ method_source (~> 0.8.1)
18
+ slop (~> 3.4)
19
+ pry-byebug (3.4.1)
20
+ byebug (~> 9.0)
21
+ pry (~> 0.10)
22
+ rake (11.3.0)
23
+ slop (3.6.0)
24
+ version (1.0.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ docker-env!
31
+ pry
32
+ pry-byebug
33
+ rake
34
+
35
+ BUNDLED WITH
36
+ 1.13.6
@@ -0,0 +1,39 @@
1
+ = Name
2
+
3
+ `docker-env` - Manage docker for mac qcow images
4
+
5
+ = SYNOPSIS
6
+
7
+ ``` sh
8
+ docker-env [global options] command [command options] [arguments...]
9
+ ```
10
+
11
+ = VERSION
12
+ 0.1.0
13
+
14
+ = GLOBAL OPTIONS
15
+
16
+ --help - Show this message
17
+ -v, --[no-]verbose - be more verbose
18
+ --version - Display the program version
19
+
20
+ = COMMANDS
21
+
22
+ current - Show current image
23
+ help - Shows a list of commands or help for one command
24
+ init - setup by moving Docker.qcow2 to "image_name" and linking back
25
+ list, ls - list available qcow images (.../Docker.qcow2.{name})
26
+ new - create new qcow image
27
+ rm - Delete "image"
28
+ use - Link to "image""
29
+
30
+ = NOTES ON `new`
31
+
32
+ `new` removes the current link so that the next time docker starts, it will
33
+ create a new empty image file. The (slightly long) steps to follow:
34
+
35
+ 1. Stop Docker.app
36
+ 2. Run this command (`docker-env new`)
37
+ 3. Restart Docker.app
38
+ 4. Stop Docker.app
39
+ 5. Run `docker-env init {name}` to name the new image and create the symlink
@@ -0,0 +1,4 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/version_task'
3
+
4
+ Rake::VersionTask.new
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.0.0
@@ -0,0 +1,134 @@
1
+ #!/usr/bin/env ruby
2
+ require 'gli'
3
+ require 'version'
4
+
5
+ include GLI::App
6
+
7
+ DIR = File.expand_path(
8
+ '~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux'
9
+ ).freeze
10
+ NAME = 'Docker.qcow2'.freeze
11
+ SYMLINK = "#{DIR}/#{NAME}".freeze
12
+
13
+ program_desc 'Manage docker for mac qcow images'
14
+ version Version.current(File.dirname(__FILE__))
15
+
16
+ subcommand_option_handling :normal
17
+ arguments :strict
18
+ wrap_help_text :verbatim
19
+
20
+ switch [:v, :verbose], desc: 'be more verbose'
21
+
22
+ def current(options)
23
+ f = File.readlink(SYMLINK)
24
+ options[:verbose] ? f : f.split('.').last
25
+ end
26
+
27
+ def running?
28
+ if `ps ax` =~ %r[/[D]ocker.app]
29
+ $stderr.puts "Please quit Docker.app before using this script!"
30
+ exit 1
31
+ end
32
+ end
33
+
34
+ desc 'setup by moving Docker.qcow2 to "image_name" and linking back'
35
+ arg 'image_name'
36
+ command :init do |c|
37
+ c.action do |global_options,options,args|
38
+ running?
39
+ if File.symlink?(SYMLINK)
40
+ $stderr.puts "Already setup. Current is: #{current(global_options)}"
41
+ exit 1
42
+ end
43
+
44
+ file = "#{SYMLINK}.#{args[0]}"
45
+ File.rename(SYMLINK, file)
46
+ File.symlink(file, SYMLINK)
47
+
48
+ puts "Current is now: " + current(global_options)
49
+ end
50
+ end
51
+
52
+ desc 'list available qcow images (.../Docker.qcow2.{name})'
53
+ command [:list, :ls] do |c|
54
+ c.action do |global_options,options,args|
55
+ puts Dir.glob("#{SYMLINK}.*").map { |f|
56
+ f.split('.').last
57
+ }
58
+ end
59
+ end
60
+
61
+ desc 'create new qcow "image"'
62
+ long_desc <<EOF
63
+ Removes current link so that the next time docker starts, it will create a
64
+ new empty image file. The (slightly long) steps to follow:
65
+
66
+ 1. Stop Docker.app
67
+ 2. Run this command (`docker-env new`)
68
+ 3. Restart Docker.app
69
+ 4. Stop Docker.app
70
+ 5. Run `docker-env init {name}` to name the new image and
71
+ create the symlink
72
+ EOF
73
+ command :new do |c|
74
+ c.action do |global_options,options,args|
75
+ running?
76
+ if File.exist?(SYMLINK) || !File.symlink?(SYMLINK)
77
+ $stderr.puts "Please use '--force' to force delete current image!"
78
+ exit 1
79
+ end
80
+
81
+ begin
82
+ File.unlink(SYMLINK)
83
+ rescue Errno::ENOENT
84
+ end
85
+ help(["new"])
86
+ end
87
+ end
88
+
89
+ desc 'Delete "image"'
90
+ arg 'image'
91
+ command :rm do |c|
92
+ c.action do |global_options,options,args|
93
+ file = "#{SYMLINK}.#{args[0]}"
94
+ unless File.exist?(file)
95
+ $stderr.puts "Image #{args[0]} doesnt exist!"
96
+ exit 1
97
+ end
98
+ if File.readlink(SYMLINK) == file
99
+ $stderr.puts "Can't delete currently linked image"
100
+ exit 1
101
+ end
102
+
103
+ File.unlink(file)
104
+ end
105
+ end
106
+
107
+ desc 'Link to "image"'
108
+ arg 'image'
109
+ command :use do |c|
110
+ c.action do |global_options,options,args|
111
+ running?
112
+ file = "#{SYMLINK}.#{args[0]}"
113
+ File.exist?(file) or raise "Image #{file} does not exist"
114
+
115
+ begin
116
+ File.unlink(SYMLINK)
117
+ rescue Errno::ENOENT
118
+ end
119
+ File.symlink(file, SYMLINK)
120
+ end
121
+ end
122
+
123
+ desc 'Show current image'
124
+ command :current do |c|
125
+ c.action do |global_options,options,args|
126
+ puts current(global_options)
127
+ end
128
+ end
129
+
130
+ on_error do |exception|
131
+ true
132
+ end
133
+
134
+ exit run(ARGV)
@@ -0,0 +1,22 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'docker-env'
3
+ s.version = File.read("VERSION").chomp # file managed by version gem...
4
+ s.authors = ["Rick Frankel"]
5
+ s.email = ["docker-env@cybercode.nyc"]
6
+ s.summary = 'A tool to switch docker for mac environments'
7
+ s.description = 'docker-env will setup soft-links and switch between docker qcow images.'
8
+ s.homepage = "https://github.com/cybercode/docker-env"
9
+ s.licenses = ["MIT"]
10
+ s.platform = Gem::Platform::RUBY
11
+ s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
12
+
13
+ s.bindir = 'bin'
14
+ s.executables << 'docker-env'
15
+
16
+ s.add_development_dependency('rake')
17
+ s.add_development_dependency('pry')
18
+ s.add_development_dependency('pry-byebug')
19
+
20
+ s.add_runtime_dependency('version')
21
+ s.add_runtime_dependency('gli','2.14.0')
22
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docker-env
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rick Frankel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-12-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rake
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
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: pry
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
+ - !ruby/object:Gem::Dependency
42
+ name: pry-byebug
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: version
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: gli
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '='
74
+ - !ruby/object:Gem::Version
75
+ version: 2.14.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '='
81
+ - !ruby/object:Gem::Version
82
+ version: 2.14.0
83
+ description: docker-env will setup soft-links and switch between docker qcow images.
84
+ email:
85
+ - docker-env@cybercode.nyc
86
+ executables:
87
+ - docker-env
88
+ extensions: []
89
+ extra_rdoc_files: []
90
+ files:
91
+ - ".gitignore"
92
+ - Gemfile
93
+ - Gemfile.lock
94
+ - README.md
95
+ - Rakefile
96
+ - VERSION
97
+ - bin/docker-env
98
+ - docker-env.gemspec
99
+ homepage: https://github.com/cybercode/docker-env
100
+ licenses:
101
+ - MIT
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.6.8
120
+ signing_key:
121
+ specification_version: 4
122
+ summary: A tool to switch docker for mac environments
123
+ test_files: []