kameleon-builder 2.7.1 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.bumpversion.cfg CHANGED
@@ -1,7 +1,7 @@
1
1
  [bumpversion]
2
2
  commit = True
3
3
  tag = True
4
- current_version = 2.7.1
4
+ current_version = 2.7.2
5
5
  parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\.(?P<release>[a-z]+))?
6
6
  serialize =
7
7
  {major}.{minor}.{patch}.{release}
data/.editorconfig CHANGED
File without changes
data/CHANGES CHANGED
@@ -1,6 +1,14 @@
1
1
  Kameleon CHANGELOG
2
2
  ==================
3
3
 
4
+ Version 2.7.2
5
+ -------------
6
+
7
+ Released on February 17th 2016
8
+
9
+ - Added ``interactive_cmd`` option to set a more apropriate interactive shell command
10
+ - Removed bash errexit flag to force bash to trap interruption
11
+
4
12
  Version 2.7.1
5
13
  -------------
6
14
 
@@ -1,6 +1,5 @@
1
1
  #!/usr/bin/env bash
2
2
 
3
- set -o errexit
4
3
  set -o pipefail
5
4
  set -o allexport
6
5
 
data/lib/kameleon/cli.rb CHANGED
@@ -56,7 +56,7 @@ module Kameleon
56
56
  end
57
57
  begin
58
58
  tpl = RecipeTemplate.new(template_path)
59
- tpl.resolve!
59
+ tpl.resolve! :strict => false
60
60
  rescue
61
61
  raise TemplateNotFound, "Template '#{template_name}' not found. " \
62
62
  "To see all templates, run the command "\
@@ -81,7 +81,7 @@ module Kameleon
81
81
  template_path = template_path + '.yaml'
82
82
  end
83
83
  tpl = RecipeTemplate.new(template_path)
84
- tpl.resolve!
84
+ tpl.resolve! :strict => false
85
85
  tpl.display_info
86
86
  end
87
87
  map %w(-h --help) => :help
@@ -6,16 +6,18 @@ module Kameleon
6
6
  attr_accessor :shell
7
7
  attr_accessor :name
8
8
  attr_accessor :cmd
9
+ attr_accessor :interactive_cmd
9
10
  attr_accessor :workdir
10
11
  attr_accessor :local_workdir
11
12
  attr_accessor :proxy
12
13
  attr_accessor :env_files
13
14
 
14
15
 
15
- def initialize(name, cmd, workdir, exec_prefix, local_workdir, env_files,
16
- kwargs = {})
16
+ def initialize(name, cmd, interactive_cmd, workdir, exec_prefix,
17
+ local_workdir, env_files, kwargs = {})
17
18
  @name = name.downcase
18
19
  @cmd = cmd
20
+ @interactive_cmd = interactive_cmd
19
21
  @workdir = workdir
20
22
  @exec_prefix = exec_prefix
21
23
  @local_workdir = local_workdir
@@ -128,7 +130,7 @@ module Kameleon
128
130
  #TODO: Load env and history
129
131
  load_shell
130
132
  Kameleon.ui.info("Starting interactive shell")
131
- @shell.fork_and_wait
133
+ @shell.start_interactive
132
134
  rescue ShellError => e
133
135
  e.message.split( /\r?\n/ ).each {|m| Kameleon.ui.error m }
134
136
  end
@@ -92,7 +92,7 @@ module Kameleon
92
92
  proxy_cache_in = @recipe.global["in_context"]["proxy_cache"]
93
93
 
94
94
  Kameleon.ui.debug("Building local context [local]")
