kontena-cli 1.1.0.pre1 → 1.1.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +3 -9
  3. data/README.md +1 -1
  4. data/VERSION +1 -1
  5. data/examples/kontena-plugin-hello/kontena-plugin-hello.gemspec +1 -1
  6. data/kontena-cli.gemspec +3 -2
  7. data/lib/kontena/cli/cloud/master/add_command.rb +2 -2
  8. data/lib/kontena/cli/grids/common.rb +4 -0
  9. data/lib/kontena/cli/grids/create_command.rb +3 -1
  10. data/lib/kontena/cli/grids/update_command.rb +4 -0
  11. data/lib/kontena/cli/master/config/get_command.rb +4 -0
  12. data/lib/kontena/cli/master/remove_command.rb +10 -13
  13. data/lib/kontena/cli/master/ssh_command.rb +43 -0
  14. data/lib/kontena/cli/master_command.rb +3 -0
  15. data/lib/kontena/cli/nodes/ssh_command.rb +28 -13
  16. data/lib/kontena/cli/registry/create_command.rb +1 -1
  17. data/lib/kontena/cli/stack_command.rb +2 -0
  18. data/lib/kontena/cli/stacks/build_command.rb +25 -21
  19. data/lib/kontena/cli/stacks/common.rb +45 -3
  20. data/lib/kontena/cli/stacks/deploy_command.rb +5 -2
  21. data/lib/kontena/cli/stacks/install_command.rb +7 -3
  22. data/lib/kontena/cli/stacks/list_command.rb +4 -4
  23. data/lib/kontena/cli/stacks/registry/push_command.rb +7 -3
  24. data/lib/kontena/cli/stacks/show_command.rb +2 -1
  25. data/lib/kontena/cli/stacks/stacks_helper.rb +55 -5
  26. data/lib/kontena/cli/stacks/upgrade_command.rb +6 -3
  27. data/lib/kontena/cli/stacks/validate_command.rb +47 -0
  28. data/lib/kontena/cli/stacks/yaml/opto/prompt_resolver.rb +1 -6
  29. data/lib/kontena/cli/stacks/yaml/reader.rb +189 -100
  30. data/lib/kontena/debug_instrumentor.rb +1 -1
  31. data/lib/kontena_cli.rb +12 -5
  32. data/omnibus/.gitignore +12 -0
  33. data/omnibus/.kitchen.yml +44 -0
  34. data/omnibus/Berksfile +12 -0
  35. data/omnibus/Gemfile +22 -0
  36. data/omnibus/Gemfile.lock +183 -0
  37. data/omnibus/README.md +120 -0
  38. data/omnibus/config/projects/kontena.rb +33 -0
  39. data/omnibus/config/software/kontena.rb +13 -0
  40. data/omnibus/config/software/liblzma.rb +47 -0
  41. data/omnibus/omnibus.rb +56 -0
  42. data/omnibus/package-scripts/kontena/postinst +22 -0
  43. data/omnibus/package-scripts/kontena/postinstall +12 -0
  44. data/omnibus/package-scripts/kontena/postrm +9 -0
  45. data/omnibus/package-scripts/kontena/preinst +7 -0
  46. data/omnibus/package-scripts/kontena/prerm +15 -0
  47. data/omnibus/resources/kontena/pkg/distribution.xml.erb +22 -0
  48. data/omnibus/resources/kontena/pkg/license.html.erb +202 -0
  49. data/omnibus/resources/kontena/pkg/welcome.html.erb +5 -0
  50. data/omnibus/wrappers/sh/kontena +7 -0
  51. data/spec/fixtures/kontena-with-variables.yml +1 -1
  52. data/spec/fixtures/kontena_build_v3.yml +1 -1
  53. data/spec/fixtures/stack-with-invalid-liquid.yml +22 -0
  54. data/spec/fixtures/stack-with-liquid.yml +21 -0
  55. data/spec/fixtures/stack-with-prompted-variables.yml +10 -5
  56. data/spec/fixtures/stack-with-variables.yml +6 -1
  57. data/spec/kontena/cli/cloud/master/add_command_spec.rb +2 -2
  58. data/spec/kontena/cli/services/containers_command_spec.rb +2 -2
  59. data/spec/kontena/cli/stacks/build_command_spec.rb +37 -26
  60. data/spec/kontena/cli/stacks/install_command_spec.rb +6 -1
  61. data/spec/kontena/cli/stacks/upgrade_command_spec.rb +14 -18
  62. data/spec/kontena/cli/stacks/yaml/reader_spec.rb +76 -21
  63. data/spec/kontena/kontena_cli_spec.rb +28 -0
  64. data/spec/support/requirements_helper.rb +20 -2
  65. metadata +46 -5
