kontena-cli 1.2.1 → 1.2.2.rc1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2348d6e1178017225647afe4f27ea5b8906cbdd0
4
- data.tar.gz: bcc0cabfc17f05d12e46403ef1bf9fce295e14e0
3
+ metadata.gz: 7db7c48764f8cf25a6c8299cfea9a9114bf22e60
4
+ data.tar.gz: 6dd47f6ca45694944a84a785f4e44dd1e679813d
5
5
  SHA512:
6
- metadata.gz: 3dcf0ee41489b454d2a406efb0e78761c8f257cf12d58102f956f3e319e74623b280447efb2c0b1c1be80bcf0ceb6b539bbce6854c2cd33458e1e43e29f40ace
7
- data.tar.gz: 803334eee3e02d1f41de731142918c3c4f50ae2fb059134ef16884cbac0fccf929368f253cbefdb4aaae12c66d3d1a423aacd47dd3a51163216f17d0dcb90fd4
6
+ metadata.gz: 66602d4abf1853a69113535b6df1c680e957c9fb505ba7c616ea9d72e4eb9fa501b0f5627ae73565688c98035030cecf3b44aa2306c6268810cf22f5b4396ab6
7
+ data.tar.gz: 0403f16eff264d3841a9b56b508ddd6f789f353d8bc91b85a95853a6562951a0f2a8987878b66ab292faed249ea83e1c4fa7b792d0b454742826532c19d8c0e4
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.1
1
+ 1.2.2.rc1
@@ -1,3 +1,4 @@
1
+ require 'securerandom'
1
2
 
2
3
  module Kontena
3
4
  module Callbacks
@@ -7,8 +7,10 @@ module Kontena::Cli::Grids
7
7
 
8
8
  parameter "NAME", "Grid name"
9
9
  option "--statsd-server", "STATSD_SERVER", "Statsd server address (host:port)"
10
+ option "--no-statsd-server", :flag, "Unset statsd server setting"
10
11
  option "--default-affinity", "[AFFINITY]", "Default affinity rule for the grid", multivalued: true
11
- option "--log-forwarder", "LOG_FORWARDER", "Set grid wide log forwarder"
12
+ option "--no-default-affinity", :flag, "Unset grid default affinity"
13
+ option "--log-forwarder", "LOG_FORWARDER", "Set grid wide log forwarder (set to 'none' to disable)"
12
14
  option "--log-opt", "[LOG_OPT]", "Set log options (key=value)", multivalued: true
13
15
 
14
16
  def execute
@@ -26,6 +28,10 @@ module Kontena::Cli::Grids
26
28
  }
27
29
  end
28
30
 
31
+ if no_statsd_server?
32
+ payload[:stats] = { statsd: nil }
33
+ end
34
+
29
35
  if log_forwarder
30
36
  payload[:logs] = {
31
37
  forwarder: log_forwarder,
@@ -33,9 +39,14 @@ module Kontena::Cli::Grids
33
39
  }
34
40
  end
35
41
 
36
- if default_affinity_list
42
+ unless default_affinity_list.empty?
37
43
  payload[:default_affinity] = default_affinity_list
38
44
  end
45
+
46
+ if no_default_affinity?
47
+ payload[:default_affinity] = []
48
+ end
49
+
39
50
  client(token).put("grids/#{name}", payload)
40
51
  end
41
52
 
@@ -1,4 +1,5 @@
1
1
  require_relative '../stacks/stacks_helper'
2
+ require 'securerandom'
2
3
 
3
4
  module Kontena::Cli::Registry
4
5
  class CreateCommand < Kontena::Command
@@ -31,7 +31,23 @@ module Kontena::Cli::Stacks::YAML
31
31
  'external_links' => optional('array'),
32
32
  'mem_limit' => optional('string'),
33
33
  'mem_swaplimit' => optional('string'),
