kontena-cli 0.12.3 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/bin/kontena +6 -4
  4. data/lib/kontena/cli/apps/common.rb +21 -7
  5. data/lib/kontena/cli/apps/deploy_command.rb +11 -4
  6. data/lib/kontena/cli/apps/docker_helper.rb +12 -0
  7. data/lib/kontena/cli/apps/logs_command.rb +0 -2
  8. data/lib/kontena/cli/apps/remove_command.rb +23 -14
  9. data/lib/kontena/cli/bytes_helper.rb +40 -0
  10. data/lib/kontena/cli/container_command.rb +0 -1
  11. data/lib/kontena/cli/grid_command.rb +4 -6
  12. data/lib/kontena/cli/grids/logs_command.rb +0 -2
  13. data/lib/kontena/cli/grids/trusted_subnet_command.rb +12 -0
  14. data/lib/kontena/cli/grids/trusted_subnets/add_command.rb +16 -0
  15. data/lib/kontena/cli/grids/trusted_subnets/list_command.rb +17 -0
  16. data/lib/kontena/cli/grids/trusted_subnets/remove_command.rb +20 -0
  17. data/lib/kontena/cli/grids/user_command.rb +12 -0
  18. data/lib/kontena/cli/grids/{add_user_command.rb → users/add_command.rb} +4 -4
  19. data/lib/kontena/cli/grids/{list_users_command.rb → users/list_command.rb} +4 -4
  20. data/lib/kontena/cli/grids/{remove_user_command.rb → users/remove_command.rb} +4 -4
  21. data/lib/kontena/cli/login_command.rb +4 -3
  22. data/lib/kontena/cli/master/aws/create_command.rb +3 -1
  23. data/lib/kontena/cli/master/current_command.rb +17 -0
  24. data/lib/kontena/cli/master/digital_ocean/create_command.rb +5 -3
  25. data/lib/kontena/cli/master/users/role_command.rb +10 -0
  26. data/lib/kontena/cli/master/users/{add_role_command.rb → roles/add_command.rb} +4 -4
  27. data/lib/kontena/cli/master/users/{remove_role_command.rb → roles/remove_command.rb} +4 -4
  28. data/lib/kontena/cli/master/users_command.rb +2 -4
  29. data/lib/kontena/cli/master_command.rb +2 -0
  30. data/lib/kontena/cli/node_command.rb +2 -4
  31. data/lib/kontena/cli/nodes/label_command.rb +14 -0
  32. data/lib/kontena/cli/nodes/{add_label_command.rb → labels/add_command.rb} +2 -2
  33. data/lib/kontena/cli/nodes/{remove_label_command.rb → labels/remove_command.rb} +2 -2
  34. data/lib/kontena/cli/nodes/list_command.rb +2 -1
  35. data/lib/kontena/cli/nodes/show_command.rb +19 -2
  36. data/lib/kontena/cli/registry_command.rb +0 -1
  37. data/lib/kontena/cli/service_command.rb +4 -11
  38. data/lib/kontena/cli/services/create_command.rb +10 -2
  39. data/lib/kontena/cli/services/env_command.rb +12 -0
  40. data/lib/kontena/cli/services/{add_env_command.rb → envs/add_command.rb} +4 -4
  41. data/lib/kontena/cli/services/{envs_command.rb → envs/list_command.rb} +5 -5
  42. data/lib/kontena/cli/services/{remove_env_command.rb → envs/remove_command.rb} +4 -4
  43. data/lib/kontena/cli/services/list_command.rb +3 -2
  44. data/lib/kontena/cli/services/logs_command.rb +0 -2
  45. data/lib/kontena/cli/services/secret_command.rb +10 -0
  46. data/lib/kontena/cli/services/{add_secret_command.rb → secrets/link_command.rb} +4 -4
  47. data/lib/kontena/cli/services/{remove_secret_command.rb → secrets/unlink_command.rb} +4 -4
  48. data/lib/kontena/cli/services/services_helper.rb +35 -8
  49. data/lib/kontena/cli/services/stats_command.rb +6 -1
  50. data/lib/kontena/cli/services/update_command.rb +4 -0
  51. data/lib/kontena/cli/user/forgot_password_command.rb +16 -0
  52. data/lib/kontena/cli/user/reset_password_command.rb +23 -0
  53. data/lib/kontena/cli/user/verify_command.rb +22 -0
  54. data/lib/kontena/cli/user_command.rb +13 -0
  55. data/lib/kontena/cli/vault/list_command.rb +1 -1
  56. data/lib/kontena/cli/vpn_command.rb +0 -1
  57. data/lib/kontena/cli/whoami_command.rb +17 -3
  58. data/lib/kontena/machine/aws/cloudinit_master.yml +13 -4
  59. data/lib/kontena/machine/aws/common.rb +8 -13
  60. data/lib/kontena/machine/aws/master_provisioner.rb +6 -5
  61. data/lib/kontena/machine/azure/cloudinit_master.yml +0 -2
  62. data/lib/kontena/machine/digital_ocean.rb +1 -0
  63. data/lib/kontena/machine/digital_ocean/cloudinit.yml +0 -22
  64. data/lib/kontena/machine/digital_ocean/cloudinit_master.yml +14 -4
  65. data/lib/kontena/machine/digital_ocean/master_provisioner.rb +12 -9
  66. data/lib/kontena/machine/vagrant/cloudinit.yml +2 -0
  67. data/lib/kontena/scripts/completer +4 -4
  68. data/spec/kontena/cli/app/common_spec.rb +55 -7
  69. data/spec/kontena/cli/app/docker_helper_spec.rb +74 -0
  70. data/spec/kontena/cli/grids/trusted_subnets/add_command_spec.rb +38 -0
  71. data/spec/kontena/cli/grids/trusted_subnets/list_command_spec.rb +31 -0
  72. data/spec/kontena/cli/grids/trusted_subnets/remove_command_spec.rb +38 -0
  73. data/spec/kontena/cli/master/current_command_spec.rb +57 -0
  74. data/spec/kontena/cli/master/users/{add_role_command_spec.rb → roles/add_command_spec.rb} +3 -3
  75. data/spec/kontena/cli/master/users/{remove_role_command_spec.rb → roles/remove_command_spec.rb} +3 -3
  76. data/spec/kontena/cli/services/{add_secret_command_spec.rb → secrets/link_command_spec.rb} +4 -3
  77. data/spec/kontena/cli/services/{remove_secret_command_spec.rb → secrets/unlink_command_spec.rb} +4 -3
  78. data/spec/kontena/cli/services/services_helper_spec.rb +44 -0
  79. metadata +45 -26
  80. data/lib/kontena/cli/forgot_password_command.rb +0 -13
  81. data/lib/kontena/cli/reset_password_command.rb +0 -19
  82. data/lib/kontena/cli/users_command.rb +0 -15
  83. data/lib/kontena/cli/verify_account_command.rb +0 -13