@@ -9,7 +9,7 @@ module Kontena
9
9
 
10
10
  if direction == 'Request'
11
11
  uri = URI.parse("#{params[:scheme]}://#{params[:host]}:#{params[:port]}")
12
- uri.path = params[:path]
12
+ uri.path = params[:path].nil? ? '/' : params[:path].split('?', 2).first
13
13
  uri.query = URI.encode_www_form(params[:query]) if params[:query] && !params[:query].empty?
14
14
  str = "#{params[:method].to_s.upcase} #{uri}"
15
15
  str << " (ssl_verify: #{params[:ssl_verify_peer]}) " if params[:scheme] == 'https'
data/lib/kontena_cli.rb CHANGED
@@ -4,12 +4,19 @@ module Kontena
4
4
  # @example
5
5
  # Kontena.run("grid list --help")
6
6
  #
7
- # @param [String] command_line
7
+ # @param [String,Array<String>] command_line
8
8
  # @return [Fixnum] exit_code
9
- def self.run(cmdline = "", returning: :status)
10
- ENV["DEBUG"] && STDERR.puts("Running Kontena.run(#{cmdline.inspect}, returning: #{returning}")
11
- result = Kontena::MainCommand.new(File.basename(__FILE__)).run(cmdline.shellsplit)
12
- ENV["DEBUG"] && STDERR.puts("Command completed, result: #{result.inspect} status: 0")
9
+ def self.run(*cmdline, returning: :status)
10
+ if cmdline.first.kind_of?(Array)
11
+ command = cmdline.first
12
+ elsif cmdline.size == 1 && cmdline.first.include?(' ')
13
+ command = cmdline.first.shellsplit
14
+ else
15
+ command = cmdline
16
+ end
17
+ ENV["DEBUG"] && puts("Running Kontena.run(#{command.inspect}, returning: #{returning}")
18
+ result = Kontena::MainCommand.new(File.basename(__FILE__)).run(command)
19
+ ENV["DEBUG"] && puts("Command completed, result: #{result.inspect} status: 0")
13
20
  return 0 if returning == :status
14
21
  return result if returning == :result
15
22
  rescue SystemExit
