Skip to content

Commit f3c8292

Browse files
committed
use jrsonnet if available
1 parent bf68deb commit f3c8292

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

gen-k8s.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
require 'json'
44
require 'tmpdir'
55

6+
7+
jsonnet = system('jrsonnet', '--help', out: File::NULL, err: [:child, :out]) ? 'jrsonnet' : 'jsonnet'
8+
69
Dir.chdir(__dir__)
710
tmpdir = Dir.mktmpdir
811

@@ -12,7 +15,7 @@
1215
FileUtils.mkdir_p File.dirname(dst)
1316

1417
File.open(dst, 'w') do |io|
15-
system('jsonnet', src, out: io, exception: true)
18+
system(jsonnet, src, out: io, exception: true)
1619
end
1720

1821
out = JSON.parse(File.read(dst))

tf/jsonnet.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
require 'json'
2121
require 'tempfile'
2222

23+
jsonnet = system('jrsonnet', '--help', out: File::NULL, err: [:child, :out]) ? 'jrsonnet' : 'jsonnet'
2324
query = JSON.load($stdin)
2425

2526
Tempfile.open do |output|
@@ -28,12 +29,12 @@
2829
end
2930

3031
if path = query['path']
31-
exit $?.to_i unless system('jsonnet', *tla, path, out: output)
32+
exit $?.to_i unless system(jsonnet, *tla, path, out: output)
3233
else
3334
Tempfile.open do |input|
3435
input.write(query.fetch('input'))
3536

36-
exit $?.to_i unless system('jsonnet', *tla, '-', in: input.tap(&:rewind), out: output)
37+
exit $?.to_i unless system(jsonnet, *tla, '-', in: input.tap(&:rewind), out: output)
3738
end
3839
end
3940

0 commit comments

Comments
 (0)