kontena-plugin-app-command 0.1.0.rc1

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.
Files changed (44) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.rspec +1 -0
  4. data/.travis.yml +21 -0
  5. data/Dockerfile +19 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +191 -0
  8. data/README.md +299 -0
  9. data/Rakefile +6 -0
  10. data/kontena-plugin-app-command.gemspec +28 -0
  11. data/lib/kontena/cli/apps/build_command.rb +28 -0
  12. data/lib/kontena/cli/apps/common.rb +172 -0
  13. data/lib/kontena/cli/apps/config_command.rb +25 -0
  14. data/lib/kontena/cli/apps/deploy_command.rb +137 -0
  15. data/lib/kontena/cli/apps/docker_compose_generator.rb +61 -0
  16. data/lib/kontena/cli/apps/docker_helper.rb +80 -0
  17. data/lib/kontena/cli/apps/dockerfile_generator.rb +16 -0
  18. data/lib/kontena/cli/apps/init_command.rb +89 -0
  19. data/lib/kontena/cli/apps/kontena_yml_generator.rb +105 -0
  20. data/lib/kontena/cli/apps/list_command.rb +59 -0
  21. data/lib/kontena/cli/apps/logs_command.rb +37 -0
  22. data/lib/kontena/cli/apps/monitor_command.rb +93 -0
  23. data/lib/kontena/cli/apps/remove_command.rb +74 -0
  24. data/lib/kontena/cli/apps/restart_command.rb +39 -0
  25. data/lib/kontena/cli/apps/scale_command.rb +33 -0
  26. data/lib/kontena/cli/apps/service_generator.rb +114 -0
  27. data/lib/kontena/cli/apps/service_generator_v2.rb +27 -0
  28. data/lib/kontena/cli/apps/show_command.rb +23 -0
  29. data/lib/kontena/cli/apps/start_command.rb +40 -0
  30. data/lib/kontena/cli/apps/stop_command.rb +40 -0
  31. data/lib/kontena/cli/apps/yaml/custom_validators/affinities_validator.rb +19 -0
  32. data/lib/kontena/cli/apps/yaml/custom_validators/build_validator.rb +22 -0
  33. data/lib/kontena/cli/apps/yaml/custom_validators/extends_validator.rb +20 -0
  34. data/lib/kontena/cli/apps/yaml/custom_validators/hooks_validator.rb +54 -0
  35. data/lib/kontena/cli/apps/yaml/custom_validators/secrets_validator.rb +22 -0
  36. data/lib/kontena/cli/apps/yaml/reader.rb +213 -0
  37. data/lib/kontena/cli/apps/yaml/service_extender.rb +77 -0
  38. data/lib/kontena/cli/apps/yaml/validations.rb +71 -0
  39. data/lib/kontena/cli/apps/yaml/validator.rb +38 -0
  40. data/lib/kontena/cli/apps/yaml/validator_v2.rb +53 -0
  41. data/lib/kontena/plugin/app-command/app_command.rb +21 -0
  42. data/lib/kontena/plugin/app-command/version.rb +7 -0
  43. data/lib/kontena_cli_plugin.rb +4 -0
  44. metadata +143 -0
@@ -0,0 +1,38 @@
1
+ require 'hash_validator'
2
+ module Kontena::Cli::Apps
3
+ module YAML
4
+ class Validator
5
+ require_relative 'validations'
6
+ include Validations
7
+
8
+ def initialize(need_image=false)
9
+ @schema = common_validations
10
+ @schema['build'] = optional('string')
11
+ @schema['dockerfile'] = optional('string')
12
+ @schema['net'] = optional(%w(host bridge))
13
+ @schema['log_driver'] = optional('string')
14
+ @schema['log_opts'] = optional({})
15
+ Validations::CustomValidators.load
16
+ end
17
+
18
+ ##
19
+ # @param [Hash] yaml
20
+ # @return [Array] validation_errors
21
+ def validate(yaml)
22
+ result = {
23
+ errors: [],
24
+ notifications: []
25
+ }
26
+ yaml.each do |service, options|
27
+ unless options.is_a?(Hash)
28
+ result[:errors] << { service => { 'options' => 'must be a mapping not a string'} }
29
+ next
30
+ end
31
+ option_errors = validate_options(options)
32
+ result[:errors] << { service => option_errors.errors } unless option_errors.valid?
33
+ end
34
+ result
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,53 @@
1
+ require 'hash_validator'
2
+ require_relative 'validator'
3
+
4
+ module Kontena::Cli::Apps
5
+ module YAML
6
+ class ValidatorV2
7
+ require_relative 'validations'
8
+ include Validations
9
+
10
+ def initialize
11
+ @schema = common_validations
12
+ @schema['build'] = optional('valid_build')
13
+ @schema['depends_on'] = optional('array')
14
+ @schema['network_mode'] = optional(%w(host bridge))
15
+ @schema['logging'] = optional({
16
+ 'driver' => optional('string'),
17
+ 'options' => optional(-> (value) { value.is_a?(Hash) })
18
+ })
19
+ Validations::CustomValidators.load
20
+ end
21
+
22
+ ##
23
+ # @param [Hash] yaml
24
+ # @param [TrueClass|FalseClass] strict
25
+ # @return [Array] validation_errors
26
+ def validate(yaml)
27
+ result = {
28
+ errors: [],
29
+ notifications: []
30
+ }
31
+ if yaml.key?('services')
32
+ yaml['services'].each do |service, options|
33
+ unless options.is_a?(Hash)
34
+ result[:errors] << { service => { 'options' => 'must be a mapping not a string'} }
35
+ next
36
+ end
37
+ option_errors = validate_options(options)
38
+ result[:errors] << { service => option_errors.errors } unless option_errors.valid?
39
+ end
40
+ else
41
+ result[:errors] << { 'file' => 'services missing' }
42
+ end
43
+ if yaml.key?('volumes')
44
+ result[:notifications] << { 'volumes' => 'Kontena does not support volumes yet. To persist data just define service as stateful (stateful: true)' }
45
+ end
46
+ if yaml.key?('networks')
47
+ result[:notifications] << { 'networks' => 'Kontena does not support multiple networks yet. You can reference services with Kontena\'s internal DNS (service_name.kontena.local)' }
48
+ end
49
+ result
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,21 @@
1
+ module Kontena
2
+ module Plugin
3
+ module AppCommand
4
+ class AppCommand < Kontena::Command
5
+ subcommand "init", "Init Kontena application", load_subcommand('kontena/cli/apps/init_command')
6
+ subcommand "build", "Build Kontena services", load_subcommand('kontena/cli/apps/build_command')
7
+ subcommand "config", "View service configurations", load_subcommand('kontena/cli/apps/config_command')
8
+ subcommand "deploy", "Deploy Kontena services", load_subcommand('kontena/cli/apps/deploy_command')
9
+ subcommand "scale", "Scale services", load_subcommand('kontena/cli/apps/scale_command')
10
+ subcommand "start", "Start services", load_subcommand('kontena/cli/apps/start_command')
11
+ subcommand "stop", "Stop services", load_subcommand('kontena/cli/apps/stop_command')
12
+ subcommand "restart", "Restart services", load_subcommand('kontena/cli/apps/restart_command')
13
+ subcommand "show", "Show service details", load_subcommand('kontena/cli/apps/show_command')
14
+ subcommand ["ps", "list", "ls"], "List services", load_subcommand('kontena/cli/apps/list_command')
15
+ subcommand ["logs"], "Show service logs", load_subcommand('kontena/cli/apps/logs_command')
16
+ subcommand "monitor", "Monitor services", load_subcommand('kontena/cli/apps/monitor_command')
17
+ subcommand ["remove","rm"], "Remove services", load_subcommand('kontena/cli/apps/remove_command')
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,7 @@
1
+ module Kontena
2
+ module Plugin
3
+ module AppCommand
4
+ VERSION = '0.1.0.rc1'
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ require 'kontena_cli'
2
+ require 'kontena/plugin/app-command/app_command'
3
+
4
+ Kontena::MainCommand.register("app", "App specific commands", Kontena::Plugin::AppCommand::AppCommand)
metadata ADDED
@@ -0,0 +1,143 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: kontena-plugin-app-command
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.rc1
5
+ platform: ruby
6
+ authors:
7
+ - Kontena, Inc
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-08-14 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: kontena-cli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.4.0.pre1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.4.0.pre1
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.14'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.14'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description: Restores the "kontena app" subcommand back to Kontena CLI v1.4+
70
+ email:
71
+ - info@kontena.io
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".rspec"
78
+ - ".travis.yml"
79
+ - Dockerfile
80
+ - Gemfile
81
+ - LICENSE.txt
82
+ - README.md
83
+ - Rakefile
84
+ - kontena-plugin-app-command.gemspec
85
+ - lib/kontena/cli/apps/build_command.rb
86
+ - lib/kontena/cli/apps/common.rb
87
+ - lib/kontena/cli/apps/config_command.rb
88
+ - lib/kontena/cli/apps/deploy_command.rb
89
+ - lib/kontena/cli/apps/docker_compose_generator.rb
90
+ - lib/kontena/cli/apps/docker_helper.rb
91
+ - lib/kontena/cli/apps/dockerfile_generator.rb
92
+ - lib/kontena/cli/apps/init_command.rb
93
+ - lib/kontena/cli/apps/kontena_yml_generator.rb
94
+ - lib/kontena/cli/apps/list_command.rb
95
+ - lib/kontena/cli/apps/logs_command.rb
96
+ - lib/kontena/cli/apps/monitor_command.rb
97
+ - lib/kontena/cli/apps/remove_command.rb
98
+ - lib/kontena/cli/apps/restart_command.rb
99
+ - lib/kontena/cli/apps/scale_command.rb
100
+ - lib/kontena/cli/apps/service_generator.rb
101
+ - lib/kontena/cli/apps/service_generator_v2.rb
102
+ - lib/kontena/cli/apps/show_command.rb
103
+ - lib/kontena/cli/apps/start_command.rb
104
+ - lib/kontena/cli/apps/stop_command.rb
105
+ - lib/kontena/cli/apps/yaml/custom_validators/affinities_validator.rb
106
+ - lib/kontena/cli/apps/yaml/custom_validators/build_validator.rb
107
+ - lib/kontena/cli/apps/yaml/custom_validators/extends_validator.rb
108
+ - lib/kontena/cli/apps/yaml/custom_validators/hooks_validator.rb
109
+ - lib/kontena/cli/apps/yaml/custom_validators/secrets_validator.rb
110
+ - lib/kontena/cli/apps/yaml/reader.rb
111
+ - lib/kontena/cli/apps/yaml/service_extender.rb
112
+ - lib/kontena/cli/apps/yaml/validations.rb
113
+ - lib/kontena/cli/apps/yaml/validator.rb
114
+ - lib/kontena/cli/apps/yaml/validator_v2.rb
115
+ - lib/kontena/plugin/app-command/app_command.rb
116
+ - lib/kontena/plugin/app-command/version.rb
117
+ - lib/kontena_cli_plugin.rb
118
+ homepage: https://github.com/kontena/kontena-plugin-app-command
119
+ licenses:
120
+ - Apache-2.0
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">"
134
+ - !ruby/object:Gem::Version
135
+ version: 1.3.1
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.6.11
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Kontena 'app' subcommand for Kontena CLI 1.4+
142
+ test_files: []
143
+ has_rdoc: