kubec 0.3.6 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2ef78e9016c5f634b5c59869b5741bb717534a48
4
- data.tar.gz: dd9bef96bd6d03148a0f8db0175c516d4d8cbe48
3
+ metadata.gz: 9620eb2542b711dd56a019147854a504dde57a9b
4
+ data.tar.gz: '04458cc7fa88ece1a99807e1885a09bef6580cfc'
5
5
  SHA512:
6
- metadata.gz: ea9259996ee8e57a48e70faf5db49f81b368728bfd5e17be71eb112e1f90841d66d36e05f995971da2759dfe022cf9fc9a9768f599aa57270089c3f5555a9676
7
- data.tar.gz: 9d85cd5458aae996f020aa467c7cb3c4d4e5b0513d3146d2d9f433dbbe51c4834f2ab9542f0de783d8d32c58ba90b1d8c7e45912d8185f654522b528d24cefba
6
+ metadata.gz: 3e2950f186e92784041d4615e0b687b076bebf0b680ee7f9667cb59671a54ae16bf90faa4c52205997d320347bc556d31181856068efdbbf5b1dfd221c3a9ee2
7
+ data.tar.gz: e14f6d89ec923627ef28689293071b5a9a3ee4eb8244ef97d60184312f30aa957c7b2df1f63851ea92f3b55f7a15c546bcbfa3c0fe08875411b22f92047ab14c
@@ -68,18 +68,19 @@ module Kubec
68
68
  end
69
69
 
70
70
  def sort_options(options)
71
- supported_options = %w[tasks]
71
+ supported_options = %w[tasks trace verbose]
72
72
 
73
73
  options.select! do |(switch, *)|
74
74
  switch =~ /--#{Regexp.union(supported_options)}/
75
75
  end
76
76
 
77
- super.push(debug, version)
77
+ super.push(debug, dry_run, version)
78
78
  end
79
79
 
80
80
  def setup_options
81
81
  options.rakelib = ['rakelib']
82
82
  options.debug = false
83
+ options.dry = false
83
84
  options.trace_output = STDERR
84
85
  end
85
86
 
@@ -97,6 +98,16 @@ module Kubec
97
98
  ]
98
99
  end
99
100
 
101
+ def dry_run
102
+ [
103
+ '--[no-]dry',
104
+ 'Run kubernetes command in dry mode',
105
+ lambda do |value|
106
+ options.dry = value
107
+ end
108
+ ]
109
+ end
110
+
100
111
  def version
101
112
  [
102
113
  '--version', '-V',
@@ -43,9 +43,9 @@ module Kubec
43
43
  # TODO: Refactor
44
44
  def path_with_stage(path)
45
45
  path.split('.').tap do |ary|
46
- ext = ary.pop
46
+ ext = ary.pop unless ary.first.empty?
47
47
  ary.push(fetch(:stage, :staging))
48
- ary.push(ext)
48
+ ary.push(ext) if ext
49
49
  end.join('.')
50
50
  end
51
51
  end
@@ -26,7 +26,16 @@ module Kubec
26
26
  return unless APPLYABLE_TYPES.include?(type.to_sym)
27
27
  return debug(type) if Rake.application.options.debug
28
28
  # TODO: Replace with RESTful API
29
- IO.popen('kubectl apply -f -', 'r+') do |io|
29
+ execute(type)
30
+ end
31
+
32
+ def cmd
33
+ return 'kubectl apply --dry-run -f -' if Rake.application.options.dry
34
+ 'kubectl apply -f -'
35
+ end
36
+
37
+ def execute(type)
38
+ IO.popen(cmd, 'r+') do |io|
30
39
  io.write convert_to_json(instance.send(type))
31
40
  io.close_write
32
41
  puts io.gets
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Kubec
4
- VERSION = '0.3.6'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kubec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 5xRuby
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-01-19 00:00:00.000000000 Z
12
+ date: 2018-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: colorize