95
- @local_context = Context.new("local", "bash", @cwd, "", @cwd,
95
+ @local_context = Context.new("local", "bash", "bash", @cwd, "", @cwd,
96
96
  @recipe.env_files,
97
97
  :proxy => @recipe.global["proxy_local"],
98
98
  :lazyload => lazyload,
@@ -100,6 +100,7 @@ module Kameleon
100
100
  Kameleon.ui.debug("Building external context [out]")
101
101
  @out_context = Context.new("out",
102
102
  @recipe.global["out_context"]["cmd"],
103
+ @recipe.global["out_context"]["interactive_cmd"],
103
104
  @recipe.global["out_context"]["workdir"],
104
105
  @recipe.global["out_context"]["exec_prefix"],
105
106
  @cwd,
@@ -111,6 +112,7 @@ module Kameleon
111
112
  Kameleon.ui.debug("Building internal context [in]")
112
113
  @in_context = Context.new("in",
113
114
  @recipe.global["in_context"]["cmd"],
115
+ @recipe.global["in_context"]["interactive_cmd"],
114
116
  @recipe.global["in_context"]["workdir"],
115
117
  @recipe.global["in_context"]["exec_prefix"],
116
118
  @cwd,
@@ -100,6 +100,20 @@ module Kameleon
100
100
  end.flatten!
101
101
  @steps_dirs.uniq!
102
102
 
103
+ # Set default value for in_ctx and out_ctx options
104
+ %w(out_context in_context).each do |context_name|
105
+ unless yaml_recipe.keys.include? "global"
106
+ yaml_recipe["global"] = {}
107
+ end
108
+ unless yaml_recipe["global"].keys.include? context_name
109
+ yaml_recipe["global"][context_name] = {}
110
+ end
111
+ @global[context_name].merge!(yaml_recipe["global"][context_name])
112
+ yaml_recipe["global"][context_name] = @global[context_name]
113
+ unless yaml_recipe["global"][context_name].keys.include? "interactive_cmd"
114
+ yaml_recipe["global"][context_name]["interactive_cmd"] = yaml_recipe["global"][context_name]['cmd']
115
+ end
116
+ end
103
117
  # Load Global variables
104
118
  @global.merge!(yaml_recipe.fetch("global", {}))
105
119
  # merge cli variable with recursive variable overload
@@ -506,7 +520,7 @@ module Kameleon
506
520
  end
507
521
  Kameleon.ui.verbose("#{real_path} : nonexistent")
508
522
  end
509
- fail RecipeError, "Cannot found data '#{partial_path}' unsed in '#{step_path}'"
523
+ fail RecipeError, "Cannot found data '#{partial_path}' used in '#{step_path}'"
510
524
  end
511
525
 
512
526
  def resolve!(kwargs = {})
@@ -14,6 +14,7 @@ module Kameleon
14
14
 
15
15
  def initialize(context)
16
16
  @cmd = context.cmd.chomp
17
+ @interactive_cmd = context.interactive_cmd.chomp
17
18
  @context_name = context.name
18
19
  @local_workdir = context.local_workdir
19
20
  @shell_workdir = context.workdir
@@ -45,6 +46,9 @@ module Kameleon
45
46
 
46
47
  @shell_cmd = "source #{@default_bashrc_file} 2> /dev/null; "\
47
48
  "#{@cmd} --rcfile #{@bashrc_file}"
49
+ @interactive_shell_cmd = "source #{@default_bashrc_file} 2> /dev/null; "\
50
+ "#{@interactive_cmd} --rcfile #{@bashrc_file}"
51
+
48
52
  Kameleon.ui.debug("Initialize shell (#{self})")
49
53
  # Injecting all variables of the options and assign the variables
50
54
  instance_variables.each do |v|
@@ -238,8 +242,8 @@ SCRIPT
238
242
  return get_status
239
243
  end
240
244
 
241
- def fork_and_wait
242
- process, _, _ = fork("inherit")
245
+ def start_interactive
246
+ process, _, _ = fork("interactive")
243
247
  process.wait()
244
248
  end
245
249
 
@@ -285,8 +289,13 @@ SCRIPT
285
289
  end
286
290
 
287
291
  def fork(io)
288
- command = ["bash", "-c", @shell_cmd]
289
- Kameleon.ui.info("Starting process: #{@cmd.inspect}")
292
+ if io.eql? "interactive"
293
+ command = ["bash", "-c", @interactive_shell_cmd]
294
+ Kameleon.ui.info("Starting interactive command: #{@interactive_shell_cmd.inspect}")
295
+ else
296
+ command = ["bash", "-c", @shell_cmd]
297
+ Kameleon.ui.info("Starting command: #{@cmd.inspect}")
298
+ end
290
299
  Kameleon.ui.debug("Starting shell process: #{ command.inspect}")
291
300
  ChildProcess.posix_spawn = true
292
301
  process = ChildProcess.build(*command)
@@ -299,7 +308,7 @@ SCRIPT
299
308
  process.io.stderr = stderr_writer
300
309
  # sets up pipe so process.io.stdin will be available after .start
301
310
  process.duplex = true
302
- elsif io.eql? "inherit"
311
+ elsif io.eql? "interactive"
303
312
  process.io.inherit!
304
313
  end
305
314
 
data/version.txt CHANGED
@@ -1 +1 @@
1
- 2.7.1
1
+ 2.7.2
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kameleon-builder
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.1
4
+ version: 2.7.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2016-01-22 00:00:00.000000000 Z
16
+ date: 2016-02-17 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: childprocess