Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow creating entries with multi-line strings #163

Open
toadjaune opened this issue Apr 29, 2024 · 0 comments
Open

Allow creating entries with multi-line strings #163

toadjaune opened this issue Apr 29, 2024 · 0 comments

Comments

@toadjaune
Copy link

Summary

Currently, when creating a value in a custom field, line breaks get turned into spaces, although 1Password does support having values spanning several lines with text field type.

Use cases

Basically, I'd like to do something along the lines of :

resource "onepassword_item" "example" {
  vault = "<some_vault_id>"
  title    = "Example"
  category = "login"
  section {
    label = "Custom section"
    field {
      label = "multi-line string"
      type  = "STRING"
      value = <<-EOT
        line1
        line2
      EOT
    }
  }
}

This results in the following entry :
image

When attempting to manually edit the resulting entry, I can't transform it into a multi-line string.
However, if I add a new field of type "text", I can enter multi-line values :
image

This leads me to believe that the underlying 1Password data model has two types of strings, one allowing multi-line values, the other not.

If that's the case, however, this is not exposed to terraform, as importing the entry after this manual addition yields this state :

resource "onepassword_item" "example" {
    [...]
    section {
        id    = "6d78330e-cf14-a8ab-44d7-d8d2e244e91e"
        label = "Custom section"
        field {
            id      = "iv33n3zfkfcnhrydqvnfruf3jm"
            label   = "multi-line string"
            purpose = null
            type    = "STRING"
            value   = (sensitive value)
        }
        field {
            id      = "h3ehk63snul76a6raioe637w4a"
            label   = "manual text"
            purpose = null
            type    = "STRING"
            value   = (sensitive value)
        }
    }
}

As you can see, terraform doesn't see the type difference between those two values.

Also, attempting to enter anything else as type (for example, TEXT), yields the following error :
Error: expected section.0.field.5.type to be one of [STRING EMAIL CONCEALED URL OTP DATE MONTH_YEAR MENU], got TEXT

I haven't attempted to manipulate those entries directly from the 1Password CLI, to see if the problem is exclusively in the terraform provider, or in the underlying CLI.

Proposed solution

I'm assuming that those two strings are indeed different types in the 1Password data model, if that's not the case, those suggestions break apart :

  1. (ideal) : Expose both types to the CLI and terraform provider
  2. Make terraform switch its STRING type to using the underlying type allowing multi-line strings.

Is there a workaround to accomplish this today?

Not that I know of. It's still possible to create entries with multi-line strings, the line breaks will just get mangled.

References & Prior Work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant