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

For database items hostname is not set because label is server not hostname as the item schema expects #76

Closed
monster-cookie opened this issue Mar 23, 2023 · 2 comments · Fixed by #167
Labels
bug Something isn't working

Comments

@monster-cookie
Copy link

Your environment

Terraform Provider Version: 1.1.4
Connect Server Version: 1.10.0
OS: Terraform Cloud so probably Ubuntu
Terraform Version: Latest (1.4.2)

What happened?

Hostname for database category items is not set

What did you expect to happen?

Hostname for database items should be set

Steps to reproduce

  1. Create a database item in 1password
  2. Use the data resource for item to access the item
  3. The hostname field will be null instead of the value

Notes & Logs

The problem stems from onepassword\data_source_onepassword_item.go line 211 to 222 specifically line 220

	for _, f := range item.Fields {
		switch f.Purpose {
		case "USERNAME":
			data.Set("username", f.Value)
		case "PASSWORD":
			data.Set("password", f.Value)
		case "NOTES":
			data.Set("note_value", f.Value)
		default:
			if f.Section == nil {
				data.Set(strings.ToLower(f.Label), f.Value)
			}
		}
	}

In the case of database items 1connect sends and id for hostname but the label is set to server they probably should both be server as that makes more sense for a database.

The best work around I could come up with that didn't require a major refactor was to set that section like this.

	for _, f := range item.Fields {
		switch f.Purpose {
		case "USERNAME":
			data.Set("username", f.Value)
		case "PASSWORD":
			data.Set("password", f.Value)
		case "NOTES":
			data.Set("note_value", f.Value)
		default:
			if f.Section == nil {
				if f.Label == "server" {
					data.Set(strings.ToLower(f.ID), f.Value)
				} else {
					data.Set(strings.ToLower(f.Label), f.Value)
				}
			}
		}
	}

Basically use ID inste4ad of label for server this gets around the schema validation. Another option would be to solve the naming issue in 1password connect and use hostname or server for both ID and label.

@monster-cookie monster-cookie added the bug Something isn't working label Mar 23, 2023
@sebastianreloaded
Copy link

it's also not working with the latest version 1.2.0

@sebastianreloaded
Copy link

sebastianreloaded commented Oct 16, 2023

Workaround: rename label "server" to "hostname" or "url"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants