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.
Files changed (82) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cli/base_handler.rb +180 -0
  3. data/lib/cli/base_serializer.rb +120 -0
  4. data/lib/cli/config_handler.rb +51 -0
  5. data/lib/cli/entry_serializers.rb +99 -0
  6. data/lib/cli/project_handler.rb +2 -2
  7. data/lib/cli/root_handler.rb +32 -13
  8. data/lib/cli/state_handler.rb +95 -0
  9. data/lib/cli/values_handler.rb +4 -3
  10. data/lib/config/cli_schema.rb +299 -27
  11. data/lib/config/config_file.rb +60 -0
  12. data/lib/config/globals.rb +4 -0
  13. data/lib/config/run_opts.rb +150 -0
  14. data/lib/config/state_consts.rb +10 -0
  15. data/lib/kerbi.rb +31 -9
  16. data/lib/main/errors.rb +109 -0
  17. data/lib/main/mixer.rb +12 -8
  18. data/lib/mixins/cli_state_helpers.rb +136 -0
  19. data/lib/mixins/cm_backend_testing.rb +95 -0
  20. data/lib/mixins/entry_tag_logic.rb +183 -0
  21. data/lib/state/base_backend.rb +59 -0
  22. data/lib/state/config_map_backend.rb +119 -0
  23. data/lib/state/entry.rb +173 -0
  24. data/lib/state/entry_set.rb +137 -0
  25. data/lib/state/metadata.yaml.erb +11 -0
  26. data/lib/state/mixers.rb +23 -0
  27. data/lib/state/resources.yaml.erb +17 -0
  28. data/lib/utils/cli.rb +77 -10
  29. data/lib/utils/helm.rb +10 -12
  30. data/lib/utils/k8s_auth.rb +87 -0
  31. data/lib/utils/misc.rb +36 -1
  32. data/lib/utils/mixing.rb +1 -1
  33. data/lib/utils/values.rb +13 -22
  34. data/spec/cli/config_handler_spec.rb +38 -0
  35. data/spec/cli/root_handler_spec.rb +99 -0
  36. data/spec/cli/state_handler_spec.rb +139 -0
  37. data/spec/cli/values_handler_spec.rb +17 -0
  38. data/spec/expectations/common/bad-tag.txt +1 -0
  39. data/spec/expectations/config/bad-set.txt +1 -0
  40. data/spec/expectations/config/set.txt +1 -0
  41. data/spec/expectations/config/show-default.yaml +6 -0
  42. data/spec/expectations/root/template-inlines.yaml +31 -0
  43. data/spec/expectations/root/template-production.yaml +31 -0
  44. data/spec/expectations/root/template-read-inlines.yaml +31 -0
  45. data/spec/expectations/root/template-read.yaml +31 -0
  46. data/spec/expectations/root/template-write.yaml +31 -0
  47. data/spec/expectations/root/template.yaml +31 -0
  48. data/spec/expectations/root/values.json +28 -0
  49. data/spec/expectations/state/delete.txt +1 -0
  50. data/spec/expectations/state/demote.txt +1 -0
  51. data/spec/expectations/state/init-already-existed.txt +2 -0
  52. data/spec/expectations/state/init-both-created.txt +2 -0
  53. data/spec/expectations/state/list.json +51 -0
  54. data/spec/expectations/state/list.txt +6 -0
  55. data/spec/expectations/state/list.yaml +35 -0
  56. data/spec/expectations/state/promote.txt +1 -0
  57. data/spec/expectations/state/prune-candidates.txt +1 -0
  58. data/spec/expectations/state/retag.txt +1 -0
  59. data/spec/expectations/state/set.txt +1 -0
  60. data/spec/expectations/state/show.json +13 -0
  61. data/spec/expectations/state/show.txt +13 -0
  62. data/spec/expectations/state/show.yaml +8 -0
  63. data/spec/expectations/state/status-all-working.txt +4 -0
  64. data/spec/expectations/state/status-not-provisioned.txt +4 -0
  65. data/spec/expectations/values/order-of-precedence.yaml +4 -0
  66. data/spec/main/configmap_backend_spec.rb +109 -0
  67. data/spec/main/state_entry_set_spec.rb +112 -0
  68. data/spec/main/state_entry_spec.rb +109 -0
  69. data/spec/spec_helper.rb +87 -1
  70. data/spec/utils/helm_spec.rb +1 -21
  71. data/spec/utils/k8s_auth_spec.rb +32 -0
  72. data/spec/utils/misc_utils_spec.rb +9 -0
  73. data/spec/utils/values_utils_spec.rb +12 -19
  74. metadata +114 -13
  75. data/lib/cli/base.rb +0 -83
  76. data/lib/config/cli_opts.rb +0 -50
  77. data/lib/config/manager.rb +0 -36
  78. data/lib/main/state_manager.rb +0 -47
  79. data/lib/utils/kubectl.rb +0 -58
  80. data/spec/main/examples_spec.rb +0 -12
  81. data/spec/main/state_manager_spec.rb +0 -84
  82. 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
@@ -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