@@ -0,0 +1,12 @@
1
+ *.gem
2
+ .bundle
3
+ .kitchen/
4
+ .kitchen.local.yml
5
+ vendor/bundle
6
+ pkg/*
7
+ .vagrant
8
+ bin/*
9
+ files/**/cache/
10
+ vendor/cookbooks
11
+ local/
12
+ .DS_Store
@@ -0,0 +1,44 @@
1
+ driver:
2
+ name: vagrant
3
+ forward_agent: yes
4
+ customize:
5
+ cpus: 2
6
+ memory: 2048
7
+ synced_folders:
8
+ - ['.', '/home/vagrant/kontena']
9
+
10
+ provisioner:
11
+ name: chef_zero
12
+ require_chef_omnibus: 12.4.1
13
+
14
+ platforms:
15
+ - name: centos-7.1
16
+ run_list: yum-epel::default
17
+ - name: centos-6.6
18
+ run_list: yum-epel::default
19
+ - name: centos-5.11
20
+ run_list: yum-epel::default
21
+ - name: debian-7.8
22
+ run_list: apt::default
23
+ - name: debian-6.0.10
24
+ run_list: apt::default
25
+ - name: freebsd-10.1
26
+ run_list: freebsd::portsnap
27
+ - name: freebsd-9.3
28
+ run_list:
29
+ - freebsd::portsnap
30
+ - freebsd::pkgng
31
+ - name: ubuntu-14.04
32
+ run_list: apt::default
33
+ - name: ubuntu-12.04
34
+ run_list: apt::default
35
+
36
+ suites:
37
+ - name: default
38
+ run_list: omnibus::default
39
+ attributes:
40
+ omnibus:
41
+ build_user: vagrant
42
+ build_user_group: vagrant
43
+ build_user_password: vagrant
44
+ install_dir: /opt/kontena
data/omnibus/Berksfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://supermarket.chef.io'
2
+
3
+ cookbook 'omnibus'
4
+
5
+ # Uncomment to use the latest version of the Omnibus cookbook from GitHub
6
+ # cookbook 'omnibus', github: 'opscode-cookbooks/omnibus'
7
+
8
+ group :integration do
9
+ cookbook 'apt', '~> 2.8'
10
+ cookbook 'freebsd', '~> 0.3'
11
+ cookbook 'yum-epel', '~> 0.6'
12
+ end
data/omnibus/Gemfile ADDED
@@ -0,0 +1,22 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Install omnibus
4
+ gem 'omnibus', '~> 5.5'
5
+
6
+ # Use Chef's software definitions. It is recommended that you write your own
7
+ # software definitions, but you can clone/fork Chef's to get you started.
8
+ # gem 'omnibus-software', github: 'opscode/omnibus-software'
9
+
10
+ # This development group is installed by default when you run `bundle install`,
11
+ # but if you are using Omnibus in a CI-based infrastructure, you do not need
12
+ # the Test Kitchen-based build lab. You can skip these unnecessary dependencies
13
+ # by running `bundle install --without development` to speed up build times.
14
+ group :development do
15
+ # Use Berkshelf for resolving cookbook dependencies
16
+ gem 'berkshelf', '~> 3.3'
17
+
18
+ # Use Test Kitchen with Vagrant for converging the build environment
19
+ gem 'test-kitchen', '~> 1.4'
20
+ gem 'kitchen-vagrant', '~> 0.18'
21
+ gem 'omnibus-software', github: 'chef/omnibus-software'
22
+ end
@@ -0,0 +1,183 @@
1
+ GIT
2
+ remote: git://github.com/chef/omnibus-software.git
3
+ revision: fae57713431ef3a325a0662272be85cfc1d157a4
4
+ specs:
5
+ omnibus-software (4.0.0)
6
+ chef-sugar (>= 3.4.0)
7
+ omnibus (>= 5.5.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.3.8)
13
+ artifactory (2.3.3)
14
+ aws-sdk (2.5.8)
15
+ aws-sdk-resources (= 2.5.8)
16
+ aws-sdk-core (2.5.8)
17
+ jmespath (~> 1.0)
18
+ aws-sdk-resources (2.5.8)
19
+ aws-sdk-core (= 2.5.8)
20
+ berkshelf (3.3.0)
21
+ addressable (~> 2.3.4)
22
+ berkshelf-api-client (~> 1.2)
23
+ buff-config (~> 1.0)
24
+ buff-extensions (~> 1.0)
25
+ buff-shell_out (~> 0.1)
26
+ celluloid (~> 0.16.0)
27
+ celluloid-io (~> 0.16.1)
28
+ cleanroom (~> 1.0)
29
+ faraday (~> 0.9.0)
30
+ httpclient (~> 2.6.0)
31
+ minitar (~> 0.5.4)
32
+ octokit (~> 3.0)
33
+ retryable (~> 2.0)
34
+ ridley (~> 4.0)
35
+ solve (~> 1.1)
36
+ thor (~> 0.19)
37
+ berkshelf-api-client (1.3.1)
38
+ faraday (~> 0.9.1)
39
+ httpclient (~> 2.6.0)
40
+ buff-config (1.0.1)
41
+ buff-extensions (~> 1.0)
42
+ varia_model (~> 0.4)
43
+ buff-extensions (1.0.0)
44
+ buff-ignore (1.2.0)
45
+ buff-ruby_engine (0.1.0)
46
+ buff-shell_out (0.2.0)
47
+ buff-ruby_engine (~> 0.1.0)
48
+ celluloid (0.16.0)
49
+ timers (~> 4.0.0)
50
+ celluloid-io (0.16.2)
51
+ celluloid (>= 0.16.0)
52
+ nio4r (>= 1.1.0)
53
+ chef-config (12.13.37)
54
+ fuzzyurl
55
+ mixlib-config (~> 2.0)
56
+ mixlib-shellout (~> 2.0)
57
+ chef-sugar (3.4.0)
58
+ cleanroom (1.0.0)
59
+ dep-selector-libgecode (1.3.1)
60
+ dep_selector (1.0.4)
61
+ dep-selector-libgecode (~> 1.0)
62
+ ffi (~> 1.9)
63
+ erubis (2.7.0)
64
+ faraday (0.9.2)
65
+ multipart-post (>= 1.2, < 3)
66
+ ffi (1.9.14)
67
+ ffi-yajl (2.3.0)
68
+ libyajl2 (~> 1.2)
69
+ fuzzyurl (0.9.0)
70
+ hashie (3.4.4)
71
+ hitimes (1.2.4)
72
+ httpclient (2.6.0.1)
73
+ ipaddress (0.8.3)
74
+ jmespath (1.3.1)
75
+ json (2.0.2)
76
+ kitchen-vagrant (0.20.0)
77
+ test-kitchen (~> 1.4)
78
+ libyajl2 (1.2.0)
79
+ license_scout (0.1.2)
80
+ ffi-yajl (~> 2.2)
81
+ mixlib-shellout (~> 2.2)
82
+ minitar (0.5.4)
83
+ mixlib-authentication (1.4.1)
84
+ mixlib-log
85
+ mixlib-cli (1.7.0)
86
+ mixlib-config (2.2.4)
87
+ mixlib-install (1.1.0)
88
+ artifactory
89
+ mixlib-shellout
90
+ mixlib-versioning
91
+ mixlib-log (1.7.1)
92
+ mixlib-shellout (2.2.7)
93
+ mixlib-versioning (1.1.0)
94
+ multipart-post (2.0.0)
95
+ net-scp (1.2.1)
96
+ net-ssh (>= 2.6.5)
97
+ net-ssh (3.2.0)
98
+ net-ssh-gateway (1.2.0)
99
+ net-ssh (>= 2.6.5)
100
+ nio4r (1.2.1)
101
+ octokit (3.8.0)
102
+ sawyer (~> 0.6.0, >= 0.5.3)
103
+ ohai (8.19.2)
104
+ chef-config (>= 12.5.0.alpha.1, < 13)
105
+ ffi (~> 1.9)
106
+ ffi-yajl (~> 2.2)
107
+ ipaddress
108
+ mixlib-cli
109
+ mixlib-config (~> 2.0)
110
+ mixlib-log (>= 1.7.1, < 2.0)
111
+ mixlib-shellout (~> 2.0)
112
+ plist (~> 3.1)
113
+ systemu (~> 2.6.4)
114
+ wmi-lite (~> 1.0)
115
+ omnibus (5.5.0)
116
+ aws-sdk (~> 2)
117
+ chef-sugar (~> 3.3)
118
+ cleanroom (~> 1.0)
119
+ ffi-yajl (~> 2.2)
120
+ license_scout
121
+ mixlib-shellout (~> 2.0)
122
+ mixlib-versioning
123
+ ohai (~> 8.0)
124
+ ruby-progressbar (~> 1.7)
125
+ thor (~> 0.18)
126
+ plist (3.2.0)
127
+ retryable (2.0.4)
128
+ ridley (4.4.2)
129
+ addressable
130
+ buff-config (~> 1.0)
131
+ buff-extensions (~> 1.0)
132
+ buff-ignore (~> 1.1)
133
+ buff-shell_out (~> 0.1)
134
+ celluloid (~> 0.16.0)
135
+ celluloid-io (~> 0.16.1)
136
+ chef-config
137
+ erubis
138
+ faraday (~> 0.9.0)
139
+ hashie (>= 2.0.2, < 4.0.0)
140
+ httpclient (~> 2.6)
141
+ json (>= 1.7.7)
142
+ mixlib-authentication (>= 1.3.0)
143
+ retryable (~> 2.0)
144
+ semverse (~> 1.1)
145
+ varia_model (~> 0.4.0)
146
+ ruby-progressbar (1.8.1)
147
+ safe_yaml (1.0.4)
148
+ sawyer (0.6.0)
149
+ addressable (~> 2.3.5)
150
+ faraday (~> 0.8, < 0.10)
151
+ semverse (1.2.1)
152
+ solve (1.2.1)
153
+ dep_selector (~> 1.0)
154
+ semverse (~> 1.1)
155
+ systemu (2.6.5)
156
+ test-kitchen (1.12.0)
157
+ mixlib-install (~> 1.0, >= 1.0.4)
158
+ mixlib-shellout (>= 1.2, < 3.0)
159
+ net-scp (~> 1.1)
160
+ net-ssh (>= 2.9, < 4.0)
161
+ net-ssh-gateway (~> 1.2.0)
162
+ safe_yaml (~> 1.0)
163
+ thor (~> 0.18)
164
+ thor (0.19.1)
165
+ timers (4.0.4)
166
+ hitimes
167
+ varia_model (0.4.1)
168
+ buff-extensions (~> 1.0)
169
+ hashie (>= 2.0.2, < 4.0.0)
170
+ wmi-lite (1.0.0)
171
+
172
+ PLATFORMS
173
+ ruby
174
+
175
+ DEPENDENCIES
176
+ berkshelf (~> 3.3)
177
+ kitchen-vagrant (~> 0.18)
178
+ omnibus (~> 5.5)
179
+ omnibus-software!
180
+ test-kitchen (~> 1.4)
181
+
182
+ BUNDLED WITH
183
+ 1.12.5
data/omnibus/README.md ADDED
@@ -0,0 +1,120 @@
1
+ kontena Omnibus project
2
+ =======================
3
+ This project creates full-stack platform-specific packages for
4
+ `kontena`!
5
+
6
+ Installation
7
+ ------------
8
+ You must have a sane Ruby 2.0.0+ environment with Bundler installed. Ensure all
9
+ the required gems are installed:
10
+
11
+ ```shell
12
+ $ bundle install --binstubs
13
+ ```
14
+
15
+ Usage
16
+ -----
17
+ ### Build
18
+
19
+ You create a platform-specific package using the `build project` command:
20
+
21
+ ```shell
22
+ $ bin/omnibus build kontena
23
+ ```
24
+
25
+ The platform/architecture type of the package created will match the platform
26
+ where the `build project` command is invoked. For example, running this command
27
+ on a MacBook Pro will generate a Mac OS X package. After the build completes
28
+ packages will be available in the `pkg/` folder.
29
+
30
+ ### Clean
31
+
32
+ You can clean up all temporary files generated during the build process with
33
+ the `clean` command:
34
+
35
+ ```shell
36
+ $ bin/omnibus clean kontena
37
+ ```
38
+
39
+ Adding the `--purge` purge option removes __ALL__ files generated during the
40
+ build including the project install directory (`/opt/kontena`) and
41
+ the package cache directory (`/var/cache/omnibus/pkg`):
42
+
43
+ ```shell
44
+ $ bin/omnibus clean kontena --purge
45
+ ```
46
+
47
+ ### Publish
48
+
49
+ Omnibus has a built-in mechanism for releasing to a variety of "backends", such
50
+ as Amazon S3. You must set the proper credentials in your `omnibus.rb` config
51
+ file or specify them via the command line.
52
+
53
+ ```shell
54
+ $ bin/omnibus publish path/to/*.deb --backend s3
55
+ ```
56
+
57
+ ### Help
58
+
59
+ Full help for the Omnibus command line interface can be accessed with the
60
+ `help` command:
61
+
62
+ ```shell
63
+ $ bin/omnibus help
64
+ ```
65
+
66
+ Version Manifest
67
+ ----------------
68
+
69
+ Git-based software definitions may specify branches as their
70
+ default_version. In this case, the exact git revision to use will be
71
+ determined at build-time unless a project override (see below) or
72
+ external version manifest is used. To generate a version manifest use
73
+ the `omnibus manifest` command:
74
+
75
+ ```
76
+ omnibus manifest PROJECT -l warn
77
+ ```
78
+
79
+ This will output a JSON-formatted manifest containing the resolved
80
+ version of every software definition.
81
+
82
+
83
+ Kitchen-based Build Environment
84
+ -------------------------------
85
+ Every Omnibus project ships will a project-specific
86
+ [Berksfile](http://berkshelf.com/) that will allow you to build your omnibus projects on all of the projects listed
87
+ in the `.kitchen.yml`. You can add/remove additional platforms as needed by
88
+ changing the list found in the `.kitchen.yml` `platforms` YAML stanza.
89
+
90
+ This build environment is designed to get you up-and-running quickly. However,
91
+ there is nothing that restricts you to building on other platforms. Simply use
92
+ the [omnibus cookbook](https://github.com/opscode-cookbooks/omnibus) to setup
93
+ your desired platform and execute the build steps listed above.
94
+
95
+ The default build environment requires Test Kitchen and VirtualBox for local
96
+ development. Test Kitchen also exposes the ability to provision instances using
97
+ various cloud providers like AWS, DigitalOcean, or OpenStack. For more
98
+ information, please see the [Test Kitchen documentation](http://kitchen.ci).
99
+
100
+ Once you have tweaked your `.kitchen.yml` (or `.kitchen.local.yml`) to your
101
+ liking, you can bring up an individual build environment using the `kitchen`
102
+ command.
103
+
104
+ ```shell
105
+ $ bin/kitchen converge ubuntu-1204
106
+ ```
107
+
108
+ Then login to the instance and build the project as described in the Usage
109
+ section:
110
+
111
+ ```shell
112
+ $ bundle exec kitchen login ubuntu-1204
113
+ [vagrant@ubuntu...] $ cd kontena
114
+ [vagrant@ubuntu...] $ bundle install
115
+ [vagrant@ubuntu...] $ ...
116
+ [vagrant@ubuntu...] $ bin/omnibus build kontena
117
+ ```
118
+
119
+ For a complete list of all commands and platforms, run `kitchen list` or
120
+ `kitchen help`.
@@ -0,0 +1,33 @@
1
+ #
2
+ # Copyright 2016 Kontena, Inc.
3
+ #
4
+ # All Rights Reserved.
5
+ #
6
+
7
+ name "kontena"
8
+ friendly_name "Kontena CLI"
9
+ maintainer "Kontena, Inc."
10
+ homepage "https://kontena.io"
11
+
12
+ # Defaults to C:/kontena on Windows
13
+ # and /opt/kontena on all other platforms
14
+ install_dir "#{default_root}/#{name}"
15
+
16
+ build_version File.read('../VERSION').strip
17
+ build_iteration 1
18
+
19
+ # Creates required build directories
20
+ dependency "preparation"
21
+
22
+ # kontena dependencies/components
23
+ dependency "kontena"
24
+
25
+ # Version manifest file
26
+ dependency "version-manifest"
27
+
28
+ exclude "**/.git"
29
+ exclude "**/bundler/git"
30
+
31
+ package :pkg do
32
+ identifier "io.kontena.pkg.cli"
33
+ end