kubes 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/docs/_docs/helpers/aws.md +1 -0
- data/docs/_docs/helpers/google.md +1 -1
- data/docs/_docs/patterns/secrets.md +0 -2
- data/lib/kubes/kubectl.rb +5 -23
- data/lib/kubes/kubectl/batch.rb +33 -6
- data/lib/kubes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b2e59aafa5ea2023bdf23dc43ba38c5279dcd719c3db793eca0abf24c8e1da2
|
4
|
+
data.tar.gz: ed004f619cba70d0d6257ca9559b3fd1b1fa7cb6c48943c64c3abcb8cddf3d38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7be4d6f0bd67e15b9ba3e3594f1b98d36c3fb5a4cc68c67fd603a75a973e4b90f8800a0a8fddf68951d0f3f09291c154bae5066830ec792aa167eb8675f5acca
|
7
|
+
data.tar.gz: 6187e6b6bc29e1a038f8c5a20530483a120cc6107854f718f8570648334f27cb7b4afb1a39d4d45ede4bb3cda97e8cc66d63c1cbbdde27a059997f65bd547704
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
4
4
|
This project *loosely tries* to adhere to [Semantic Versioning](http://semver.org/), even before v1.0.
|
5
5
|
|
6
|
+
## [0.4.7]
|
7
|
+
- #33 improve switch context: earlier and only when needed
|
8
|
+
|
6
9
|
## [0.4.6]
|
7
10
|
- #32 custom helpers support
|
8
11
|
|
data/docs/_docs/helpers/aws.md
CHANGED
@@ -12,3 +12,4 @@ List of AWS helpers:
|
|
12
12
|
## Notes
|
13
13
|
|
14
14
|
* By default, `KubeGoogle.logger = Kubes.logger`. This means, you can set `logger.level = "debug"` in `.kubes/config.rb` to see more details.
|
15
|
+
* The AWS helpers are provided by the [boltops-tools/kubes_aws](https://github.com/boltops-tools/kubes_aws) library.
|
@@ -14,4 +14,4 @@ List of Google helpers:
|
|
14
14
|
* By default, `KubeGoogle.logger = Kubes.logger`. This means, you can set `logger.level = "debug"` in `.kubes/config.rb` to see more details.
|
15
15
|
* The `gcloud` cli is used to create IAM roles. So `gcloud` is required.
|
16
16
|
* Note: Would like to use the google sdk, but it wasn't obvious how to do so. PRs are welcomed.
|
17
|
-
|
17
|
+
* The Google helpers are provided by the [boltops-tools/kubes_google](https://github.com/boltops-tools/kubes_google) library.
|
@@ -78,5 +78,3 @@ upcase | Automatically upcase the Kubernetes secret data keys. | false
|
|
78
78
|
prefix | Prefixed used to list and filter Google secrets. IE: `projects/686010496118/secrets/demo-dev-`. Can also be set with the `GCP_SECRET_PREFIX` env variable. The env variable takes the highest precedence. | nil
|
79
79
|
|
80
80
|
Note, Kubernetes secrets are only base64 encoded. So users who have access to read Kubernetes secrets will be able to decode and get the value trivially. Depending on your security posture requirements, this may or may not suffice.
|
81
|
-
|
82
|
-
The Google helpers are provided by the [boltops-tools/kubes_google](https://github.com/boltops-tools/kubes_google) library. For more details, check out its README.
|
data/lib/kubes/kubectl.rb
CHANGED
@@ -17,13 +17,11 @@ module Kubes
|
|
17
17
|
params = args.flatten.join(' ')
|
18
18
|
args = "#{@name} #{params}" # @name: apply or delete
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
self.class.execute(args, options)
|
26
|
-
end
|
20
|
+
run_hooks("kubectl.rb", name: @name, file: @options[:file]) do
|
21
|
+
if options[:capture]
|
22
|
+
self.class.capture(args, options) # already includes kubectl
|
23
|
+
else
|
24
|
+
self.class.execute(args, options)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -44,22 +42,6 @@ module Kubes
|
|
44
42
|
Kubes.config.kubectl.exit_on_fail[@name]
|
45
43
|
end
|
46
44
|
|
47
|
-
def switch_context(&block)
|
48
|
-
kubectl = Kubes.config.kubectl
|
49
|
-
context = kubectl.context
|
50
|
-
if context
|
51
|
-
previous_context = capture("kubectl config current-context")
|
52
|
-
sh("kubectl config use-context #{context}", mute: true)
|
53
|
-
result = block.call
|
54
|
-
if !previous_context.blank? && !kubectl.context_keep
|
55
|
-
sh("kubectl config use-context #{previous_context}", mute: true)
|
56
|
-
end
|
57
|
-
result
|
58
|
-
else
|
59
|
-
block.call
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
45
|
def args
|
64
46
|
# base at end in case of redirection. IE: command > /path
|
65
47
|
custom.args + default.args
|
data/lib/kubes/kubectl/batch.rb
CHANGED
@@ -3,6 +3,7 @@ class Kubes::Kubectl
|
|
3
3
|
include Kubes::Hooks::Concern
|
4
4
|
include Kubes::Logging
|
5
5
|
include Kubes::Util::Consider
|
6
|
+
include Kubes::Util::Sh
|
6
7
|
include Ordering
|
7
8
|
|
8
9
|
def initialize(name, options={})
|
@@ -12,17 +13,43 @@ class Kubes::Kubectl
|
|
12
13
|
def run
|
13
14
|
# @options[:preview] is really only used for kubectl delete
|
14
15
|
logger.info "Will run:" if @options[:preview]
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
switch_context do
|
17
|
+
run_hooks("kubes.rb", name: @name) do
|
18
|
+
sorted_files.each do |file|
|
19
|
+
if @options[:preview]
|
20
|
+
logger.info " kubectl #{@name} -f #{file}"
|
21
|
+
else
|
22
|
+
Kubes::Kubectl.run(@name, @options.merge(file: file))
|
23
|
+
end
|
21
24
|
end
|
22
25
|
end
|
23
26
|
end
|
24
27
|
end
|
25
28
|
|
29
|
+
def switch_context(&block)
|
30
|
+
kubectl = Kubes.config.kubectl
|
31
|
+
context = kubectl.context
|
32
|
+
|
33
|
+
unless context
|
34
|
+
block.call
|
35
|
+
return
|
36
|
+
end
|
37
|
+
|
38
|
+
previous_context = sh_capture("kubectl config current-context")
|
39
|
+
if previous_context == context
|
40
|
+
block.call
|
41
|
+
return
|
42
|
+
end
|
43
|
+
|
44
|
+
logger.debug "Switching kubectl context to: #{context}"
|
45
|
+
sh("kubectl config use-context #{context}", mute: true)
|
46
|
+
result = block.call
|
47
|
+
if !previous_context.blank? && !kubectl.context_keep
|
48
|
+
sh("kubectl config use-context #{previous_context}", mute: true)
|
49
|
+
end
|
50
|
+
result
|
51
|
+
end
|
52
|
+
|
26
53
|
# kubes apply # {role: nil, resource: nil}
|
27
54
|
# kubes apply clock # {role: "clock", resource: nil}
|
28
55
|
# kubes apply clock deployment # {role: "clock", resource: "deployment"}
|
data/lib/kubes/version.rb
CHANGED