kerbi 0.0.1 → 0.0.2
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 +4 -4
- data/lib/cli/base_handler.rb +180 -0
- data/lib/cli/base_serializer.rb +120 -0
- data/lib/cli/config_handler.rb +51 -0
- data/lib/cli/entry_serializers.rb +99 -0
- data/lib/cli/project_handler.rb +2 -2
- data/lib/cli/root_handler.rb +32 -13
- data/lib/cli/state_handler.rb +95 -0
- data/lib/cli/values_handler.rb +4 -3
- data/lib/config/cli_schema.rb +299 -27
- data/lib/config/config_file.rb +60 -0
- data/lib/config/globals.rb +4 -0
- data/lib/config/run_opts.rb +150 -0
- data/lib/config/state_consts.rb +10 -0
- data/lib/kerbi.rb +31 -9
- data/lib/main/errors.rb +109 -0
- data/lib/main/mixer.rb +12 -8
- data/lib/mixins/cli_state_helpers.rb +136 -0
- data/lib/mixins/cm_backend_testing.rb +95 -0
- data/lib/mixins/entry_tag_logic.rb +183 -0
- data/lib/state/base_backend.rb +59 -0
- data/lib/state/config_map_backend.rb +119 -0
- data/lib/state/entry.rb +173 -0
- data/lib/state/entry_set.rb +137 -0
- data/lib/state/metadata.yaml.erb +11 -0
- data/lib/state/mixers.rb +23 -0
- data/lib/state/resources.yaml.erb +17 -0
- data/lib/utils/cli.rb +77 -10
- data/lib/utils/helm.rb +10 -12
- data/lib/utils/k8s_auth.rb +87 -0
- data/lib/utils/misc.rb +36 -1
- data/lib/utils/mixing.rb +1 -1
- data/lib/utils/values.rb +13 -22
- data/spec/cli/config_handler_spec.rb +38 -0
- data/spec/cli/root_handler_spec.rb +99 -0
- data/spec/cli/state_handler_spec.rb +139 -0
- data/spec/cli/values_handler_spec.rb +17 -0
- data/spec/expectations/common/bad-tag.txt +1 -0
- data/spec/expectations/config/bad-set.txt +1 -0
- data/spec/expectations/config/set.txt +1 -0
- data/spec/expectations/config/show-default.yaml +6 -0
- data/spec/expectations/root/template-inlines.yaml +31 -0
- data/spec/expectations/root/template-production.yaml +31 -0
- data/spec/expectations/root/template-read-inlines.yaml +31 -0
- data/spec/expectations/root/template-read.yaml +31 -0
- data/spec/expectations/root/template-write.yaml +31 -0
- data/spec/expectations/root/template.yaml +31 -0
- data/spec/expectations/root/values.json +28 -0
- data/spec/expectations/state/delete.txt +1 -0
- data/spec/expectations/state/demote.txt +1 -0
- data/spec/expectations/state/init-already-existed.txt +2 -0
- data/spec/expectations/state/init-both-created.txt +2 -0
- data/spec/expectations/state/list.json +51 -0
- data/spec/expectations/state/list.txt +6 -0
- data/spec/expectations/state/list.yaml +35 -0
- data/spec/expectations/state/promote.txt +1 -0
- data/spec/expectations/state/prune-candidates.txt +1 -0
- data/spec/expectations/state/retag.txt +1 -0
- data/spec/expectations/state/set.txt +1 -0
- data/spec/expectations/state/show.json +13 -0
- data/spec/expectations/state/show.txt +13 -0
- data/spec/expectations/state/show.yaml +8 -0
- data/spec/expectations/state/status-all-working.txt +4 -0
- data/spec/expectations/state/status-not-provisioned.txt +4 -0
- data/spec/expectations/values/order-of-precedence.yaml +4 -0
- data/spec/main/configmap_backend_spec.rb +109 -0
- data/spec/main/state_entry_set_spec.rb +112 -0
- data/spec/main/state_entry_spec.rb +109 -0
- data/spec/spec_helper.rb +87 -1
- data/spec/utils/helm_spec.rb +1 -21
- data/spec/utils/k8s_auth_spec.rb +32 -0
- data/spec/utils/misc_utils_spec.rb +9 -0
- data/spec/utils/values_utils_spec.rb +12 -19
- metadata +114 -13
- data/lib/cli/base.rb +0 -83
- data/lib/config/cli_opts.rb +0 -50
- data/lib/config/manager.rb +0 -36
- data/lib/main/state_manager.rb +0 -47
- data/lib/utils/kubectl.rb +0 -58
- data/spec/main/examples_spec.rb +0 -12
- data/spec/main/state_manager_spec.rb +0 -84
- data/spec/utils/state_utils.rb +0 -15
@@ -1,84 +0,0 @@
|
|
1
|
-
# require_relative './../spec_helper'
|
2
|
-
|
3
|
-
# RSpec.describe Kerbi::StateManager do
|
4
|
-
#
|
5
|
-
# subject { Kerbi::StateManager.new }
|
6
|
-
#
|
7
|
-
# context = ENV['KERBI_RSPEC_K8S_CONTEXT'] || 'kind-kind'
|
8
|
-
#
|
9
|
-
# before :each do
|
10
|
-
# puts "KONTEXT #{context}"
|
11
|
-
# end
|
12
|
-
#
|
13
|
-
# describe "#patch" do
|
14
|
-
# context "when there is no entry for variables" do
|
15
|
-
#
|
16
|
-
# before :each do
|
17
|
-
# system(
|
18
|
-
# "kubectl delete cm state -n default --context #{context}",
|
19
|
-
# out: File::NULL,
|
20
|
-
# err: File::NULL
|
21
|
-
# )
|
22
|
-
# end
|
23
|
-
#
|
24
|
-
# it "patches the configmap" do
|
25
|
-
# argue("--context #{context} --set foo.bar=baz")
|
26
|
-
# old_values = subject.get_crt_vars
|
27
|
-
# expect(old_values).to eq({})
|
28
|
-
# subject.patch
|
29
|
-
# new_values = subject.get_crt_vars
|
30
|
-
# expect(new_values).to eq({foo: {bar: "baz"}})
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
#
|
34
|
-
# context "when there is an entry for variables" do
|
35
|
-
#
|
36
|
-
# before :each do
|
37
|
-
# system "kubectl delete cm state -n default --context #{context}"
|
38
|
-
# end
|
39
|
-
#
|
40
|
-
# it "patches the configmap" do
|
41
|
-
# argue("--context #{context} --set foo.bar=baz")
|
42
|
-
# subject.patch
|
43
|
-
#
|
44
|
-
# argue("--context #{context} --set foo.bar=car")
|
45
|
-
# subject.patch
|
46
|
-
#
|
47
|
-
# new_values = subject.get_crt_vars
|
48
|
-
# expect(new_values).to eq({foo: {bar: "car"}})
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# end
|
52
|
-
# end
|
53
|
-
#
|
54
|
-
# describe "#get_configmap" do
|
55
|
-
# context "when it does not exist" do
|
56
|
-
#
|
57
|
-
# before :each do
|
58
|
-
# system "kubectl delete cm state -n default --context #{context}"
|
59
|
-
# end
|
60
|
-
#
|
61
|
-
# it "returns the configmap as a hash" do
|
62
|
-
# argue("--context #{context}")
|
63
|
-
# result = subject.get_configmap(raise_on_er: false)
|
64
|
-
# expect(result).to be_nil
|
65
|
-
# end
|
66
|
-
# end
|
67
|
-
#
|
68
|
-
# context "when it does exist" do
|
69
|
-
# before :each do
|
70
|
-
# system "kubectl create cm state -n default --context #{context}"
|
71
|
-
# end
|
72
|
-
#
|
73
|
-
# it "returns the configmap as a hash" do
|
74
|
-
# argue("--context #{context}")
|
75
|
-
# result = subject.get_configmap
|
76
|
-
# expect(result).to_not be_nil
|
77
|
-
# must_have = { name: "state", namespace: "default" }
|
78
|
-
# expect(result[:metadata].slice(:name, :namespace)).to eq(must_have)
|
79
|
-
# end
|
80
|
-
# end
|
81
|
-
# end
|
82
|
-
|
83
|
-
|
84
|
-
# end
|
data/spec/utils/state_utils.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
module Kerbi
|
2
|
-
module Utils
|
3
|
-
module State
|
4
|
-
def self.kubectl_get_cm(res_name, opts={})
|
5
|
-
kmd = "get configmap #{res_name} #{opts[:kubectl_args]}"
|
6
|
-
Utils::Kubectl.jkmd(kmd, **opts)
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.read_cm_data(configmap)
|
10
|
-
json_enc_vars = configmap.dig(:data, :variables) || '{}'
|
11
|
-
JSON.parse(json_enc_vars).deep_symbolize_keys
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|