@@ -1,10 +1,10 @@
1
- require_relative 'common'
1
+ require_relative '../common'
2
2
 
3
- module Kontena::Cli::Grids
4
- class RemoveUserCommand < Clamp::Command
3
+ module Kontena::Cli::Grids::Users
4
+ class RemoveCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
6
  include Kontena::Cli::GridOptions
7
- include Common
7
+ include Kontena::Cli::Grids::Common
8
8
 
9
9
  parameter "EMAIL", "Email address"
10
10
 
@@ -24,7 +24,7 @@ class Kontena::Cli::LoginCommand < Clamp::Command
24
24
  response = do_login(email, password)
25
25
 
26
26
  if response
27
- update_master_info(name, url, response['access_token'])
27
+ update_master_info(name, url, response['access_token'], email)
28
28
  display_logo
29
29
  puts ''
30
30
  puts "Logged in as #{response['user']['name'].green}"
@@ -97,12 +97,13 @@ class Kontena::Cli::LoginCommand < Clamp::Command
97
97
  # @param [String] url
98
98
  # @param [String] token
99
99
  #
100
- def update_master_info(name, url, token)
100
+ def update_master_info(name, url, token, email)
101
101
  name = name || 'default'
102
102
  master = {
103
103
  'name' => name,
104
104
  'url' => url,
105
- 'token' => token
105
+ 'token' => token,
106
+ 'email' => email
106
107
  }
