How to load content from file using yaml template?

Options
matheushent
matheushent
Community Member

So, I've been trying to work around based on this link.

My idea is to have a file on 1Password like:

db:
  username: blabla
  password: iamasecret
api:
  whatever: whenever

And then, load to a yaml template file using op inject. However, when I try to do such a thing I get:

item <vault id>/<item id> does not have a field db.username

Which makes sense when I discover the file running `op item get --format json. I wonder if it is possible to achieve such a thing because my secrets are very customized and doesn't fit any of the pre sets 1Password provides (login, api credential, etc).

Btw, I'm using the CLI 2.0.0


1Password Version: 8.9.4
Extension Version: Not Provided
OS Version: 12.5
Browser:_ Not Provided

Comments

  • matheushent
    matheushent
    Community Member
    edited August 2022
    Options

    For now I ended up creating an empty note and adding fields to it. It would be so cool to be able to create a secret with no pre-defined fields

  • Hi @matheushent, thanks for reaching out. If I understood your question correctly, the CLI allows for creation of items from a template file using either piping or passing a file path to the command's --template flag, under the condition that the file has json format (so yaml is not currently supported for creation - nor editing for that matter). To achieve this, use: op item create --template myFile. To get a sense of how myFile should look like, use op item template get Login, for instance. The piped version of this command should then go like this op item template get Login | op item create --vault Private -. If you need a way to replicate nested fields like in yaml, you could make use of an item's section/field structure. If you need more than 2 nested fields this would no longer suit your needs, and what I would do is straight up attach a yaml file to my item or create a document type item with a yaml file.

    Let me know if this answers your question.
    Best,
    Andi

This discussion has been closed.