kube_cluster 0.4.2 → 0.4.3

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
  SHA256:
3
- metadata.gz: eac52e8ce0c9a435a78497095c22cdc598ccbde6d617247cd25ed00919261e46
4
- data.tar.gz: 3e6147a0ab466a2cf0275ded885febb7ea9ec4bc092abdc19c39e2130c2dc517
3
+ metadata.gz: 29db1c6f54de40e913ebbf0698353380446c782e040e7eed7cefe2953f77bcb6
4
+ data.tar.gz: 346218c60144c14a826e2a96f622aefdd099f1ac86d339a25d7d331f27ca799d
5
5
  SHA512:
6
- metadata.gz: d84f7ef217ade440d364d368701e6b4e75aaf4da3628c60f65b2d71dabf33f6764d802a239628831e2107c2fa988c03f337d4615b173b5d66b125ea911c31a3e
7
- data.tar.gz: 320623843a7d59d2e8716264211f9e9004bf7984e4b3eebf33bc03762297f8d64b46e4c20103085098a167199922cadb300ad6a852f3ae39ac6e4427b3a2df76
6
+ metadata.gz: c1a5e8987a539b0d47395ee463cbfce25dec2694898ffecdab4b238d1f4d14e85946bf1c39907bd63932973f80cdc79d6034ae4bac540a3ffcaa196c33811436
7
+ data.tar.gz: b5ce0e7cb7fe198569bf2b15d265785ad97c2e512ec5a2ecbb92eabea8b994be621f486ffd9bdf8b6843e861a672518420721cb19e02463153548632a4b86a9b
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kube_cluster (0.4.2)
4
+ kube_cluster (0.4.3)
5
5
  kube_kubectl (~> 2.0.9)
6
6
  kube_schema (~> 1.4.1)
7
7
  scampi (~> 0.1)
@@ -23,6 +23,31 @@ module Kube
23
23
  #
24
24
  class Manifest < Kube::Schema::Manifest
25
25
  attr_reader :resources
26
+
27
+ # Override << to automatically upgrade Kube::Schema::Resource
28
+ # instances into Kube::Cluster::Resource instances. This ensures
29
+ # resources parsed via Kube::Schema::Manifest (e.g. from Helm
30
+ # charts or downloaded YAML) gain cluster-level methods like
31
+ # cluster_scoped?, pod_bearing?, and rebuild when composed into
32
+ # a cluster manifest.
33
+ def <<(item)
34
+ case item
35
+ when Kube::Cluster::Resource
36
+ @resources << item
37
+ when Kube::Schema::Resource
38
+ @resources << Kube::Cluster[item.kind].new(item.to_h)
39
+ when Kube::Schema::Manifest
40
+ item.each { |r| self << r }
41
+ when Array
42
+ item.each { |r| self << r }
43
+ else
44
+ raise ArgumentError,
45
+ "Expected a Kube::Schema::Resource or Manifest, got #{item.class}. " \
46
+ "Use Kube::Schema.parse(hash) to convert hashes."
47
+ end
48
+
49
+ self
50
+ end
26
51
  end
27
52
  end
28
53
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Kube
4
4
  module Cluster
5
- VERSION = "0.4.2"
5
+ VERSION = "0.4.3"
6
6
  end
7
7
  end
@@ -46,13 +46,13 @@ module Kube
46
46
  #
47
47
  # @return [self]
48
48
  def add
49
- if endpoint.requires_add?
50
- repo_name = @name
51
- repo_url = endpoint.url
52
- cmd = helm.call { repo.add.(repo_name).(repo_url) }
53
- helm.run(cmd.to_s)
49
+ tap do
50
+ if endpoint.requires_add?
51
+ helm.run(
52
+ helm.call { repo.add.(@name).(endpoint.url) }.to_s
53
+ )
54
+ end
54
55
  end
55
- self
56
56
  end
57
57
 
58
58
  # Update the local chart index for this repo.
@@ -60,12 +60,13 @@ module Kube
60
60
  #
61
61
  # @return [self]
62
62
  def update
63
- if endpoint.requires_add?
64
- repo_name = @name
65
- cmd = helm.call { repo.update.(repo_name) }
66
- helm.run(cmd.to_s)
63
+ tap do
64
+ if endpoint.requires_add?
65
+ helm.run(
66
+ helm.call { repo.update.(@name) }.to_s
67
+ )
68
+ end
67
69
  end
68
- self
69
70
  end
70
71
 
71
72
  # Remove this repo from the local Helm client.
@@ -73,12 +74,13 @@ module Kube
73
74
  #
74
75
  # @return [self]
75
76
  def remove
76
- if endpoint.requires_add?
77
- repo_name = @name
78
- cmd = helm.call { repo.remove.(repo_name) }
79
- helm.run(cmd.to_s)
77
+ tap do
78
+ if endpoint.requires_add?
79
+ helm.run(
80
+ helm.call { repo.remove.(@name) }.to_s
81
+ )
82
+ end
80
83
  end
81
- self
82
84
  end
83
85
 
84
86
  # Fetch a chart from this repo.
@@ -96,12 +98,19 @@ module Kube
96
98
 
97
99
  ref = endpoint.chart_ref(chart_name, repo_name: @name)
98
100
 
99
- cmd = helm.call { show.chart.(ref) }
100
- cmd = cmd.version(version) if version
101
- yaml_output = helm.run(cmd.to_s)
102
-
103
- data = YAML.safe_load(yaml_output, permitted_classes: [Symbol]) || {}
104
- Chart.new(data, ref: ref, cluster: @cluster)
101
+ helm.run(
102
+ helm.call {
103
+ if version
104
+ show.chart.(ref).version(version)
105
+ else
106
+ show.chart.(ref)
107
+ end
108
+ }.to_s
109
+ ).then do |yaml_output|
110
+ (YAML.safe_load(yaml_output, permitted_classes: [Symbol]) || {}).then do |data|
111
+ Chart.new(data, ref: ref, cluster: @cluster)
112
+ end
113
+ end
105
114
  end
106
115
 
107
116
  # Is this an OCI-backed repo?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kube_cluster
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nathan K