107
108
 
108
109
  self.add_master(name, master)
@@ -16,6 +16,7 @@ module Kontena::Cli::Master::Aws
16
16
  option "--storage", "STORAGE", "Storage size (GiB)", default: '30'
17
17
  option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (default: generate random secret)"
18
18
  option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (default: generate random iv)"
19
+ option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
19
20
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
20
21
  option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url (optional)"
21
22
 
@@ -34,7 +35,8 @@ module Kontena::Cli::Master::Aws
34
35
  key_pair: key_pair,
35
36
  auth_server: auth_provider_url,
36
37
  vault_secret: vault_secret || SecureRandom.hex(24),
37
- vault_iv: vault_iv || SecureRandom.hex(24)
38
+ vault_iv: vault_iv || SecureRandom.hex(24),
39
+ mongodb_uri: mongodb_uri
38
40
  )
39
41
  end
40
42
  end
@@ -0,0 +1,17 @@
1
+ module Kontena::Cli::Master
2
+ class CurrentCommand < Clamp::Command
3
+ include Kontena::Cli::Common
4
+
5
+ option ["--name"], :flag, "Show name only", default: false
6
+
7
+ def execute
8
+ master = current_master
9
+
10
+ if name?
11
+ puts master['name']
12
+ else
13
+ puts "#{master['name']} #{master['url']}"
14
+ end
15
+ end
16
+ end
17
+ end
@@ -9,8 +9,9 @@ module Kontena::Cli::Master::DigitalOcean
9
9
  option "--ssl-cert", "SSL CERT", "SSL certificate file"
10
10
  option "--size", "SIZE", "Droplet size", default: '1gb'
11
11
  option "--region", "REGION", "Region", default: 'ams2'
12
- option "--vault-secret", "VAULT_SECRET", "Secret key for Vault"
13
- option "--vault-iv", "VAULT_IV", "Initialization vector for Vault"
12
+ option "--vault-secret", "VAULT_SECRET", "Secret key for Vault (optional)"
13
+ option "--vault-iv", "VAULT_IV", "Initialization vector for Vault (optional)"
14
+ option "--mongodb-uri", "URI", "External MongoDB uri (optional)"
14
15
  option "--version", "VERSION", "Define installed Kontena version", default: 'latest'
15
16
  option "--auth-provider-url", "AUTH_PROVIDER_URL", "Define authentication provider url"
16
17
 
@@ -28,7 +29,8 @@ module Kontena::Cli::Master::DigitalOcean
28
29
  version: version,
29
30
  auth_server: auth_provider_url,
30
31
  vault_secret: vault_secret || SecureRandom.hex(24),
31
- vault_iv: vault_iv || SecureRandom.hex(24)
32
+ vault_iv: vault_iv || SecureRandom.hex(24),
33
+ mongodb_uri: mongodb_uri
32
34
  )
33
35
  end
34
36
 
@@ -0,0 +1,10 @@
1
+ module Kontena::Cli::Master::Users
2
+
3
+ require_relative 'roles/add_command'
4
+ require_relative 'roles/remove_command'
5
+
6
+ class RoleCommand < Clamp::Command
7
+ subcommand "add", "Add role to user", Roles::AddCommand
8
+ subcommand ["remove", "rm"], "Remove role from user", Roles::RemoveCommand
9
+ end
10
+ end
@@ -1,7 +1,7 @@
1
- require_relative '../../common'
1
+ require_relative '../../../common'
2
2
 
3
- module Kontena::Cli::Master::Users
4
- class AddRoleCommand < Clamp::Command
3
+ module Kontena::Cli::Master::Users::Roles
4
+ class AddCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
6
 
7
7
  parameter "ROLE", "Role name"
