k8s-client 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/lib/k8s/client/version.rb +1 -1
- data/lib/k8s/resource.rb +6 -3
- data/lib/k8s/util.rb +10 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ffb8d5ea84ea9155cf1edabd3658712e419d61caf2381c7c9e00a450d7b5c52
|
4
|
+
data.tar.gz: d97128fc9858a09d41585a5b9879deb2920cda848fcf1b01661c5bf23c2b1c10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79481cc31f515777ab46d942aa5f941c4525fee62497dd93137ea33e075d32cd25ec1a4a26c3422b6a7c5ef533432b58e36a6cd10b2cd392deffa0dc66e9c91
|
7
|
+
data.tar.gz: 34694c8c5985f51ff701853cd7d34a307c9e3a414570e0817760df5200edc9b47b92b8b7a087d094c5863e2ef5d0133447905f576b09491fd5b2c9fa002e9a42
|
data/.travis.yml
CHANGED
@@ -12,7 +12,7 @@ deploy:
|
|
12
12
|
provider: rubygems
|
13
13
|
gem: k8s-client
|
14
14
|
api_key:
|
15
|
-
secure:
|
15
|
+
secure: "f5NfPVtrGPaOCP/tnfoYRSZCRwITnQrl/YNW70gm+nk32JD1UE7qloYdNqpx4VChdFsOH/hfxygiFJkuAhvEWsx1kqOfNpVV+05r92ulp0tMyC/U1wBdnY1UEVbyZF/of25aPezx6Egkw5OFAOqUVwC6m1CqHiL91InZcE5uNtI9Kc2MHAWZqKyD7G5hau0jdFWldTS1gRrl4wJaJq0TQEWqllX6UmaW+p3pSFYKw6IekrI4LYTmCCbxRjwl2TQ8WMSTjvzEK3AIeUe7QU8bv3+56FsnCwr7dXeSK6GoDTQHZlflqYaTt6khsIXbGFCQyws4qFWu69Wf+nEJTSe7TH3qKa1WsAQy0CucVxQ5C0Lt5N5Bb2ZhqM3F2rjxeUnRBJfSRPNqyRQJUaY5GyxcEgco/rhFNJKD28sfNMqBslxGRpj2Y+hyzXt9JnRe7yEdWJcVuQLp6ObhK5DDqtcOF4aFrVd1OxZLlvl7DTHlngBuMJ7TRX50wfAkRWr4u+crrsN25j8y1KfXkTBWvlPNlReHxeT3DjPkhGuMGpy52KOtGB+5ibFvea3N2o4t9xT5pykvQ0ohwu+aj/4MroP95NKwVWZ8cbW/euOd68lwA1ZGTalPKmMWH4pPwNUmhnaCgZGexktGAVpDxFE7fZdh7gb/szfmeDDZ66eAolzrImU="
|
16
16
|
on:
|
17
17
|
tags: true
|
18
18
|
rvm: '2.4'
|
data/lib/k8s/client/version.rb
CHANGED
data/lib/k8s/resource.rb
CHANGED
@@ -27,7 +27,7 @@ module K8s
|
|
27
27
|
|
28
28
|
if stat.directory?
|
29
29
|
# recurse
|
30
|
-
Dir.glob("#{path}/*.{yml,yaml}").sort.map{|
|
30
|
+
Dir.glob("#{path}/*.{yml,yaml}").sort.map { |dir| self.from_files(dir) }.flatten
|
31
31
|
else
|
32
32
|
::YAML.load_stream(File.read(path), path).map{|doc| new(doc) }
|
33
33
|
end
|
@@ -79,10 +79,13 @@ module K8s
|
|
79
79
|
# @return [Hash]
|
80
80
|
def current_config(config_annotation)
|
81
81
|
current_cfg = self.metadata.annotations&.dig(config_annotation)
|
82
|
+
return {} unless current_cfg
|
82
83
|
|
83
|
-
|
84
|
+
current_hash = JSON.parse(current_cfg)
|
85
|
+
# kubectl adds empty metadata.namespace, let's fix it
|
86
|
+
current_hash['metadata'].delete('namespace') if current_hash.dig('metadata', 'namespace').to_s.empty?
|
84
87
|
|
85
|
-
|
88
|
+
current_hash
|
86
89
|
end
|
87
90
|
|
88
91
|
def can_patch?(config_annotation)
|
data/lib/k8s/util.rb
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
module K8s
|
2
2
|
# Miscellaneous helpers
|
3
3
|
module Util
|
4
|
+
PATH_TR_MAP={ '~' => '~0', '/' => '~1' }.freeze
|
5
|
+
PATH_REGEX=%r{(/|~(?!1))}.freeze
|
6
|
+
|
4
7
|
# Yield with all non-nil args, returning matching array with corresponding return values or nils.
|
5
8
|
#
|
6
9
|
# Args must be usable as hash keys. Duplicate args will all map to the same return value.
|
@@ -29,13 +32,17 @@ module K8s
|
|
29
32
|
def self.json_patch(a, b)
|
30
33
|
diffs = HashDiff.diff(a, b, array_path: true)
|
31
34
|
ops = []
|
32
|
-
# Each diff is like
|
33
|
-
#
|
35
|
+
# Each diff is like:
|
36
|
+
# ["+", ["spec", "selector", "food"], "kebab"]
|
37
|
+
# ["-", ["spec", "selector", "drink"], "pepsi"]
|
38
|
+
# or
|
39
|
+
# ["~", ["spec", "selector", "drink"], "old value", "new value"]
|
40
|
+
# the path elements can be symbols too, depending on the input hashes
|
34
41
|
diffs.each do |diff|
|
35
42
|
operator = diff[0]
|
36
43
|
# substitute '/' with '~1' and '~' with '~0'
|
37
44
|
# according to RFC 6901
|
38
|
-
path = diff[1].map {|p| p.to_s.gsub(
|
45
|
+
path = diff[1].map {|p| p.to_s.gsub(PATH_REGEX, PATH_TR_MAP) }
|
39
46
|
if operator == '-'
|
40
47
|
ops << {
|
41
48
|
op: "remove",
|
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.
|
4
|
+
version: 0.4.1
|
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-
|
11
|
+
date: 2018-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|