Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

feat: add LABEL_SELECTOR to filter which OnePasswordItems the operator reconciles#276

Open
ochumakov wants to merge 1 commit into
1Password:main1Password/onepassword-operator:mainfrom
ochumakov:feature/label-selector-filterochumakov/onepassword-operator:feature/label-selector-filterCopy head branch name to clipboard
Open

feat: add LABEL_SELECTOR to filter which OnePasswordItems the operator reconciles#276
ochumakov wants to merge 1 commit into
1Password:main1Password/onepassword-operator:mainfrom
ochumakov:feature/label-selector-filterochumakov/onepassword-operator:feature/label-selector-filterCopy head branch name to clipboard

Conversation

@ochumakov

Copy link
Copy Markdown

✨ Summary

Adds an optional LABEL_SELECTOR environment variable. When set, the operator only reconciles OnePasswordItem resources whose labels match the selector; unset (the default) reconciles all items, so behavior is unchanged for existing deployments.

This enables running multiple operators that watch the same namespaces where each 1Password Connect token / service account only has access to its own vaults. Without it, every operator reconciles every OnePasswordItem cluster-wide and returns 403: token does not have access to vault on items it doesn't own, racing to overwrite each other's OnePasswordItem status. Giving each operator a distinct label selector makes each item owned by exactly one operator.

Implementation: a predicate.LabelSelectorPredicate on the OnePasswordItem controller's SetupWithManager (scoped to that controller only — the Deployment auto-restart watcher is untouched). The selector is parsed once from LABEL_SELECTOR via metav1.ParseToLabelSelector; an invalid value fails fast at startup. No CRD/API change — it filters on existing metadata.labels.

Example:

```yaml

operator Deployment env

  • name: LABEL_SELECTOR
    value: "operator-owner=team-a"

apiVersion: onepassword.com/v1
kind: OnePasswordItem
metadata:
name: example-secret
labels:
operator-owner: team-a # reconciled by the operator above; others ignore it
spec:
itemPath: "vaults//items/"
```

🔗 Resolves:

N/A (no existing issue found)

✅ Checklist

  • 🖊️ Commits are signed
  • 🧪 Tests added/updated:
    • 🔹 Unit — label-selector predicate matching/non-matching/unlabeled (internal/controller/onepassworditem_predicate_test.go)
    • 🔸 Integration
    • 🌐 E2E (Connect)
    • 🔑 E2E (Service Account)
  • 📚 Docs updated — USAGEGUIDE.md (both env-var lists + a new "Filtering which OnePasswordItems an operator reconciles" section), config/manager/manager.yaml, test/e2e/manifests/manager.yaml, CHANGELOG.md

🕵️ Review Notes & ⚠️ Risks

  • Fully backward compatible: no LABEL_SELECTOR set ⇒ nil selector ⇒ no predicate ⇒ all items reconciled (today's behavior).
  • Scoped to the OnePasswordItem controller; the Deployment/secret-update paths are unchanged.
  • make test and make lint pass; no generated-file drift.
  • Note: the periodic secret-update poller still refreshes secrets by annotation and is not label-scoped; it updates Secret data (not OnePasswordItem status), so it does not cause the status flapping this addresses. Could be a follow-up if desired.
  • The {#PR} placeholder in the CHANGELOG.md "Latest" entry should be replaced with this PR number.

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

⚠️ This PR contains unsigned commits. To get your PR merged, please sign those commits (git rebase --exec 'git commit -S --amend --no-edit -n' @{upstream}) and force push them to this branch (git push --force-with-lease).

If you're new to commit signing, there are different ways to set it up:

Sign commits with gpg

Follow the steps below to set up commit signing with gpg:

  1. Generate a GPG key
  2. Add the GPG key to your GitHub account
  3. Configure git to use your GPG key for commit signing
Sign commits with ssh-agent

Follow the steps below to set up commit signing with ssh-agent:

  1. Generate an SSH key and add it to ssh-agent
  2. Add the SSH key to your GitHub account
  3. Configure git to use your SSH key for commit signing
Sign commits with 1Password

You can also sign commits using 1Password, which lets you sign commits with biometrics without the signing key leaving the local 1Password process.

Learn how to use 1Password to sign your commits.

Watch the demo

@ochumakov
ochumakov force-pushed the feature/label-selector-filter branch from 8241f9f to ca57cdb Compare July 6, 2026 16:28
@ochumakov
ochumakov force-pushed the feature/label-selector-filter branch from ca57cdb to 2008de6 Compare July 6, 2026 16:29
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.

1 participant

Morty Proxy This is a proxified and sanitized view of the page, visit original site.