kubes 0.7.4 → 0.7.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -0
- data/README.md +7 -5
- data/docs/_docs/config/reference.md +1 -0
- data/docs/_docs/dsl/resources.md +1 -1
- data/docs/_docs/dsl.md +3 -3
- data/docs/_docs/intro/how-kubes-works.md +2 -0
- data/docs/_docs/intro/structure.md +2 -2
- data/docs/_docs/layering/{merge.md → merge-dsl.md} +0 -0
- data/docs/_docs/layering/merge-options.md +76 -0
- data/docs/_docs/layering.md +1 -1
- data/docs/_docs/vs/helm.md +3 -3
- data/docs/_includes/header.html +7 -0
- data/docs/_includes/layering/layers.md +12 -10
- data/docs/_includes/reference.md +1 -1
- data/docs/_includes/sidebar.html +2 -1
- data/docs/_sass/theme.scss +92 -0
- data/docs/index.html +2 -2
- data/docs/search/data.json +44 -0
- data/docs/search/index.html +30 -0
- data/docs/search/lunr.js +3475 -0
- data/docs/search/search.js +247 -0
- data/docs/search/tips.md +48 -0
- data/lib/kubes/cli/init.rb +2 -1
- data/lib/kubes/compiler/decorator/hashable/field.rb +41 -21
- data/lib/kubes/compiler/decorator/post.rb +12 -12
- data/lib/kubes/compiler/dsl/core/fields.rb +1 -1
- data/lib/kubes/compiler/dsl/syntax/resource.rb +2 -2
- data/lib/kubes/compiler/layering.rb +17 -15
- data/lib/kubes/compiler/strategy/dispatcher.rb +2 -2
- data/lib/kubes/compiler.rb +2 -1
- data/lib/kubes/config.rb +3 -0
- data/lib/kubes/core.rb +6 -0
- data/lib/kubes/docker/args/default.rb +0 -4
- data/lib/kubes/util/consider.rb +2 -2
- data/lib/kubes/version.rb +1 -1
- data/lib/templates/yaml/.kubes/resources/base/deployment.yaml.tt +0 -3
- data/lib/templates/yaml/.kubes/resources/shared/namespace.yaml.tt +0 -2
- data/spec/fixtures/decorators/deployment/configMap/volumes-name-first.yaml +14 -0
- data/spec/fixtures/decorators/deployment/configMap/volumes-name-second.yaml +14 -0
- data/spec/fixtures/decorators/ingress/tls.yaml +12 -0
- data/spec/kubes/compiler/decorator/post/deployment_spec.rb +25 -0
- data/spec/kubes/compiler/decorator/post/ingress_spec.rb +22 -0
- metadata +18 -4
@@ -0,0 +1,247 @@
|
|
1
|
+
/**
|
2
|
+
* A simple JSON search
|
3
|
+
* Requires jQuery (v 1.7+)
|
4
|
+
*
|
5
|
+
* @author Mat Hayward - Erskine Design
|
6
|
+
* @author Rishikesh Darandale <Rishikesh.Darandale@gmail.com>
|
7
|
+
* @version 1.1
|
8
|
+
*/
|
9
|
+
|
10
|
+
var q, jsonFeedUrl = "/search/data.json",
|
11
|
+
$searchForm = $("[data-search-form]"),
|
12
|
+
$searchInput = $("[data-search-input]"),
|
13
|
+
$resultTemplate = $("#search-result"),
|
14
|
+
$resultsPlaceholder = $("[data-search-results]"),
|
15
|
+
$foundContainer = $("[data-search-found]"),
|
16
|
+
$foundTerm = $("[data-search-found-term]"),
|
17
|
+
$foundCount = $("[data-search-found-count]"),
|
18
|
+
$foundWord = $("[data-search-found-word]"),
|
19
|
+
allowEmpty = true,
|
20
|
+
showLoader = true,
|
21
|
+
loadingClass = "is--loading",
|
22
|
+
indexVar;
|
23
|
+
|
24
|
+
|
25
|
+
$(document).ready( function() {
|
26
|
+
// hide items found string
|
27
|
+
$foundContainer.hide();
|
28
|
+
// initiate search functionality
|
29
|
+
initSearch();
|
30
|
+
});
|
31
|
+
|
32
|
+
function initSearch() {
|
33
|
+
if(!sessionStorage.getItem("lunrIndex")) {
|
34
|
+
// get the data
|
35
|
+
getData();
|
36
|
+
} else {
|
37
|
+
// Get search results if q parameter is set in querystring
|
38
|
+
if (getParameterByName('q')) {
|
39
|
+
q = decodeURIComponent(getParameterByName('q'));
|
40
|
+
$searchInput.val(q);
|
41
|
+
execSearch(q);
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
// Get search results on submission of form
|
46
|
+
$(document).on("submit", $searchForm, function(e) {
|
47
|
+
console.log("form submitted");
|
48
|
+
e.preventDefault();
|
49
|
+
q = $searchInput.val();
|
50
|
+
execSearch(q);
|
51
|
+
});
|
52
|
+
}
|
53
|
+
|
54
|
+
/**
|
55
|
+
* Get the JSON data
|
56
|
+
* Get the generated feeds/feed.json file so lunr.js can search it locally.
|
57
|
+
* Store the index in sessionStorage
|
58
|
+
*/
|
59
|
+
function getData(indexVar) {
|
60
|
+
jqxhr = $.getJSON(jsonFeedUrl)
|
61
|
+
.done(function(loaded_data){
|
62
|
+
// save the actual data as well
|
63
|
+
sessionStorage.setItem("actualData", JSON.stringify(loaded_data));
|
64
|
+
// set the index fields
|
65
|
+
indexVar = lunr(function () {
|
66
|
+
this.field('id');
|
67
|
+
this.field('title', { boost: 10 });
|
68
|
+
this.field('search_title', { boost: 10 });
|
69
|
+
this.field('content', { boost: 10 });
|
70
|
+
this.field('author');
|
71
|
+
loaded_data.forEach(function (doc, index) {
|
72
|
+
if ( doc.search_omit != "true" ) {
|
73
|
+
console.log("adding to index: " + doc.title);
|
74
|
+
this.add($.extend({ "id": index }, doc));
|
75
|
+
}
|
76
|
+
}, this)
|
77
|
+
});
|
78
|
+
// store the index in sessionStorage
|
79
|
+
sessionStorage.setItem("lunrIndex", JSON.stringify(indexVar));
|
80
|
+
// Get search results if q parameter is set in querystring
|
81
|
+
if (getParameterByName('q')) {
|
82
|
+
q = decodeURIComponent(getParameterByName('q'));
|
83
|
+
$searchInput.val(q);
|
84
|
+
execSearch(q);
|
85
|
+
}
|
86
|
+
})
|
87
|
+
.fail( function() {
|
88
|
+
console.log("get json failed...");
|
89
|
+
})
|
90
|
+
.always( function() {
|
91
|
+
console.log("finally...");
|
92
|
+
});
|
93
|
+
}
|
94
|
+
|
95
|
+
/**
|
96
|
+
* Get the search result from lunr
|
97
|
+
* @param {String} q
|
98
|
+
* @returns search results
|
99
|
+
*/
|
100
|
+
function getResults(q) {
|
101
|
+
var savedIndexData = JSON.parse(sessionStorage.getItem("lunrIndex"));
|
102
|
+
console.log("Indexed var from sessionStorage: " + savedIndexData);
|
103
|
+
return lunr.Index.load(savedIndexData).search(q);
|
104
|
+
}
|
105
|
+
|
106
|
+
/**
|
107
|
+
* Executes search
|
108
|
+
* @param {String} q
|
109
|
+
* @return null
|
110
|
+
*/
|
111
|
+
function execSearch(q) {
|
112
|
+
if (q != '' || allowEmpty) {
|
113
|
+
if (showLoader) {
|
114
|
+
toggleLoadingClass();
|
115
|
+
}
|
116
|
+
processResultData(getResults(q));
|
117
|
+
changeUrl("Search", "/search/?q=" + encodeURIComponent(q));
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
/**
|
122
|
+
* Toggles loading class on results and found string
|
123
|
+
* @return null
|
124
|
+
*/
|
125
|
+
function toggleLoadingClass() {
|
126
|
+
$resultsPlaceholder.toggleClass(loadingClass);
|
127
|
+
$foundContainer.toggleClass(loadingClass);
|
128
|
+
}
|
129
|
+
|
130
|
+
/**
|
131
|
+
* Process search result data
|
132
|
+
* @return null
|
133
|
+
*/
|
134
|
+
function processResultData(searchResults) {
|
135
|
+
$results = [];
|
136
|
+
|
137
|
+
console.log("Search Results: " + searchResults);
|
138
|
+
var resultsCount = 0,
|
139
|
+
results = "";
|
140
|
+
|
141
|
+
// Iterate over the results
|
142
|
+
searchResults.forEach(function(result) {
|
143
|
+
var loaded_data = JSON.parse(sessionStorage.getItem("actualData"));
|
144
|
+
var item = loaded_data[result.ref];
|
145
|
+
var result = populateResultContent($resultTemplate.html(), item);
|
146
|
+
resultsCount++;
|
147
|
+
results += result;
|
148
|
+
});
|
149
|
+
|
150
|
+
|
151
|
+
if (showLoader) {
|
152
|
+
toggleLoadingClass();
|
153
|
+
}
|
154
|
+
|
155
|
+
populateResultsString(resultsCount);
|
156
|
+
showSearchResults(results);
|
157
|
+
}
|
158
|
+
|
159
|
+
/**
|
160
|
+
* Add search results to placeholder
|
161
|
+
* @param {String} results
|
162
|
+
* @return null
|
163
|
+
*/
|
164
|
+
function showSearchResults(results) {
|
165
|
+
// Add results HTML to placeholder
|
166
|
+
$resultsPlaceholder.html(results);
|
167
|
+
}
|
168
|
+
|
169
|
+
/**
|
170
|
+
* Add results content to item template
|
171
|
+
* @param {String} html
|
172
|
+
* @param {object} item
|
173
|
+
* @return {String} Populated HTML
|
174
|
+
*/
|
175
|
+
function populateResultContent(html, item) {
|
176
|
+
var title = item.search_title || item.title
|
177
|
+
html = injectContent(html, title, '##Title##');
|
178
|
+
html = injectContent(html, item.link, '##Url##');
|
179
|
+
var content = text_truncate(item.content);
|
180
|
+
html = injectContent(html, content, '##Content##');
|
181
|
+
return html;
|
182
|
+
}
|
183
|
+
|
184
|
+
function text_truncate(str, length, ending) {
|
185
|
+
if (length == null) {
|
186
|
+
length = 255;
|
187
|
+
}
|
188
|
+
if (ending == null) {
|
189
|
+
ending = '...';
|
190
|
+
}
|
191
|
+
if (str.length > length) {
|
192
|
+
return str.substring(0, length - ending.length) + ending;
|
193
|
+
} else {
|
194
|
+
return str;
|
195
|
+
}
|
196
|
+
};
|
197
|
+
|
198
|
+
/**
|
199
|
+
* Populates results string
|
200
|
+
* @param {String} count
|
201
|
+
* @return null
|
202
|
+
*/
|
203
|
+
function populateResultsString(count) {
|
204
|
+
$foundTerm.text(q);
|
205
|
+
$foundCount.text(count);
|
206
|
+
if (count == 1)
|
207
|
+
$foundWord.text("result")
|
208
|
+
else
|
209
|
+
$foundWord.text("results")
|
210
|
+
$foundContainer.show();
|
211
|
+
}
|
212
|
+
|
213
|
+
/* ==========================================================================
|
214
|
+
Helper functions
|
215
|
+
========================================================================== */
|
216
|
+
|
217
|
+
|
218
|
+
/**
|
219
|
+
* Gets query string parameter - taken from http://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript
|
220
|
+
* @param {String} name
|
221
|
+
* @return {String} parameter value
|
222
|
+
*/
|
223
|
+
function getParameterByName(name) {
|
224
|
+
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
|
225
|
+
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
|
226
|
+
}
|
227
|
+
|
228
|
+
/**
|
229
|
+
* Injects content into template using placeholder
|
230
|
+
* @param {String} originalContent
|
231
|
+
* @param {String} injection
|
232
|
+
* @param {String} placeholder
|
233
|
+
* @return {String} injected content
|
234
|
+
*/
|
235
|
+
function injectContent(originalContent, injection, placeholder) {
|
236
|
+
var regex = new RegExp(placeholder, 'g');
|
237
|
+
return originalContent.replace(regex, injection);
|
238
|
+
}
|
239
|
+
|
240
|
+
function changeUrl(page, url) {
|
241
|
+
if (typeof(window.history.pushState) != "undefined") {
|
242
|
+
var obj = { Page: page, Url: url };
|
243
|
+
window.history.pushState(obj, obj.Page, obj.Url);
|
244
|
+
} else {
|
245
|
+
console.log("Browser does not support HTML5.");
|
246
|
+
}
|
247
|
+
}
|
data/docs/search/tips.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
title: Search Tips
|
3
|
+
---
|
4
|
+
|
5
|
+
Here are some useful search tips that can help to make searching more effective.
|
6
|
+
|
7
|
+
## OR Searches
|
8
|
+
|
9
|
+
By default, searches for multiple terms are combined with OR. If a document matches at least one of the search terms, it will show in the results. So:
|
10
|
+
|
11
|
+
install aws
|
12
|
+
|
13
|
+
Will always result in more results just `install` by itself.
|
14
|
+
|
15
|
+
|
16
|
+
## AND Searches
|
17
|
+
|
18
|
+
To do an AND search of "install AND aws" mark both terms as required, you use a `+` sign in front of each term. Example:
|
19
|
+
|
20
|
+
+install +aws
|
21
|
+
|
22
|
+
This results in pages only with both exactly install and aws.
|
23
|
+
|
24
|
+
## Filter Terms
|
25
|
+
|
26
|
+
To filter "keywords", you use a `-` sign in front of each term. Example:
|
27
|
+
|
28
|
+
+install -aws
|
29
|
+
|
30
|
+
This results in pages only with install but filter or reject any pages with aws.
|
31
|
+
|
32
|
+
## Wildcard
|
33
|
+
|
34
|
+
You can use wildcards:
|
35
|
+
|
36
|
+
install*
|
37
|
+
|
38
|
+
## Fields
|
39
|
+
|
40
|
+
You can target specific fields:
|
41
|
+
|
42
|
+
title:install
|
43
|
+
|
44
|
+
For fields see: [search data.json]({% link search/data.json %})
|
45
|
+
|
46
|
+
## More Tips
|
47
|
+
|
48
|
+
More search tips can be found at: [lunrjs searching](https://lunrjs.com/guides/searching.html)
|
data/lib/kubes/cli/init.rb
CHANGED
@@ -86,10 +86,11 @@ class Kubes::CLI
|
|
86
86
|
ignores = %w[
|
87
87
|
.kubes/output
|
88
88
|
.kubes/state
|
89
|
+
.kubes/tmp
|
89
90
|
].map {|l| "#{l}\n"} # the readlines will have lines with \n so keep consistent for processing
|
90
91
|
if File.exist?(".gitignore")
|
91
92
|
lines = IO.readlines(".gitignore")
|
92
|
-
if lines.detect { |l| l.include?('.kubes/
|
93
|
+
if lines.detect { |l| l.include?('.kubes/tmp') }
|
93
94
|
return # early
|
94
95
|
else
|
95
96
|
lines += ignores
|
@@ -1,52 +1,72 @@
|
|
1
1
|
class Kubes::Compiler::Decorator::Hashable
|
2
2
|
class Field
|
3
|
-
# item is full
|
3
|
+
# item is full structure
|
4
4
|
#
|
5
|
-
# secretRef:
|
6
|
-
# name: demo-secret
|
5
|
+
# secretRef: <--- wrapper_key
|
6
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
7
7
|
#
|
8
|
+
attr_reader :item # for debugging
|
8
9
|
def initialize(item)
|
9
10
|
@item = item
|
10
11
|
end
|
11
12
|
|
12
13
|
def hashable?
|
13
|
-
x = @item.keys &
|
14
|
+
x = @item.keys & wrapper_map.keys
|
14
15
|
!x.empty?
|
15
16
|
end
|
16
17
|
|
17
18
|
def kind
|
18
|
-
|
19
|
+
wrapper_key =~ /configMap/ ? "ConfigMap" : "Secret"
|
19
20
|
end
|
20
21
|
|
21
|
-
# The key of the hashable value
|
22
|
+
# The target key of the hashable value is that key used for find value to add hash
|
22
23
|
#
|
23
24
|
# envFrom:
|
24
|
-
# - secretRef:
|
25
|
-
# name: demo-secret <---
|
25
|
+
# - secretRef: <--- wrapper_key
|
26
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
26
27
|
#
|
27
|
-
def
|
28
|
-
|
28
|
+
def target_key
|
29
|
+
wrapper_map[wrapper_key]
|
29
30
|
end
|
30
31
|
|
31
32
|
# The wrapper field is nested right above the item with the hashable value.
|
33
|
+
# Simple example:
|
32
34
|
#
|
33
35
|
# envFrom:
|
34
|
-
# - secretRef:
|
35
|
-
# name: demo-secret
|
36
|
+
# - secretRef: <--- wrapper_key
|
37
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
36
38
|
#
|
37
|
-
|
38
|
-
|
39
|
+
# More complex example where there's a configMap.name key also on the same level.
|
40
|
+
#
|
41
|
+
# volumes:
|
42
|
+
# - name: config-map-volume
|
43
|
+
# configMap:
|
44
|
+
# name: demo-config-map
|
45
|
+
#
|
46
|
+
# Note: Wont work for case when there's are 2 matching wrapper_map keys,
|
47
|
+
# but don't think Kubernetes allows 2 matching wrapper_map keys.
|
48
|
+
# Example: This is invalid Kubernetes YAML.
|
49
|
+
#
|
50
|
+
# volumes:
|
51
|
+
# - name: config-map-volume
|
52
|
+
# configMap:
|
53
|
+
# name: demo-config-map
|
54
|
+
# secretRef:
|
55
|
+
# name: demo-seret
|
56
|
+
def wrapper_key
|
57
|
+
@item.keys.find { |k| wrapper_map.keys.include?(k) } # this key used for map[wrapper_key]
|
39
58
|
end
|
40
59
|
|
41
60
|
# wrapper element to key that stores the hashable value
|
42
|
-
def
|
61
|
+
def wrapper_map
|
43
62
|
{
|
44
|
-
'configMapRef' => 'name',
|
45
|
-
'configMapKeyRef' => 'name',
|
46
|
-
'configMap' => 'name',
|
47
|
-
'secretRef' => 'name',
|
48
|
-
'secretKeyRef' => 'name',
|
49
|
-
'secret' => 'secretName',
|
63
|
+
'configMapRef' => 'name', # containers.env.envFrom.configMapRef.name
|
64
|
+
'configMapKeyRef' => 'name', # containers.env.valueFrom.configMapKeyRef.name
|
65
|
+
'configMap' => 'name', # containers.env.envFrom.configMapRef.name
|
66
|
+
'secretRef' => 'name', # containers.env.envFrom.secretRef.name
|
67
|
+
'secretKeyRef' => 'name', # containers.env.valueFrom.secretKeyRef.name
|
68
|
+
'secret' => 'secretName', # volumes.secret.secretName
|
69
|
+
'tls' => 'secretName', # tls.secretName
|
50
70
|
}
|
51
71
|
end
|
52
72
|
end
|
@@ -16,12 +16,12 @@ module Kubes::Compiler::Decorator
|
|
16
16
|
# hashable set from previous stack call
|
17
17
|
if options[:hashable_field] && item.is_a?(Hash)
|
18
18
|
field = options[:hashable_field]
|
19
|
-
value_without_md5 = item[field.
|
19
|
+
value_without_md5 = item[field.target_key]
|
20
20
|
@reset_hashable_field = true unless value_without_md5
|
21
21
|
if field.hashable? && value_without_md5
|
22
22
|
md5 = Hashable::Storage.fetch(field.kind, value_without_md5)
|
23
23
|
v = [value_without_md5, md5].compact.join('-')
|
24
|
-
item[field.
|
24
|
+
item[field.target_key] = v
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,10 +29,10 @@ module Kubes::Compiler::Decorator
|
|
29
29
|
# Pretty tricky case. Given:
|
30
30
|
#
|
31
31
|
# envFrom:
|
32
|
-
# - secretRef:
|
33
|
-
# name: demo-secret
|
34
|
-
# - configMapRef:
|
35
|
-
# name: demo-config-map
|
32
|
+
# - secretRef: <--- wrapper_key
|
33
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
34
|
+
# - configMapRef: <--- wrapper_key
|
35
|
+
# name: demo-config-map <--- target_key is 'name' from wrapper_map[wrapper_key]
|
36
36
|
#
|
37
37
|
# Need to reset the stored hashable_field in the call stack.
|
38
38
|
# Else the field.kind is cached and the md5 look is incorrect
|
@@ -52,19 +52,19 @@ module Kubes::Compiler::Decorator
|
|
52
52
|
#
|
53
53
|
# 1. envFrom example
|
54
54
|
# envFrom:
|
55
|
-
# - secretRef:
|
56
|
-
# name: demo-secret
|
55
|
+
# - secretRef: <--- wrapper_key
|
56
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
57
57
|
#
|
58
58
|
# 2. valueFrom example
|
59
59
|
# valueFrom:
|
60
|
-
# secretKeyRef:
|
61
|
-
# name: demo-secret
|
60
|
+
# secretKeyRef: <--- wrapper_key
|
61
|
+
# name: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
62
62
|
# key: password
|
63
63
|
#
|
64
64
|
# 3. volumes example
|
65
65
|
# volumes:
|
66
|
-
# - secret:
|
67
|
-
# secretName: demo-secret
|
66
|
+
# - secret: <--- wrapper_key
|
67
|
+
# secretName: demo-secret <--- target_key is 'name' from wrapper_map[wrapper_key]
|
68
68
|
#
|
69
69
|
# This is useful to capture for the next level of the stack call
|
70
70
|
#
|
@@ -64,7 +64,7 @@ module Kubes::Compiler::Dsl::Core
|
|
64
64
|
result = instance_variable_get(ivar)
|
65
65
|
result = {} if mode == "reset" # allow user to override with mode: reset option
|
66
66
|
result ||= {} # maintain value for layering
|
67
|
-
|
67
|
+
Kubes.deep_merge!(result, value)
|
68
68
|
instance_variable_set(ivar, result)
|
69
69
|
end
|
70
70
|
end
|
@@ -18,7 +18,7 @@ module Kubes::Compiler::Dsl::Syntax
|
|
18
18
|
# top-level of resource is quite common
|
19
19
|
def default_result
|
20
20
|
data = top.merge(default_top)
|
21
|
-
|
21
|
+
Kubes.deep_merge!(data, default_result_append)
|
22
22
|
data.deep_stringify_keys!
|
23
23
|
HashSqueezer.squeeze(data)
|
24
24
|
end
|
@@ -63,7 +63,7 @@ module Kubes::Compiler::Dsl::Syntax
|
|
63
63
|
|
64
64
|
# For generic kind
|
65
65
|
def field(name, data)
|
66
|
-
|
66
|
+
Kubes.deep_merge!(top, {name => data})
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -6,29 +6,21 @@ class Kubes::Compiler
|
|
6
6
|
ext = File.extname(@path)
|
7
7
|
kind = File.basename(@path).sub(ext,'') # IE: deployment
|
8
8
|
kind = kind.pluralize if @block_form
|
9
|
+
role = @path.split('/')[-2] # .kubes/resources/web/deployment.yaml
|
9
10
|
layers = [
|
10
|
-
"all",
|
11
|
-
"all/#{Kubes.env}",
|
12
|
-
"
|
13
|
-
"
|
11
|
+
"base/all",
|
12
|
+
"base/all/#{Kubes.env}",
|
13
|
+
"base/#{kind}",
|
14
|
+
"base/#{kind}/#{Kubes.env}",
|
15
|
+
"#{role}/all",
|
14
16
|
]
|
15
17
|
layers = add_exts(layers)
|
16
18
|
layers.map! do |layer|
|
17
|
-
"#{Kubes.root}/.kubes/resources
|
19
|
+
"#{Kubes.root}/.kubes/resources/#{layer}"
|
18
20
|
end
|
19
21
|
layers.select { |layer| File.exist?(layer) }
|
20
22
|
end
|
21
23
|
|
22
|
-
def add_exts(layers)
|
23
|
-
layers.map do |layer|
|
24
|
-
[
|
25
|
-
"#{layer}.rb",
|
26
|
-
"#{layer}.yaml",
|
27
|
-
"#{layer}.yml",
|
28
|
-
]
|
29
|
-
end.flatten
|
30
|
-
end
|
31
|
-
|
32
24
|
def post_layers
|
33
25
|
return [] if Kubes.kustomize?
|
34
26
|
|
@@ -45,5 +37,15 @@ class Kubes::Compiler
|
|
45
37
|
end
|
46
38
|
layers.select { |layer| File.exist?(layer) }
|
47
39
|
end
|
40
|
+
|
41
|
+
def add_exts(*layers)
|
42
|
+
layers.flatten.map do |layer|
|
43
|
+
[
|
44
|
+
"#{layer}.rb",
|
45
|
+
"#{layer}.yaml",
|
46
|
+
"#{layer}.yml",
|
47
|
+
]
|
48
|
+
end.flatten
|
49
|
+
end
|
48
50
|
end
|
49
51
|
end
|
@@ -4,8 +4,8 @@ class Kubes::Compiler::Strategy
|
|
4
4
|
result = render(@path) # main
|
5
5
|
results = [result].flatten # ensure array
|
6
6
|
data = results.map! do |main|
|
7
|
-
hash =
|
8
|
-
|
7
|
+
hash = Kubes.deep_merge!(pre_layer, main)
|
8
|
+
Kubes.deep_merge!(hash, post_layer)
|
9
9
|
end
|
10
10
|
Result.new(@save_file, data)
|
11
11
|
end
|
data/lib/kubes/compiler.rb
CHANGED
@@ -57,7 +57,8 @@ module Kubes
|
|
57
57
|
acc << IO.read(file)
|
58
58
|
end
|
59
59
|
content = full.join("\n")
|
60
|
-
path = "#{Kubes.root}/.kubes/
|
60
|
+
path = "#{Kubes.root}/.kubes/tmp/full.yaml" # write to tmp instead of output so it doesnt interfere with kubes get
|
61
|
+
FileUtils.mkdir_p(File.dirname(path))
|
61
62
|
IO.write(path, content)
|
62
63
|
logger.debug "Compiled #{pretty(path)}"
|
63
64
|
end
|
data/lib/kubes/config.rb
CHANGED
data/lib/kubes/core.rb
CHANGED
@@ -34,5 +34,11 @@ module Kubes
|
|
34
34
|
logger.error "ERROR: It doesnt look like this is a kubes project. Are you sure you are in a kubes project?".color(:red)
|
35
35
|
ENV['TS_TEST'] ? raise : exit(1)
|
36
36
|
end
|
37
|
+
|
38
|
+
# wrapper to ensure we use the same deeper_merge options everywhere
|
39
|
+
def deep_merge!(a, b)
|
40
|
+
a.deeper_merge!(b, config.merger.options)
|
41
|
+
a
|
42
|
+
end
|
37
43
|
end
|
38
44
|
end
|
data/lib/kubes/util/consider.rb
CHANGED
data/lib/kubes/version.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
# apiVersion: apps/v1
|
3
|
+
# kind: Deployment
|
4
|
+
# spec:
|
5
|
+
# template:
|
6
|
+
# spec:
|
7
|
+
# only including structure needed for spec
|
8
|
+
volumes:
|
9
|
+
- name: config-map-volume
|
10
|
+
configMap:
|
11
|
+
name: demo-config-map
|
12
|
+
items:
|
13
|
+
- key: k1
|
14
|
+
path: config-map.conf
|
@@ -0,0 +1,14 @@
|
|
1
|
+
---
|
2
|
+
# apiVersion: apps/v1
|
3
|
+
# kind: Deployment
|
4
|
+
# spec:
|
5
|
+
# template:
|
6
|
+
# spec:
|
7
|
+
# only including structure needed for spec
|
8
|
+
volumes:
|
9
|
+
- configMap:
|
10
|
+
name: demo-config-map
|
11
|
+
items:
|
12
|
+
- key: k1
|
13
|
+
path: config-map.conf
|
14
|
+
name: config-map-volume
|