twpayne / chezmoi

Manage your dotfiles across multiple diverse machines, securely.
https://www.chezmoi.io/
MIT License
13.4k stars 493 forks source link

Prefer `id` over `label` when decoding 1Password CLI 2.0 response #1965

Closed blahspam closed 2 years ago

blahspam commented 2 years ago

Is your feature request related to a problem? Please describe.

Some 1Password items have fields whose label contains a space but also contain a snake_cased id that would make a better key when decoding.

One example is ssh key (edited for brevity):

{
  "id": "blahblahblah",
  "category": "SSH_KEY",
  "fields": [
    {
      "id": "private_key",
      "type": "UNKNOWN",
      "label": "private key",
     "value": "......"
   }]
}

Using label makes templating a bit cumbersome:

{{ (index (onepasswordDetailsFields "someidvalue") "private key").value }}

It would be great if onepasswordDetailsFields preferred id over label when decoding fields: https://github.com/twpayne/chezmoi/blob/cb3db977ae221e028b38a3aa10f0ff1e7dc47982/pkg/cmd/onepasswordtemplatefuncs.go#L123

twpayne commented 2 years ago

Thanks, this makes sense.