Chamber integration


#1

Is there an example that integrates Chamber?
I did a basic

gem install chamber
chamber init

but can’t access what’s in settings.yml. This is the error I get: (notice it does read my settings.yml and complains about the keys with the _secure* prefix, but it’s unable to get the values)

16:12:14@ maestro (AS-5845-evaluate-campaign-eligibility-gi)*$ jets console
running database.yml development
Jets booting up in development mode!
irb(main):001:0> Chamber.assurance_host
WARNING: It appears that you would like to keep your information for _secure_secure_setting secure, however the value for that setting does not appear to be encrypted. Make sure you run 'chamber secure' before committing.
Traceback (most recent call last):
       14: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/bin/jets:23:in `<main>'
       13: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/bin/jets:23:in `load'
       12: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/exe/jets:14:in `<top (required)>'
       11: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/lib/jets/cli.rb:5:in `start'
       10: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/lib/jets/cli.rb:21:in `start'
        9: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/lib/jets/commands/base.rb:27:in `perform'
        8: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/lib/jets/commands/base.rb:38:in `dispatch'
        7: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
        6: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
        5: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
        4: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/lib/jets/commands/main.rb:61:in `console'
        3: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/jets-1.8.14/lib/jets/commands/console.rb:11:in `run'
        2: from (irb):1
        1: from /Users/thusharawijeratna/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/chamber-2.12.3/lib/chamber.rb:29:in `method_missing'
NoMethodError (undefined method `assurance_host' for Chamber:Module)
irb(main):002:0>

My settings.yml (at the root) looks like this:

development:
  assurance_host:         http://localhost
  assurance_port:         3000

  # The following will become 'secure_setting'
  _secure_secure_setting: secure_development_value

test:
  assurance_host:         https://staging.assurance.com
  assurance_port:         443

production:
  assurance_host:         https://assurance.com
  assurance_port:         443

I can see the values in Chamber.env , somehow the usual method of extraction doesn’t seem to work:

irb(main):001:0> Chamber.env
=> #<Chamber::Settings:0x00007faecff6c310 @namespaces=#<Chamber::NamespaceSet:0x00007faecff6c2e8 @raw_namespaces=[]>, @raw_data=#<Hashie::Mash development=#<Hashie::Mash assurance_host="http://localhost" assurance_port=3000> production=#<Hashie::Mash assurance_host="https://assurance.com" assurance_port=443> test=#<Hashie::Mash assurance_host="https://staging.assurance.com" assurance_port=443>>

<snip>


#2

Little more debugging here reveals this:

irb(main):002:0> Chamber.keys
=> ["development", "test", "production"]
irb(main):003:0> Chamber['development']
=> #<Hashie::Mash assurance_host="http://localhost" assurance_port=3000>
irb(main):004:0> Chamber['development']['assurance_host']
=> "http://localhost"
irb(main):005:0>

It seems that the environment is not read by chamber startup, but I can get access to the variables this way. Although not sure why Chamber behaves this way under Jets.