kustomizer 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5b88c7e828be9c93ec00ef81cd1fa0b583f2772c6b621cfab5ce0e422418d49c
4
- data.tar.gz: a08c5c25f4c234ea9b698d64e6f327a5e3a17147d1cf17c613471fcf0f32a7cf
3
+ metadata.gz: 961ff655cafb23672a01fae7147f08a28d4198a59f72a07c092cfd8907acb98f
4
+ data.tar.gz: fdafe50e353de94b2105fa754a31ff6a40b347585f1d0359924410581ffa7b58
5
5
  SHA512:
6
- metadata.gz: 42ecbbe674b0b4f49c434457f99cc43084e4c6d432789d15ac4a3081e345a5dda6b459ca1db1f15057f2279f3b00454dd46e5d350a4c60fe0e391495c26d5952
7
- data.tar.gz: dbb5dbbca1c1b1ae4e95584fb9601284b5f8c3f73a2b4ba15f02d4f1bf382634d87e86632ec7319e90761beb6de8ef8cc946909531718df4bfeff3a9793351fd
6
+ metadata.gz: 60136761417e2ddcdeef7af0e1fb8898ba1cdb95b62e638e0355fba04af252c9b14fce85801f924109ebbae4be01f19e83a3b9795dbb29a9ea49303e71f62bfa
7
+ data.tar.gz: 1bce76a9ccb5549dc71e3bf1acb0a8c26f0ded8c0a785332f6d72c77d81fffc71ec9629fa593462312fe67bee80ffb19c5b78d792b5e6e3b3f02b0e39d805e93
@@ -1,13 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- kustomizer (0.1.0)
4
+ kustomizer (0.1.1)
5
5
  accessory (~> 0.1.9)
6
+ base32-multi
6
7
 
7
8
  GEM
8
9
  remote: https://rubygems.org/
9
10
  specs:
10
11
  accessory (0.1.9)
12
+ base32-multi (0.1.1)
11
13
  diff-lcs (1.4.4)
12
14
  rake (13.0.3)
13
15
  rspec (3.10.0)
data/README.md CHANGED
@@ -9,9 +9,14 @@ the user to have the native Go version of Kustomize installed.
9
9
  ## Roadmap
10
10
 
11
11
  KustomizeR is **not yet feature-complete**, i.e. it does not yet do everything
12
- that Kustomize does.
12
+ that Kustomize does. KustomizeR probably won't work for arbitrary
13
+ `kustomization.yaml` files.
13
14
 
14
- Status of `kustomization.yaml` support:
15
+ (KustomizeR *is*, however, in production use; it is being used with
16
+ `kustomization.yaml` files matching its current feature set. We wrote Just
17
+ Enough Library to solve our own problems :wink:)
18
+
19
+ Status of `kustomization.yaml` feature support:
15
20
 
16
21
  * [x] `bases`
17
22
  * [ ] `commonAnnotations`
