berkshelf / ridley

A reliable Chef API client with a clean syntax
Other
231 stars 84 forks source link

dot-separated attribute name #342

Open scottsuch opened 8 years ago

scottsuch commented 8 years ago

I've inherited some dot-separated node attributes that I'm attempting to alter via ridley.

The items look like:

"installer": {
  "properties": {
    "config.admin.email": "admin@scottsuch.test.com"
  }
}

Is there any way to escape the dots and tell ridely to update ['installer']['properties']['config.admin.email']

Some sample code:

require 'ridley'

kniferb = 'kniferb'
private_host = 'hostname'
new_url = 'scottsuch2.test.com'

ridley = Ridley.from_chef_config(kniferb, ssl: { verify: false })
node = ridley.node.find(private_host)

attr = 'installer.properties["config.admin.email"]'
node.set_chef_attribute(attr, "admin@#{new_url}")

After running the above, knife node edit gives me:

"installer": {
  "properties[\"config": {
    "admin": {
      "email\"]": "admin@scottsuch2.test.com"
    }
  }
}
lamont-granquist commented 7 years ago

I believe this is tightly coupled to how varia_model was designed.

This is a legit bug. The fix, however, would require some major overhauling.