34
- 'environment' => optional(-> (value) { value.is_a?(Array) || value.is_a?(Hash) }),
34
+ 'environment' => optional(-> (value) {
35
+ if value.is_a?(Hash)
36
+ value.all? do |k,v|
37
+ k.kind_of?(String) && (
38
+ v.kind_of?(String) ||
39
+ v.kind_of?(Integer) ||
40
+ v.kind_of?(TrueClass) ||
41
+ v.kind_of?(FalseClass) ||
42
+ v.nil?
43
+ )
44
+ end
45
+ elsif value.is_a?(Array)
46
+ value.all? { |v| v.kind_of?(String) && v =~ /\A\S+(?<!\\)=.*/ }
47
+ else
48
+ false
49
+ end
50
+ }),
35
51
  'env_file' => optional(-> (value) { value.is_a?(String) || value.is_a?(Array) }),
36
52
  'instances' => optional('integer'),
37
53
  'links' => optional(-> (value) { value.is_a?(Array) || value.nil? }),
@@ -29,5 +29,6 @@ exclude "**/.git"
29
29
  exclude "**/bundler/git"
30
30
 
31
31
  package :pkg do
32
- identifier "io.kontena.pkg.cli"
32
+ identifier "io.kontena.cli.pkg.kontena"
33
+ signing_identity "Developer ID Installer: Kontena Oy (JJ22T2W355)"
33
34
  end
@@ -41,6 +41,24 @@ describe Kontena::Cli::Grids::UpdateCommand do
41
41
  )
42
42
  subject.run(['--log-forwarder', 'fluentd', '--log-opt', 'foo=bar', 'test'])
43
43
  end
44
+
45
+ it 'should send empty statsd when --no-statsd-server given' do
46
+ expect(client).to receive(:put).with(
47
+ 'grids/test', hash_including({
48
+ stats: { statsd: nil }
49
+ })
50
+ )
51
+ subject.run(['--no-statsd-server', 'test'])
52
+ end
53
+
54
+ it 'should send empty default_affinity when --no-default-affinity given' do
55
+ expect(client).to receive(:put).with(
56
+ 'grids/test', hash_including({
57
+ default_affinity: []
58
+ })
59
+ )
60
+ subject.run(['--no-default-affinity', 'test'])
61
+ end
44
62
  end
45
63
  end
46
64
  end
@@ -110,6 +110,18 @@ describe Kontena::Cli::Stacks::YAML::ValidatorV3 do
110
110
  expect(result.errors.key?('environment')).to be_falsey
111
111
  end
112
112
 
113
+ it 'fails validation if environment array includes items without equals sign' do
114
+ result = subject.validate_options('environment' => ['KEY=VALUE', 'KEY2=VALUE2'])
115
+ expect(result.errors.key?('environment')).to be_falsey
116
+ result = subject.validate_options('environment' => ['KEY=VALUE', 'KEY2 VALUE'])
117
+ expect(result.errors.key?('environment')).to be_truthy
118
+ end
119
+
120
+ it 'passes validation if environment array includes items with booleans or nils' do
121
+ result = subject.validate_options('environment' => { 'KEY' => true, 'KEY2' => false, 'KEY3' => nil })
122
+ expect(result.errors.key?('environment')).to be_falsey
123
+ end
124
+
113
125
  context 'validates secrets' do
114
126
  it 'must be array' do
115
127
  result = subject.validate_options('secrets' => {})
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kontena-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-28 00:00:00.000000000 Z
11
+ date: 2017-05-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -662,9 +662,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
662
662
  version: 2.1.0
663
663
  required_rubygems_version: !ruby/object:Gem::Requirement
664
664
  requirements:
665
- - - ">="
665
+ - - ">"
666
666
  - !ruby/object:Gem::Version
667
- version: '0'
667
+ version: 1.3.1
668
668
  requirements: []
669
669
  rubyforge_project:
670
670
  rubygems_version: 2.6.8