kubes 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/docs/_includes/layering/layers.md +1 -1
- data/lib/kubes.rb +1 -1
- data/lib/kubes/compiler/strategy/base.rb +2 -3
- data/lib/kubes/compiler/strategy/dsl.rb +2 -2
- data/lib/kubes/compiler/strategy/erb.rb +8 -1
- data/lib/kubes/compiler/strategy/erb/yaml_error.rb +60 -0
- data/lib/kubes/compiler/util/normalize.rb +1 -1
- data/lib/kubes/compiler/util/save_file.rb +8 -0
- data/lib/kubes/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9bfe400824a8ee2877643cba9abfbd10a5e57b058e88977313457836a490c7f0
|
4
|
+
data.tar.gz: 98bff5118293f84161ed5b10b9d0162df5181b75a6dbc09dc88ed2ecd5e7029e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f3a2a36e27e2c64d5821f429368bd515c259045a26d24b8ee16713a356f53d6370938a2748bf1e65f95779936ea654547117f49bef8da2c0b435461f5456099
|
7
|
+
data.tar.gz: 9e603c401b2e9a56fc38cd1aec28d3ceaf9ff821d5add2b22bf9d8d2e5d209d7ab5609b9ab0116bd1189d5594a0e6ee00a071984605b235408ac6a0fffbeee1b
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@
|
|
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.4]
|
7
|
+
- #30 friendly message for rendered erb yaml and dsl errors
|
8
|
+
- fix backtrace_reject pattern
|
9
|
+
|
6
10
|
## [0.4.3]
|
7
11
|
- #29 fix edge case when user provides hook on option for non-kubectl hooks
|
8
12
|
|
@@ -27,7 +27,7 @@ To explain the layering, here's the general processing order that Kubes takes.
|
|
27
27
|
|
28
28
|
Note, both YAML and DSL forms support layering.
|
29
29
|
|
30
|
-
Layering only combines resources definitions with the same form. For example, `base/all.rb` will not be combined with `web/deployment.yaml`.
|
30
|
+
Layering only combines resources definitions with the same form. For example, the DSL form `base/all.rb` will not be combined with YAML form `web/deployment.yaml`.
|
31
31
|
|
32
32
|
## Full Layering
|
33
33
|
|
data/lib/kubes.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
class Kubes::Compiler::Strategy
|
2
2
|
class Base
|
3
3
|
include Kubes::Logging
|
4
|
+
include Kubes::Compiler::Util::SaveFile
|
4
5
|
|
5
6
|
def initialize(options={})
|
6
7
|
@options = options
|
7
8
|
@path = options[:path]
|
8
|
-
|
9
|
-
@filename = @path.sub(%r{.*\.kubes/resources/},'') # IE: web/deployment.rb or web/deployment.yaml
|
10
|
-
@save_file = @filename.sub('.yml','.yaml').sub('.rb','.yaml')
|
9
|
+
@save_file = save_file(@path)
|
11
10
|
end
|
12
11
|
end
|
13
12
|
end
|
@@ -17,7 +17,7 @@ class Kubes::Compiler::Strategy
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def syntax_class
|
20
|
-
klass_name = normalize_kind(@
|
20
|
+
klass_name = normalize_kind(@save_file)
|
21
21
|
"Kubes::Compiler::Dsl::Syntax::#{klass_name}".constantize
|
22
22
|
rescue NameError
|
23
23
|
logger.debug "Using default resource for: #{klass_name}"
|
@@ -25,7 +25,7 @@ class Kubes::Compiler::Strategy
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def block_form?
|
28
|
-
type = extract_type(@
|
28
|
+
type = extract_type(@save_file)
|
29
29
|
type.pluralize == type
|
30
30
|
end
|
31
31
|
end
|
@@ -32,11 +32,18 @@ class Kubes::Compiler::Strategy
|
|
32
32
|
def render_result(path)
|
33
33
|
if File.exist?(path)
|
34
34
|
yaml = RenderMePretty.result(path, context: self)
|
35
|
-
result =
|
35
|
+
result = yaml_load(path, yaml)
|
36
36
|
result.is_a?(Hash) ? result : {} # in case of blank yaml doc a Boolean false is returned
|
37
37
|
else
|
38
38
|
{}
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
def yaml_load(path, yaml)
|
43
|
+
YAML.load(yaml)
|
44
|
+
rescue Psych::SyntaxError
|
45
|
+
YamlError.new(path, yaml).show
|
46
|
+
exit 1
|
47
|
+
end
|
41
48
|
end
|
42
49
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class Kubes::Compiler::Strategy::Erb
|
2
|
+
class YamlError
|
3
|
+
include Kubes::Compiler::Util::SaveFile
|
4
|
+
|
5
|
+
def initialize(path, rendered_yaml)
|
6
|
+
@path, @rendered_yaml = path, rendered_yaml
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
FileUtils.mkdir_p(File.dirname(dest))
|
11
|
+
IO.write(dest, @rendered_yaml)
|
12
|
+
show_error(dest)
|
13
|
+
end
|
14
|
+
|
15
|
+
def dest
|
16
|
+
save_file = save_file(@path)
|
17
|
+
"#{Kubes.root}/.kubes/output/#{save_file}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def show_error(path)
|
21
|
+
text = IO.read(path)
|
22
|
+
begin
|
23
|
+
YAML.load(text)
|
24
|
+
rescue Psych::SyntaxError => e
|
25
|
+
handle_yaml_syntax_error(e, path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def handle_yaml_syntax_error(e, path)
|
30
|
+
io = StringIO.new
|
31
|
+
io.puts "Invalid yaml. Output written for debugging: #{path}".color(:red)
|
32
|
+
io.puts "ERROR: #{e.message}".color(:red)
|
33
|
+
|
34
|
+
# Grab line info. Example error:
|
35
|
+
# ERROR: (<unknown>): could not find expected ':' while scanning a simple key at line 2 column 1
|
36
|
+
md = e.message.match(/at line (\d+) column (\d+)/)
|
37
|
+
line = md[1].to_i
|
38
|
+
|
39
|
+
lines = IO.read(path).split("\n")
|
40
|
+
context = 5 # lines of context
|
41
|
+
top, bottom = [line-context-1, 0].max, line+context-1
|
42
|
+
spacing = lines.size.to_s.size
|
43
|
+
lines[top..bottom].each_with_index do |line_content, index|
|
44
|
+
line_number = top+index+1
|
45
|
+
if line_number == line
|
46
|
+
io.printf("%#{spacing}d %s\n".color(:red), line_number, line_content)
|
47
|
+
else
|
48
|
+
io.printf("%#{spacing}d %s\n", line_number, line_content)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if ENV['KUBES_TEST']
|
53
|
+
io.string
|
54
|
+
else
|
55
|
+
puts io.string
|
56
|
+
exit 1
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
data/lib/kubes/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kubes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -540,9 +540,11 @@ files:
|
|
540
540
|
- lib/kubes/compiler/strategy/base.rb
|
541
541
|
- lib/kubes/compiler/strategy/dsl.rb
|
542
542
|
- lib/kubes/compiler/strategy/erb.rb
|
543
|
+
- lib/kubes/compiler/strategy/erb/yaml_error.rb
|
543
544
|
- lib/kubes/compiler/strategy/pass.rb
|
544
545
|
- lib/kubes/compiler/strategy/result.rb
|
545
546
|
- lib/kubes/compiler/util/normalize.rb
|
547
|
+
- lib/kubes/compiler/util/save_file.rb
|
546
548
|
- lib/kubes/compiler/util/yaml_dump.rb
|
547
549
|
- lib/kubes/completer.rb
|
548
550
|
- lib/kubes/completer/script.rb
|