github / github/octocatalog-diff
octocalog-diff seems to resolve scope differently from puppet
- Dominant language
- Ruby
- Stars
- 252
- Forks
- 95
- PR merge metrics
- No merged PRs in 30d
Description
> Description of problem
tl;dr
puppet and octocatalog diff don't read things the same way.
in puppet I have module (foo) which calls a template in another module (bar)
a var declared in module bar is not accessible to the template with @ in octocalog-diff but in puppet it is accessible.
in puppet this works fine but in octocatalog-diff
"cluster_name" : "<%= @cluster_name.downcase %>",
If I change it to scope['bar::cluster_name'].downcase it works in octocalog-diff
- What did you do?
I have a module
foo:
which has:
define service_definition (
$service = $title,
$template = "${service}/${service}.json.erb",
$enabled = true,
$watch_config = '',
) {
$service_def_path = "/etc/somepath/servicedefs/${service}.json"
if $enabled and ($::foo::version != 'absent') {
file { $service_def_path:
ensure => present,
# content => inline_template($template),
content => template($template),
owner => 'root',
group => 'root',
mode => '0644',
require => Package['foo'],
}
In puppet when I give it service bar it works fine,
but in your tool I get:
Error: Failed to compile catalog for node bas Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Failed to parse template bar/bar.json.erb:
Filepath: /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/ibar/templates/bar.json.erb
Line: 7
Detail: undefined method `downcase' for nil:NilClass
at /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/foo/manifests/init.pp:77:18 at /var/folders/sp/r687p5j51y106yn0gb4vynwm0000gn/T/d20170811-19384-1ldupto/environments/production/modules/bar/manifests/init.pp:59 on node bas
Line: 7 is
"cluster_name" : "<%= @cluster_name.downcase %>",
If I change it to scope['bar::cluster_name'].downcase it works fine for octocatalog--diff.
- What happened?
octocalog-diff did not work like puppet
- What did you expect to happen?
octocalog-diff should work like puppet
- How can someone reproduce the problem?
any time one module calls another modules, template, and that template uses vars define in the second module
> Command used and debugging output
If you feel this will help I will add it.
> Platform and version information
- Your OS:
mac 10.12.5 (16F73) for octocatalog-diff
16.6.0 Darwin puppet master
- Your Ruby version:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16] ( on octocatalog-diff host
- Your version of Puppet:
puppet --version
3.8.6
ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux ( on puppet master)
- Your version of octocatalog-diff:
> Do the tests pass from a clean checkout?
yes
> Anything else to add that you think will be helpful?
is this expected/etc ?
Contributor guide
Research direction
Start by reproducing the foo/bar module case with bar/bar.json.erb and the template call shown in the issue, then inspect how template scope is handled when octocatalog-diff compiles the catalog. Compare the result with Puppet using @cluster_name; done means the same template variable resolves without requiring scope['bar::cluster_name'].
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100