minfra-cli 1.7.1 → 1.9.0

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: 2a48cc8f6178ef5a337fbaa5c7d26b17ae22e699c91c35e4b6835da9ea489183
4
- data.tar.gz: fbcc714995a34fd2bf63aa48c09166d0f85c6a5f40495472f1cc7b96f7cf95a2
3
+ metadata.gz: f850f6ee46b5749af756bfb223e38836a3bc538dc8bcbe4b1f2fb3bc2c3a131a
4
+ data.tar.gz: e5b4b5b317c1ead81fedae5d78021003c31a55858fe36e040fad59c61d8e8c23
5
5
  SHA512:
6
- metadata.gz: e37680916acd863645042a241853cbdefef19aeaff358a5196f0068fb3be81604bab7c59a11fff19fa13e5e0b8ed5d153f20c88aebdabbad4e6aea2ddcd1c331
7
- data.tar.gz: d395137f217d52837983604bd590c1a2ef813446ff27c7ada4e26575690f42b448d4623fe248825482a8ca569130e87d6ae2c4ee10665a1c9c9fb58a24684398
6
+ metadata.gz: 26036eb5236bedf5a6cf6f3a39b8ceb272d8242938bf1730c20b0385facb0c1c9c1c8c92335c670562b5bd3dc946eae7e5891963b38643e0144f2b5ed5b8d3d3
7
+ data.tar.gz: 47cba9834d267496e5411d9d326a3a5d8899cb8a06119bbcafa790fdef48fd22ee620eea43725b706627efc59bdfb0db03fa93a0950de5f913476a81a46054eb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,16 @@
1
+ # 1.9.0
2
+ * helm template now called with --debug
3
+ * added "file" to service
4
+ * ready for ruby 3.2
5
+ * fixing project build "loading int " typo
6
+ * changing init sequence (first load minfrarc)
7
+ * STDERR of external commands is now written as INFO
8
+
9
+ # 1.8.0
10
+ * more output which "require" failed when loading dependencies
11
+ * catching closed stream errors in Minfra::Cli::Runner
12
+ * stderr of runner goes to info
13
+ * stdout of runner goes to debug
1
14
  # 1.7.1
2
15
  * fix plugin install edge cases
3
16
  # 1.7.0
@@ -40,7 +40,7 @@ module Minfra
40
40
  ARGV.delete('project') # ARGV is passed along to `rspec` call
41
41
  ARGV.delete('test')
42
42
 
43
- if File.exists?('./bin/run_tests')
43
+ if File.exist?('./bin/run_tests')
44
44
  # config = Config.load('staging')
45
45
  project = ProjectInfo.load(Pathname.pwd)
46
46
  # Minfra::Cli::Document.document(config, "Using project specific ./bin/run_tests in #{project.name}")
@@ -68,7 +68,7 @@ module Minfra
68
68
  exit(1) if res.error?
69
69
 
70
70
  unless options[:noload]