@@ -23,4 +23,4 @@ module Kontena::Cli::Master::Users
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -1,7 +1,7 @@
1
- require_relative '../../common'
1
+ require_relative '../../../common'
2
2
 
3
- module Kontena::Cli::Master::Users
4
- class RemoveRoleCommand < Clamp::Command
3
+ module Kontena::Cli::Master::Users::Roles
4
+ class RemoveCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
6
 
7
7
  parameter "ROLE", "Role name"
@@ -23,4 +23,4 @@ module Kontena::Cli::Master::Users
23
23
  end
24
24
  end
25
25
  end
26
- end
26
+ end
@@ -3,14 +3,12 @@ module Kontena::Cli::Master
3
3
  require_relative 'users/invite_command'
4
4
  require_relative 'users/remove_command'
5
5
  require_relative 'users/list_command'
6
- require_relative 'users/add_role_command'
7
- require_relative 'users/remove_role_command'
6
+ require_relative 'users/role_command'
8
7
 
9
8
  class UsersCommand < Clamp::Command
10
9
  subcommand "invite", "Invite user to Kontena Master", Users::InviteCommand
11
10
  subcommand ["remove", "rm"], "Remove user from Kontena Master", Users::RemoveCommand
12
11
  subcommand ["list", "ls"], "List users", Users::ListCommand
13
- subcommand "add-role", "Add role to user", Users::AddRoleCommand
14
- subcommand "remove-role", "Remove role from user", Users::RemoveRoleCommand
12
+ subcommand "role", "User role specific commands", Users::RoleCommand
15
13
  end
16
14
  end
@@ -5,6 +5,7 @@ require_relative 'master/azure_command'
5
5
  require_relative 'master/use_command'
6
6
  require_relative 'master/list_command'
7
7
  require_relative 'master/users_command'
8
+ require_relative 'master/current_command'
8
9
 
9
10
  class Kontena::Cli::MasterCommand < Clamp::Command
10
11
 
@@ -15,6 +16,7 @@ class Kontena::Cli::MasterCommand < Clamp::Command
15
16
  subcommand ["list", "ls"], "List masters where client has logged in", Kontena::Cli::Master::ListCommand
16
17
  subcommand "use", "Switch to use selected master", Kontena::Cli::Master::UseCommand
17
18
  subcommand "users", "Users specific commands", Kontena::Cli::Master::UsersCommand
19
+ subcommand "current", "Show current master details", Kontena::Cli::Master::CurrentCommand
18
20
  def execute
19
21
  end
20
22
  end
@@ -4,8 +4,7 @@ require_relative 'nodes/show_command'
4
4
  require_relative 'nodes/update_command'
5
5
  require_relative 'nodes/ssh_command'
6
6
 
7
- require_relative 'nodes/add_label_command'
8
- require_relative 'nodes/remove_label_command'
7
+ require_relative 'nodes/label_command'
9
8
 
10
9
  require_relative 'nodes/vagrant_command'
11
10
  require_relative 'nodes/digital_ocean_command'
@@ -20,8 +19,7 @@ class Kontena::Cli::NodeCommand < Clamp::Command
20
19
  subcommand "update", "Update node", Kontena::Cli::Nodes::UpdateCommand
21
20
  subcommand ["remove","rm"], "Remove node", Kontena::Cli::Nodes::RemoveCommand
22
21
 
23
- subcommand "add-label", "Add label to node", Kontena::Cli::Nodes::AddLabelCommand
24
- subcommand "remove-label", "Remove label from node", Kontena::Cli::Nodes::RemoveLabelCommand
22
+ subcommand "label", "Node label specific commands", Kontena::Cli::Nodes::LabelCommand
25
23
 
26
24
  subcommand "vagrant", "Vagrant specific commands", Kontena::Cli::Nodes::VagrantCommand
27
25
  subcommand "digitalocean", "DigitalOcean specific commands", Kontena::Cli::Nodes::DigitalOceanCommand
@@ -0,0 +1,14 @@
1
+ module Kontena::Cli::Nodes
2
+
3
+ require_relative 'labels/add_command'
4
+ require_relative 'labels/remove_command'
5
+
6
+ class LabelCommand < Clamp::Command
7
+
8
+ subcommand "add", "Add label to node", Labels::AddCommand
9
+ subcommand ["remove", "rm"], "Remove label from node", Labels::RemoveCommand
10
+
11
+ def execute
12
+ end
13
+ end
14
+ end
@@ -1,5 +1,5 @@
1
- module Kontena::Cli::Nodes
2
- class AddLabelCommand < Clamp::Command
1
+ module Kontena::Cli::Nodes::Labels
2
+ class AddCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
4
 
5
5
  parameter "NODE_ID", "Node id"
@@ -1,5 +1,5 @@
1
- module Kontena::Cli::Nodes
2
- class RemoveLabelCommand < Clamp::Command
1
+ module Kontena::Cli::Nodes::Labels
2
+ class RemoveCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
4
 
5
5
  parameter "NODE_ID", "Node id"
@@ -32,7 +32,8 @@ module Kontena::Cli::Nodes
32
32
  else
33
33
  nodes = client(token).get("grids/#{current_grid}/nodes")
34
34
  puts "%-70s %-10s %-40s" % ['Name', 'Status', 'Labels']
35
- nodes['nodes'].each do |node|
35
+ nodes = nodes['nodes'].sort_by{|n| n['node_number'] }
36
+ nodes.each do |node|
36
37
  if node['connected']
37
38
  status = 'online'
38
39
  else
@@ -2,6 +2,7 @@ module Kontena::Cli::Nodes
2
2
  class ShowCommand < Clamp::Command
3
3
  include Kontena::Cli::Common
4
4
  include Kontena::Cli::GridOptions
5
+ include Kontena::Cli::BytesHelper
5
6
 
6
7
  parameter "NODE_ID", "Node id"
7
8
 
@@ -22,12 +23,28 @@ module Kontena::Cli::Nodes
22
23
  puts " os: #{node['os']}"
23
24
  puts " driver: #{node['driver']}"
24
25
  puts " kernel: #{node['kernel_version']}"
25
- puts " cpus: #{node['cpus']}"
26
- puts " memory: #{node['mem_total'] / 1024 / 1024}M"
27
26
  puts " labels:"
28
27
  if node['labels']
29
28
  node['labels'].each{|l| puts " - #{l}"}
30
29
  end
30
+ puts " stats:"
31
+ puts " cpus: #{node['cpus']}"
32
+ loads = node.dig('resource_usage', 'load')
33
+ if loads
34
+ puts " load: #{loads['1m'].round(2)} #{loads['5m'].round(2)} #{loads['15m'].round(2)}"
35
+ end
36
+ mem = node.dig('resource_usage', 'memory')
37
+ if mem
38
+ mem_used = mem['used'] - (mem['cached'] + mem['buffers'])
39
+ puts " memory: #{to_gigabytes(mem_used, 2)} of #{to_gigabytes(mem['total'], 2)} GB"
40
+ end
41
+ if node['resource_usage']['filesystem']
42
+ puts " filesystem:"
43
+ node['resource_usage']['filesystem'].each do |filesystem|
44
+ puts " - #{filesystem['name']}: #{to_gigabytes(filesystem['used'], 2)} of #{to_gigabytes(filesystem['total'], 2)} GB"
45
+ end
46
+ end
31
47
  end
48
+
32
49
  end
33
50
  end
@@ -6,7 +6,6 @@ class Kontena::Cli::RegistryCommand < Clamp::Command
6
6
 
7
7
  subcommand "create", "Create Docker image registry service", Kontena::Cli::Registry::CreateCommand
8
8
  subcommand ["remove","rm"], "Remove Docker image registry service", Kontena::Cli::Registry::RemoveCommand
9
- subcommand "delete", "[DEPRECATED] Delete Docker image registry service", Kontena::Cli::Registry::DeleteCommand
10
9
 
11
10
  def execute
12
11
  end
@@ -14,12 +14,8 @@ require_relative 'services/logs_command'
14
14
  require_relative 'services/stats_command'
