k8s-client 0.4.2 → 0.5.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.
data/lib/k8s/util.rb CHANGED
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module K8s
2
4
  # Miscellaneous helpers
3
5
  module Util
4
- PATH_TR_MAP={ '~' => '~0', '/' => '~1' }.freeze
5
- PATH_REGEX=%r{(/|~(?!1))}.freeze
6
+ PATH_TR_MAP = { '~' => '~0', '/' => '~1' }.freeze
7
+ PATH_REGEX = %r{(/|~(?!1))}.freeze
6
8
 
7
9
  # Yield with all non-nil args, returning matching array with corresponding return values or nils.
8
10
  #
@@ -20,17 +22,17 @@ module K8s
20
22
  # Hash{arg => value}
21
23
  value_map = Hash[func_args.zip(values)]
22
24
 
23
- args.map{|arg| value_map[arg] }
25
+ args.map{ |arg| value_map[arg] }
24
26
  end
25
27
 
26
28
  # Produces a set of json-patch operations so that applying
27
29
  # the operations on a, gives you the results of b
28
30
  # Used in correctly patching the Kube resources on stack updates
29
31
  #
30
- # @param a [Hash] Hash to compute patches against
31
- # @param a [Hash] New Hash to compute patches "from"
32
- def self.json_patch(a, b)
33
- diffs = HashDiff.diff(a, b, array_path: true)
32
+ # @param patch_to [Hash] Hash to compute patches against
33
+ # @param patch_from [Hash] New Hash to compute patches "from"
34
+ def self.json_patch(patch_to, patch_from)
35
+ diffs = HashDiff.diff(patch_to, patch_from, array_path: true)
34
36
  ops = []
35
37
  # Each diff is like:
36
38
  # ["+", ["spec", "selector", "food"], "kebab"]
@@ -42,7 +44,7 @@ module K8s
42
44
  operator = diff[0]
43
45
  # substitute '/' with '~1' and '~' with '~0'
44
46
  # according to RFC 6901
45
- path = diff[1].map {|p| p.to_s.gsub(PATH_REGEX, PATH_TR_MAP) }
47
+ path = diff[1].map { |p| p.to_s.gsub(PATH_REGEX, PATH_TR_MAP) }
46
48
  if operator == '-'
47
49
  ops << {
48
50
  op: "remove",
@@ -63,7 +65,6 @@ module K8s
63
65
  else
64
66
  raise "Unknown diff operator: #{operator}!"
65
67
  end
66
-
67
68
  end
68
69
 
69
70
  ops
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: k8s-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kontena, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-13 00:00:00.000000000 Z
11
+ date: 2018-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.3.7
83
+ - !ruby/object:Gem::Dependency
84
+ name: jsonpath
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 0.9.5
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 0.9.5
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: bundler
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,20 @@ dependencies:
136
150
  - - "~>"
137
151
  - !ruby/object:Gem::Version
138
152
  version: 3.4.2
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.59'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.59'
139
167
  description:
140
168
  email:
141
169
  - info@kontena.io
@@ -145,6 +173,8 @@ extra_rdoc_files: []
145
173
  files:
146
174
  - ".gitignore"
147
175
  - ".rspec"
176
+ - ".rubocop.relaxed.yml"
177
+ - ".rubocop.yml"
148
178
  - ".travis.yml"
149
179
  - Dockerfile
150
180
  - Gemfile