71
- debug("loading int KIND")
71
+ debug("loading image into KIND's registry")
72
72
  Runner.run(%{kind load docker-image #{p.repo_name}:latest --name #{minfra_config.name}})
73
73
  end
74
74
  end
@@ -49,7 +49,7 @@ module Minfra
49
49
  begin
50
50
  require minfra_path # this should register the command
51
51
  rescue LoadError
52
- logger.warn("Minfra plugin detected but dependencies not installed: #{minfra_path} (try: minfra plugin install)")
52
+ logger.warn("Minfra plugin detected but dependencies not installed: #{minfra_path} (#{$!}). TRY: minfra plugin install")
53
53
  end
54
54
  end
55
55
  else
@@ -1,3 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'English'
1
4
  require 'open3'
2
5
 
3
6
  module Minfra
@@ -5,26 +8,30 @@ module Minfra
5
8
  class Runner
6
9
  class Result
7
10
  include Logging
8
-
11
+
9
12
  attr_writer :status
10
-
13
+
11
14
  def initialize
12
- @stderr_lines=[]
13
- @stdout_lines=[]
14
- @status=nil
15
+ @stderr_lines = []
16
+ @stdout_lines = []
17
+ @status = nil
15
18
  end
16
-
17
- def add(line, stream=:stdout)
19
+
20
+ def add(line, stream = :stdout)
18
21
  line.chomp!
19
22
  if stream == :stdout
20
23
  @stdout_lines << line
21
24
  debug line
22
25
  else
23
26
  @stderr_lines << line
24
- error line
27
+ info line
25
28
  end
26
29
  end
27
-
30
+
31
+ def exitstatus
32
+ @status.exitstatus
33
+ end
34
+
28
35
  def success?
29
36
  @status.success?
30
37
  end
@@ -36,11 +43,11 @@ module Minfra
36
43
  def stdout
37
44
  @stdout_lines.join("\n")
38
45
  end
39
-
46
+
40
47
  def stderr
41
48
  @stderr_lines.join("\n")
42
- end
43
-
49
+ end
50
+
44
51
  def to_s
45
52
  stdout
46
53
  end
@@ -52,39 +59,46 @@ module Minfra
52
59
  end
53
60
 
54
61
  attr_reader :exit_on_error
62
+
55
63
  def initialize(cmd, exit_on_error: true)
56
- @cmd=cmd
64
+ @cmd = cmd
57
65
  @exit_on_error = exit_on_error
58
66
  end
59
67
 
60
68
  def run
61
69
  debug("running: #{@cmd}")
62
- res=nil
70
+ res = nil
63
71
  begin
64
- res=Result.new
72
+ res = Result.new
65
73
  # see: http://stackoverflow.com/a/1162850/83386
66
- Open3.popen3(@cmd) do |stdin, stdout, stderr, thread|
74
+ # the whole implementation is problematic as we migth miss some output lines
75
+ # Open4 might be a solution. Using Select might be a solution. Using Process.fork might be a solution....
76
+ Open3.popen3(@cmd) do |_stdin, stdout, stderr, thread|
67
77
  # read each stream from a new thread
68
- { :stdout => stdout, :stderr => stderr }.each do |key, stream|
78
+ { stdout: stdout, stderr: stderr }.each do |key, stream|
69
79
  Thread.new do
70
- until (raw_line = stream.gets).nil? do
80
+ until (raw_line = stream.gets).nil?
81
+ # stream.each do |raw_line|
71
82
  res.add(raw_line, key)
72
83
  end
84
+ rescue IOError # happens when you read from a close stream
85
+ raise unless ['stream closed in another thread', 'closed stream'].include?($ERROR_INFO.message)
86
+ # warn("Caught: #{$ERROR_INFO.message} for #{@cmd}")
73
87
  end
74
88
  end
75
89
  thread.join # don't exit until the external process is done
76
90
  res.status = thread.value
77
91
  end
78
- rescue
92
+ rescue StandardError
79
93
  end
80
-
94
+
81
95
  if res.error?
82
96
  error "command failed: #{@cmd}"
83
- info res.stdout
84
- error res.stderr
97
+ debug res.stdout
98
+ info res.stderr
85
99
  end
86
100
  if exit_on_error && res.error?
87
- info "exiting on error"
101
+ info "command exiting on error (#{res.exitstatus})"
88
102
  exit 1
89
103
  end
90
104
  res
@@ -1,5 +1,5 @@
1
1
  module Minfra
2
2
  module Cli
3
- VERSION = '1.7.1'.freeze
3
+ VERSION = '1.9.0'.freeze
4
4
  end
5
5
  end
data/lib/minfra/cli.rb CHANGED
@@ -47,6 +47,12 @@ module Minfra
47
47
 
48
48
  @logger=Logger.new(STDERR)
49
49
  logger.level=ENV["MINFRA_LOGGING_LEVEL"] || @config.project.minfra.logging_level || 'warn'
50
+
51
+ project_minfrarc_path = @config.base_path.join("config",'minfrarc.rb')
52
+ require project_minfrarc_path if project_minfrarc_path.exist?
53
+ me_minfrarc_path = @config.me_path.join('minfrarc.rb')
54
+ require @me_minfrarc_path if me_minfrarc_path.exist?
55
+
50
56
  @logger.debug("Minfra: loglevel: #{@logger.level}, env: #{@config.orch_env}")
51
57
 
52
58
  hiera_init
@@ -58,10 +64,7 @@ module Minfra
58
64
  require_relative 'cli/main_command'
59
65
  Minfra::Cli.resolve
60
66
 
61
- project_minfrarc_path = @config.base_path.join("config",'minfrarc.rb')
62
- require project_minfrarc_path if project_minfrarc_path.exist?
63
- me_minfrarc_path = @config.me_path.join('minfrarc.rb')
64
- require @me_minfrarc_path if me_minfrarc_path.exist?
67
+
65
68
 
66
69
  end
67
70
 
@@ -331,6 +331,7 @@ module Orchparty
331
331
 
332
332
  def initialize(name, type)
333
333
  super AST.service(name: name, _type: type)
334
+ @node.files = {}
334
335
  end
335
336
 
336
337
  # 1. rememebring the secrets in environment_secrets (so these environments can be created differentyly
@@ -340,6 +341,18 @@ module Orchparty
340
341
  @node.environment_secrets = result
341
342
  self
342
343
  end
344
+
345
+ def file(name, volume, &block)
346
+ result = FileBuilder.build(name, volume, block)
347
+ @node.files[name]=result
348
+ self
349
+ end
350
+ end
351
+
352
+ class FileBuilder < CommonBuilder
353
+ def initialize(name, volume)
354
+ super AST.service(filename: name, volume: volume)
355
+ end
343
356
  end
344
357
 
345
358
  class ServiceMixinBuilder < CommonBuilder
@@ -163,7 +163,7 @@ module Orchparty
163
163
  def print_install(chart)
164
164
 
165
165
  build_chart(chart) do |chart_path|
166
- cmd="helm template --namespace #{namespace} --kube-context #{cluster_name} #{chart.name} #{chart_path}"
166
+ cmd="helm template --namespace #{namespace} --debug --kube-context #{cluster_name} #{chart.name} #{chart_path}"
167
167
  @out_io.puts `$cmd`
168
168
  if system("#{cmd} > /dev/null")
169
169
  info("helm template check: OK")
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minfra-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Schrammel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-08 00:00:00.000000000 Z
11
+ date: 2023-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -237,7 +237,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
237
237
  - !ruby/object:Gem::Version
238
238
  version: '0'
239
239
  requirements: []
240
- rubygems_version: 3.1.6
240
+ rubygems_version: 3.4.6
241
241
  signing_key:
242
242
  specification_version: 4
243
243
  summary: A cli framework for k8s based development and deployment.