15
15
  require_relative 'services/monitor_command'
16
16
 
17
- require_relative 'services/envs_command'
18
- require_relative 'services/add_env_command'
19
- require_relative 'services/remove_env_command'
20
-
21
- require_relative 'services/add_secret_command'
22
- require_relative 'services/remove_secret_command'
17
+ require_relative 'services/env_command'
18
+ require_relative 'services/secret_command'
23
19
 
24
20
  require_relative 'services/link_command'
25
21
  require_relative 'services/unlink_command'
@@ -42,12 +38,9 @@ class Kontena::Cli::ServiceCommand < Clamp::Command
42
38
  subcommand "stats", "Show service statistics", Kontena::Cli::Services::StatsCommand
43
39
  subcommand "monitor", "Monitor", Kontena::Cli::Services::MonitorCommand
44
40
 
45
- subcommand "envs", "Show environment variables", Kontena::Cli::Services::EnvsCommand
46
- subcommand "add-env", "Add environment variable", Kontena::Cli::Services::AddEnvCommand
47
- subcommand "remove-env", "Remove environment variable", Kontena::Cli::Services::RemoveEnvCommand
41
+ subcommand "env", "Environment variable specific commands", Kontena::Cli::Services::EnvCommand
48
42
 
49
- subcommand "add-secret", "Add secret from Vault", Kontena::Cli::Services::AddSecretCommand
50
- subcommand "remove-secret", "Remove secret", Kontena::Cli::Services::RemoveSecretCommand
43
+ subcommand "secret", "Secret specific commands", Kontena::Cli::Services::SecretCommand
51
44
 
52
45
  subcommand "link", "Link service to another service", Kontena::Cli::Services::LinkCommand
53
46
  subcommand "unlink", "Unlink service from another service", Kontena::Cli::Services::UnlinkCommand
@@ -31,6 +31,7 @@ module Kontena::Cli::Services
31
31
  option "--deploy-strategy", "STRATEGY", "Deploy strategy to use (ha, daemon, random)"
32
32
  option "--deploy-wait-for-port", "PORT", "Wait for port to respond when deploying"
33
33
  option "--deploy-min-health", "FLOAT", "The minimum percentage (0.0 - 1.0) of healthy instances that do not sacrifice overall service availability while deploying"
34
+ option "--deploy-interval", "TIME", "Auto-deploy with given interval (format: <number><unit>, where unit = min, h, d)"
34
35
  option "--pid", "PID", "Pid namespace to use"
35
36
  option "--secret", "SECRET", "Import secret from Vault (format: <secret>:<name>:<env>)", multivalued: true
36
37
 
@@ -73,8 +74,15 @@ module Kontena::Cli::Services
73
74
  data[:log_opts] = parse_log_opts(log_opt_list)
74
75
  data[:strategy] = deploy_strategy if deploy_strategy
75
76
  data[:deploy_opts] = {}
76
- data[:deploy_opts][:min_health] = deploy_min_health.to_f if deploy_min_health
77
- data[:deploy_opts][:wait_for_port] = deploy_wait_for_port.to_i if deploy_wait_for_port
77
+ if deploy_min_health
78
+ data[:deploy_opts][:min_health] = deploy_min_health.to_f
79
+ end
80
+ if deploy_wait_for_port
81
+ data[:deploy_opts][:wait_for_port] = deploy_wait_for_port.to_i
82
+ end
83
+ if deploy_interval
84
+ data[:deploy_opts][:interval] = parse_relative_time(deploy_interval)
85
+ end
78
86
  data[:pid] = pid if pid
79
87
  data
80
88
  end
@@ -0,0 +1,12 @@
1
+ module Kontena::Cli::Services
2
+
3
+ require_relative 'envs/add_command'
4
+ require_relative 'envs/list_command'
5
+ require_relative 'envs/remove_command'
6
+
7
+ class EnvCommand < Clamp::Command
8
+ subcommand ["list", "ls"], "List service environment variables", Envs::ListCommand
9
+ subcommand "add", "Add environment variable", Envs::AddCommand
10
+ subcommand ["remove", "rm"], "Remove environment variable", Envs::RemoveCommand
11
+ end
12
+ end
@@ -1,10 +1,10 @@
1
- require_relative 'services_helper'
1
+ require_relative '../services_helper'
2
2
 
