Skip to content

feat: have parity with 1Password connect service for GetSecretMap#4895

Merged
Skarlso merged 2 commits intoexternal-secrets:mainfrom
Skarlso:add-extract-to-get-secret
Jun 13, 2025
Merged

feat: have parity with 1Password connect service for GetSecretMap#4895
Skarlso merged 2 commits intoexternal-secrets:mainfrom
Skarlso:add-extract-to-get-secret

Conversation

@Skarlso
Copy link
Copy Markdown
Contributor

@Skarlso Skarlso commented Jun 11, 2025

Problem Statement

What is the problem you're trying to solve?

Related Issue

Fixes #4893

Proposed Changes

How do you like to solve the issue and why?

Checklist

  • I have read the contribution guidelines
  • All commits are signed with git commit --signoff
  • My changes have reasonable test coverage
  • All tests pass with make test
  • I ensured my PR is ready for review with make reviewable

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
@Skarlso Skarlso requested a review from a team as a code owner June 11, 2025 20:42
@Skarlso Skarlso requested a review from moolen June 11, 2025 20:42
@gusfcarvalho
Copy link
Copy Markdown
Member

one question though - does this PR makes property mandatory for GetSecretMap? 🤔

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jun 12, 2025

@gusfcarvalho Yes, it does. It did that before that as well I believe. 🤔

Are you okay with that? ( before I merge this ).

Also, this is an obvious breaking change in that. But it's okay, because it's alpha.

@sonarqubecloud
Copy link
Copy Markdown

@gusfcarvalho
Copy link
Copy Markdown
Member

gusfcarvalho commented Jun 12, 2025

It's not really about the breaking change, but the fact this provider will be the only one not in line with other provider implementations. If a property is passed we parse it, but if no property is passed we just parse what we've found at the root of the secret

e.g. given the following content on a given secret provider (vault, aws sm, gcp sm, ...)

{
  "foo" :"bar",
  "nested": {"baz":"bing","bang":"bong"}
  }

if no property is specified we generate this secret:

foo: bar
nested: '{"baz":"bing", "bang":"bong"}'

while if nested property is provided, we generate this secret:

baz: bing
bang: bong

and lastly if foo property is provided we error out because that key does not contain a valid json.

that above is the behavior most providers implement ☝️ so I am having second thoughts if we should allow a provider that would not follow that 🤔

AFAIK the OG implementation is a subset of that (i.e. the property bit was 'not implemented') right?

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jun 12, 2025

@gusfcarvalho It definitely was. That's exactly how the old implementation is working.

I agree that it's an outlier.

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jun 12, 2025

To be clear, I don't know what to do about it. :D It makes sense to have parity, but yeah, essentially, this is working differently, than other providers.

@gusfcarvalho
Copy link
Copy Markdown
Member

Does 1password connect behaves differently than that today? 🤔

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jun 12, 2025

Nope. It behovass exactly the same way.

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jun 13, 2025

@gusfcarvalho Actually... :D Property is not required. If not provided, it will default to fetching fields. :)

@Skarlso Skarlso merged commit cb0d91e into external-secrets:main Jun 13, 2025
20 checks passed
alliseeisgold pushed a commit to alliseeisgold/external-secrets that referenced this pull request Jul 10, 2025
…ternal-secrets#4895)

Signed-off-by: Gergely Brautigam <182850+Skarlso@users.noreply.github.com>
Signed-off-by: asrormirzoev <asrormirzoev@yandex-team.ru>
@nervo
Copy link
Copy Markdown

nervo commented Jul 22, 2025

Hi, sorry @Skarlso, but i can not figure out the new behavior :)

I used to set a plain json content in a plain note onepassword secret, such as:

{
  "foo": "123",
  "bar": "456"
}

Then, using a dataFrom in spec:

...
  dataFrom:
    - extract:
        key: my_secret/notesPlain
...

I was able to either:

  • get all my json keys/values (foo and bar) as secret data without setting a data in my target spec
...
  target:
    deletionPolicy: Retain
    template:
      engineVersion: v2
      type: Opaque
  • get some specific json key(s)/value(s) by their name
...
  target:
    deletionPolicy: Retain
    template:
      engineVersion: v2
      type: Opaque
      data:
        foo: {{ `{{ .foo }}` }}
        bar: {{ `{{ .bar }}` }}

Now, in both cases, i receive some events: error processing spec.dataFrom[0].extract, err: key not found

Isn't that the supposed way to do it ?

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jul 27, 2025

Hello @nervo. Humm. The code is almost the same. So it should have worked.

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jul 27, 2025

They key does exist in your given vault given in your Store, right?

@nervo
Copy link
Copy Markdown

nervo commented Jul 28, 2025

@Skarlso, i finally found out what had changed :)

Right before this pr, the provider behaved just like the Google Cloud "all-keys-example-secret" here https://external-secrets.io/v0.18.2/guides/all-keys-one-secret/ , namely, a single secret item holds a single field, which contains raw json content, this json was unmarshalled, and boom, we got all our keys/values.
In my previous setup, i used to set a "Secure Note" item with plain raw json as single value. The value was accessible via the "notesPlain" field in onepassword api, so i used

  dataFrom:
    - extract:
        key: my_secret/notesPlain

Robust, but not very intuitive :)

Now, after that pr, i can continue to use "Secure Note" items, but i directly set keys/values as fields of my items, which is way more intuitive :) And i just need to declare the name of my item as key, without - obviously - the property|field.

  dataFrom:
    - extract:
        key: my_secret

(note that the "notesPlain" field seems not to be taken into account)

I've struggled a bit to understand this new behavior, digging the code and made many tests, but anyway, it works, and it works quite well ! Thanks for the good and hard job 💪

@Skarlso
Copy link
Copy Markdown
Contributor Author

Skarlso commented Jul 29, 2025

Thank you! Do you think we should add more tests or some documentation update to make that clearer?

@nervo
Copy link
Copy Markdown

nervo commented Jul 29, 2025

Well, that's the fun part, the documentation did not mention at all the previous behavior with dataFrom, i've discovered it the hard way :)
So i guess you can just only document the new behavior.

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

Successfully merging this pull request may close these issues.

Support multiple fields in onepasswordsdk

3 participants