@@ -31,7 +36,7 @@ Status of `kustomization.yaml` support:
31
36
  * [ ] `transformers` (see [Extending Kustomize](https://kubectl.docs.kubernetes.io/guides/extending_kustomize/))
32
37
  * [ ] `vars`
33
38
 
34
- Status of support for other features:
39
+ Status of support for other Kustomize features:
35
40
 
36
41
  * [ ] Resource loading
37
42
  * [x] resource-config files on disk
@@ -44,6 +49,15 @@ Status of support for other features:
44
49
  * [x] Secrets
45
50
  * [ ] ConfigMaps
46
51
 
52
+ Status of support for "extra" features not supported by Kustomize:
53
+
54
+ * [ ] `filters` (a plugin-type for dropping resource-configs from output)
55
+ * [ ] `rewriters` (a plugin-type for entirely replacing output; takes all
56
+ intermediate resource-config docs as a single input)
57
+ * [ ] Built-in plugins:
58
+ * [ ] `SealedSecretGenerator`
59
+ * [ ] `DerivedSecretGenerator`
60
+
47
61
  #### Differences from Kustomize
48
62
 
49
63
  * KustomizeR is **not yet feature-complete**. (KustomizeR will be bumped to
@@ -55,12 +69,16 @@ Status of support for other features:
55
69
  * KustomizeR is modular, and is intended to be loaded and used as a library,
56
70
  rather than being spawned as a subprocess. Crucially, the load path for
57
71
  plugins is under the caller's control, and so higher-level frameworks can
58
- manage project-level KustomizeR plugins.
72
+ inject plugins into a KustomizeR session to suit their needs.
59
73
 
60
74
  * Some `kustomization.yaml` features have been temporarily extended in
61
- non-compatible ways.
62
- * `patchesJson6902` accepts an inline an `ops` array
63
- * `patchesJson6902` accepts a `gsub` op
75
+ non-compatible ways:
76
+ * `patchesJson6902`
77
+ * accepts an inline `ops` array
78
+ * accepts lens accessor names in `path` (e.g. `/spec/rules/:all/host`)
79
+ * accepts a `paths` array rather than a single `path`
80
+ * accepts a `gsub` op (works like `replace` but with a regular expression;
81
+ has `pattern` and `replacement` fields)
64
82
 
65
83
  (Before v1.0, these extensions will be moved to become built-in plugins, to
66
84
  allow for inter-compatibility with Kustomize, which could support them as
@@ -86,12 +104,114 @@ Or install it yourself as:
86
104
 
87
105
  ```ruby
88
106
  require 'kustomize'
107
+ ```
108
+
109
+ ### Loading Kustomization documents
110
+
111
+ You can either load a `kustomization.yaml` file by specifying its path:
112
+
113
+ ```ruby
89
114
  k = Kustomize.load("./path/to/kustomization.yaml")
90
115
 
91
- k.emit # Array of Hashes (the final resource-configs)
92
- k.to_yaml_stream # String (merged YAML multi-document stream)
116
+ # equivalent; discovers the kustomization.yaml within the directory
117
+ k = Kustomize.load("./path/to")
93
118
  ```
94
119
 
120
+ Or you can load a `Kustomization` document spec directly:
121
+
122
+ ```ruby
123
+ k_doc = {
124
+ 'apiVersion' => 'kustomize.config.k8s.io/v1beta1',
125
+ 'kind' => 'Kustomization',
126
+ # ...
127
+ }
128
+
129
+ k = Kustomization.load(k_doc, source_path: "./path/to/kustomization.yaml")
130
+ ```
131
+
132
+ Note the `source_path` keyword parameter. Specifying a `source_path` for an
133
+ in-memory Kustomization document is optional, but will usually be necessary, as
134
+ the Kustomization document will need an effective path for itself, to use as a
135
+ relative navigation prefix for any referenced on-disk resource files/directories.
136
+
137
+ The `source_path` can be left out if all the resources a Kustomization document
138
+ references are either remote or generated.
139
+
140
+ ### Rendering resource-configuration documents
141
+
142
+ To get the final resource-configurations directly, as an Array of Hashes, call
143
+ `KustomizationDocument#emit`:
144
+
145
+ ```ruby
146
+ k.emit # => [{'kind' => 'Deployment', ...}, ...]
147
+ ```
148
+
149
+ Or, to get a merged YAML multi-document stream suitable for feeding to
150
+ `kubectl apply -f`, call `KustomizationDocument#to_yaml_stream`:
151
+
152
+ ```ruby
153
+ k.to_yaml_stream # => "---\nkind: Deployment\n..."
154
+ ```
155
+
156
+ ### Accessing intermediate resources
157
+
158
+ KustomizeR represents your Kustomization document as a digraph of `Emitter`
159
+ instances, a combination of `FileEmitter`s, `DirectoryEmitter`s,
160
+ `DocumentEmitter`s, and `PluginEmitter`s. You can think of these as being
161
+ arranged akin to an audio VST digraph, where emitters are "plugged into" other
162
+ downstream emitters, with the outputs (resource configs) of one emitter becoming
163
+ inputs to another.
164
+
165
+ All `Emitter` types support the following methods:
166
+
167
+ ```ruby
168
+ e.input_emitters # gets the emitters that feed their output into this emitter
169
+
170
+ e.input_resources # runs the input emitters, gathering their outputs and
171
+ # caching it as this emitter's input
172
+
173
+ e.emit # runs this emitter, producing the output that would be fed
174
+ # into any downstream emitters
175
+ ```
176
+
177
+ A `KustomizationDocument` constructed by `Kustomize.load` is just a regular
178
+ `Emitter`; you can use it as the starting point to explore or manipulate the
179
+ rest of the `Emitter` graph.
180
+
181
+ ### Sessions
182
+
183
+ All emitters belong to a `Kustomize::Session`. When you call `Kustomize.load`,
184
+ you pass in (or implicitly create) a new `Kustomize::Session`:
185
+
186
+ ```ruby
187
+ Kustomize.load("./foo", session: Kustomize::Session.new)
188
+ Kustomize.load("./foo") # equivalent to above
189
+ ```
190
+
191
+ #### Plugin Load-Paths
192
+
193
+ The `Kustomize::Session` manages plugin load-paths. By default, it defines a
194
+ load-path referencing only the built-in plugins embedded within this gem.
195
+
196
+ You can create your own subclass of `Kustomize::Session` to define a new
197
+ load-path, and pass in an instance of it as the `session` keyword-parameter
198
+ to `Kustomize.load`. This custom Session will be inherited by all `Emitter`s
199
+ created under the loaded `KustomizeDocument` emitter.
200
+
201
+ You can also add other features to your `Kustomize::Session` subclass. The
202
+ passed-in `Session` is accessible within `Kustomize::Plugin`s as
203
+ `this.session`, so it can be useful to pass e.g. a framework context object as
204
+ a member of your `Kustomize::Session` subclass, for use by framework-specific
205
+ plugins.
206
+
207
+ #### Plugin Discovery and Loading
208
+
209
+ The `Kustomize::Session` also holds an instance of `Kustomize::PluginManager`,
210
+ which discovers, loads, and caches plugins.
211
+
212
+ As such, if you're calling `Kustomize.load` a lot, it is recommended to reuse
213
+ your `Kustomize::Session`, so that plugins need only be discovered+loaded once.
214
+
95
215
  ## Development
96
216
 
97
217
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -25,4 +25,5 @@ Gem::Specification.new do |spec|
25
25
  spec.require_paths = ["lib"]
26
26
 
27
27
  spec.add_runtime_dependency "accessory", "~> 0.1.9"
28
+ spec.add_runtime_dependency "base32-multi"
28
29
  end
@@ -1,3 +1,3 @@
1
1
  module Kustomize
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kustomizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Levi Aul
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.1.9
27
+ - !ruby/object:Gem::Dependency
28
+ name: base32-multi
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: A pure-ruby implementation of the Kubernetes 'kustomize' command.
28
42
  email:
29
43
  - levi@leviaul.com