3
- module Kontena::Cli::Services
4
- class AddEnvCommand < Clamp::Command
3
+ module Kontena::Cli::Services::Envs
4
+ class AddCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
6
  include Kontena::Cli::GridOptions
7
- include ServicesHelper
7
+ include Kontena::Cli::Services::ServicesHelper
8
8
 
9
9
  parameter "NAME", "Service name"
10
10
  parameter "ENV", "Environment variable"
@@ -1,10 +1,10 @@
1
- require_relative 'services_helper'
1
+ require_relative '../services_helper'
2
2
 
3
- module Kontena::Cli::Services
4
- class EnvsCommand < Clamp::Command
3
+ module Kontena::Cli::Services::Envs
4
+ class ListCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
6
  include Kontena::Cli::GridOptions
7
- include ServicesHelper
7
+ include Kontena::Cli::Services::ServicesHelper
8
8
 
9
9
  parameter "NAME", "Service name"
10
10
 
@@ -12,7 +12,7 @@ module Kontena::Cli::Services
12
12
  require_api_url
13
13
  token = require_token
14
14
  service = client(token).get("services/#{parse_service_id(name)}")
15
- service["env"].each do |env|
15
+ service["env"].sort.each do |env|
16
16
  puts env
17
17
  end
18
18
  end
@@ -1,10 +1,10 @@
1
- require_relative 'services_helper'
1
+ require_relative '../services_helper'
2
2
 
3
- module Kontena::Cli::Services
4
- class RemoveEnvCommand < Clamp::Command
3
+ module Kontena::Cli::Services::Envs
4
+ class RemoveCommand < Clamp::Command
5
5
  include Kontena::Cli::Common
6
6
  include Kontena::Cli::GridOptions
7
- include ServicesHelper
7
+ include Kontena::Cli::Services::ServicesHelper
8
8
 
9
9
  parameter "NAME", "Service name"
10
10
  parameter "ENV", "Environment variable name"
@@ -11,9 +11,10 @@ module Kontena::Cli::Services
11
11
  token = require_token
12
12
 
13
13
  grids = client(token).get("grids/#{current_grid}/services")
14
+ services = grids['services'].sort_by{|s| s['updated_at'] }.reverse
14
15
  titles = ['NAME', 'INSTANCES', 'STATEFUL', 'STATE', 'EXPOSED PORTS']
15
- puts "%-60.60s %-10s %-8s %-10s %-50s" % titles
16
- grids['services'].each do |service|
16
+ puts "%-60s %-10s %-8s %-10s %-50s" % titles
17
+ services.each do |service|
17
18
  stateful = service['stateful'] ? 'yes' : 'no'
18
19
  running = service['instances']['running']
19
20
  desired = service['container_count']
@@ -10,7 +10,6 @@ module Kontena::Cli::Services
10
10
  option ["-t", "--tail"], :flag, "Tail (follow) logs", default: false
11
11
  option ["-l", "--lines"], "LINES", "How many lines to show", default: '100'
12
12
  option "--since", "SINCE", "Show logs since given timestamp"
13
- option ["-s", "--search"], "SEARCH", "Search from logs"
14
13
  option ["-i", "--instance"], "INSTANCE", "Show only given instance specific logs"
15
14
 
16
15
  def execute
@@ -22,7 +21,6 @@ module Kontena::Cli::Services
22
21
  query_params << "limit=#{lines}"
23
22
  query_params << "from=#{last_id}" unless last_id.nil?
24
23
  query_params << "since=#{since}" if !since.nil? && last_id.nil?
25
- query_params << "search=#{search}" if search
26
24
  query_params << "container=#{name}-#{instance}" if instance
27
25
 
28
26
  result = client(token).get("services/#{current_grid}/#{name}/container_logs?#{query_params.join('&')}")