voxpupuli / hiera-eyaml-gpg

GPG encryption backend for the hiera-eyaml module
MIT License
49 stars 33 forks source link

eyaml edit: undefined method `plain_text' on save #17

Open igalic opened 10 years ago

igalic commented 10 years ago

I have a file foo.eyaml, that, unencrypted, looks like so:


---
postgresql::dbs:
  dbx:
    user: u1
    password: DEC(1)::GPG[Defect9advert-great]!

now I'd like to duplicate this, and have something like:


---
postgresql::dbs:
  dbx:
    user: u1
    password: DEC(1)::GPG[Defect9advert-great]!
  dby:
    user: u2
    password: DEC(2)::GPG[madrid_riot-Knot]!

when saving & closing the editor, I'm getting the following error:

[hiera-eyaml-core] !!! undefined method `plain_text' for #<Hiera::Backend::Eyaml::Parser::NonMatchToken:0x007f630b9c2938>
[hiera-eyaml-core] ["/home/igalic/.gem/ruby/2.1.2/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/subcommands/edit.rb:69:in `block in execute'", "/home/igalic/.gem/ruby/2.1.2/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/subcommands/edit.rb:66:in `map'", "/home/igalic/.gem/ruby/2.1.2/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/subcommands/edit.rb:66:in `execute'", "/home/igalic/.gem/ruby/2.1.2/gems/hiera-eyaml-2.0.3/lib/hiera/backend/eyaml/CLI.rb:45:in `execute'", "/home/igalic/.gem/ruby/2.1.2/gems/hiera-eyaml-2.0.3/bin/eyaml:13:in `<top (required)>'", "/home/igalic/.gem/ruby/2.1.2/bin/eyaml:23:in `load'", "/home/igalic/.gem/ruby/2.1.2/bin/eyaml:23:in `<main>'"]
lucab commented 9 years ago

Just for reference, I suspect this is because you are manually assigning a new ID (DEC(2)) to the second entry.

Just introducing it as DEC::GPG[foo]! works for me. A new ID will be automatically assigned as soon as you save.

sihil commented 9 years ago

@lucab is right. The id is used to track changes so we don't unnecessarily re-encrypt values that haven't been changed. It will break if you try and introduce a new id that it doesn't exist.

The new release (2.0.4) adds a preamble that explains this and makes it all a little easier to remember.

igalic commented 9 years ago

ACK! Thanks for the info

sihil commented 9 years ago

We should see if we can make this error clearer although it belongs in the hiera-eyaml project rather than here so I'll open a new ticket.