Skip to content

[platform] Add secret selectors to app definitions - #1447

Merged
Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
feat/cozyrd-secret-selectors
Sep 23, 2025
Merged

Andrei Kvapil (kvaps) merged 1 commit into
mainfrom
feat/cozyrd-secret-selectors

Conversation

@lllamnyp

@lllamnyp Timofei Larkin (lllamnyp) commented Sep 23, 2025 •

Copy link
Copy Markdown
Member

What this PR does

This patch expands the CozystackResourceDefinitions with new label selector fields to include and exclude secrets by their labelsets. This will enable application developers to selectively show or hide application secrets to and from end-users.

Release note

[platform] Add selectors for application secrets, offering developers
an API to control secret visibility for end users.

Summary by CodeRabbit

  • New Features
    • Added support for configuring secret visibility on resource definitions using include/exclude label selectors. This lets you precisely control which secrets are considered without affecting existing setups.
    • The configuration is optional; if not set, behavior remains unchanged.

This patch expands the CozystackResourceDefinitions with new label
selector fields to include and exclude secrets by their labelsets.
This will enable application developers to selectively show or hide
application secrets to and from end-users.

```release-note
[platform] Add selectors for application secrets, offering developers
an API to control secret visibility for end users.
```

Signed-off-by: Timofei Larkin <[email protected]>
@coderabbitai

coderabbitai Bot commented Sep 23, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

A new struct CozystackResourceDefinitionSecrets was added to define include/exclude secret label selectors. The CozystackResourceDefinitionSpec gained a new optional field Secrets with JSON key "secrets". No methods or control flow were modified.

Changes

Cohort / File(s) Summary of changes
API Types: Secrets configuration
api/v1alpha1/cozystackresourcedefinitions_types.go
Added type CozystackResourceDefinitionSecrets with Exclude/Include slices of *metav1.LabelSelector. Added Secrets CozystackResourceDefinitionSecrets \json:"secrets,omitempty"`field toCozystackResourceDefinitionSpec`.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch my ears at structs so neat,
New secrets’ maps, include/exclude treat.
In YAML burrows, fields now peek,
With labels guiding hide-and-seek.
I thump approval—types aligned,
Hop along, definitions refined.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title "[platform] Add secret selectors to app definitions" concisely and accurately summarizes the main change in the PR by indicating that secret selector fields are being added to application/resource definitions to control secret visibility; it is specific, aligned with the PR objectives and file changes, and free of noise or vague wording.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/cozyrd-secret-selectors

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello Timofei Larkin (@lllamnyp), I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the CozystackResourceDefinitions API by integrating new secret selectors. This feature empowers application developers with the ability to precisely manage the visibility of application secrets to end-users, ensuring that only relevant or authorized secrets are exposed while others remain hidden. The change provides a robust mechanism for controlling sensitive data access within applications.

Highlights

  • API Expansion: Expanded the CozystackResourceDefinitions API with new label selector fields for secrets.
  • Secret Visibility Control: Introduced Include and Exclude label selectors within the Secrets configuration to control which application secrets are visible to end-users.
  • Developer Empowerment: Enabled application developers to selectively show or hide application secrets, providing fine-grained control over sensitive data exposure.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on Gemini (@gemini-code-assist) comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces secret selectors to the CozystackResourceDefinitions, enabling application developers to control the visibility of application secrets for end-users. The changes involve adding a Secrets field to the CozystackResourceDefinitionSpec and defining a CozystackResourceDefinitionSecrets struct with Include and Exclude label selectors. I have identified a potential issue with the DeepCopy implementation for the newly added CozystackResourceDefinitionSecrets struct, which could lead to unexpected behavior when copying these objects.

Comment on lines +93 to +103
type CozystackResourceDefinitionSecrets struct {
// Exclude contains an array of label selectors that target secrets.
// If a secret matches the selector in any of the elements in the array, it is
// hidden from the user, regardless of the matches in the include array.
Exclude []*metav1.LabelSelector `json:"exclude,omitempty"`
// Include contains an array of label selectors that target secrets.
// If a secret matches the selector in any of the elements in the array, and
// matches none of the selectors in the exclude array that secret is marked
// as a tenant secret and is visible to users.
Include []*metav1.LabelSelector `json:"include,omitempty"`
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Consider adding a comment explaining the precedence of Exclude over Include. It's mentioned in the description, but adding it here will improve readability and prevent confusion.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 66b53cb and 48919c0.

📒 Files selected for processing (1)
  • api/v1alpha1/cozystackresourcedefinitions_types.go (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Build
🔇 Additional comments (2)
api/v1alpha1/cozystackresourcedefinitions_types.go (2)

51-52: LGTM! Well-documented field addition.

The new Secrets field is properly documented and follows Go struct conventions with appropriate JSON tags.


93-103: LGTM! Well-designed secret selector struct with clear semantics.

The CozystackResourceDefinitionSecrets struct provides a clean API for controlling secret visibility. The exclude-takes-precedence semantics (Line 96-97) and the dual condition for inclusion (Lines 99-101) are well-documented and follow intuitive filtering patterns.

The use of []*metav1.LabelSelector allows for flexible label-based secret selection, which aligns well with Kubernetes conventions.

Comment on lines +93 to +103
type CozystackResourceDefinitionSecrets struct {
// Exclude contains an array of label selectors that target secrets.
// If a secret matches the selector in any of the elements in the array, it is
// hidden from the user, regardless of the matches in the include array.
Exclude []*metav1.LabelSelector `json:"exclude,omitempty"`
// Include contains an array of label selectors that target secrets.
// If a secret matches the selector in any of the elements in the array, and
// matches none of the selectors in the exclude array that secret is marked
// as a tenant secret and is visible to users.
Include []*metav1.LabelSelector `json:"include,omitempty"`
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

🧩 Analysis chain

Verify integration with secret filtering logic.

The new struct defines the API contract for secret selectors, but please ensure the corresponding controller or reconciler logic has been implemented to actually filter secrets based on these selectors.


🏁 Script executed:

#!/bin/bash
# Description: Search for code that processes the new Secrets field to ensure integration is complete.
# Expected: Find controller/reconciler code that uses the Include/Exclude selectors.

echo "=== Searching for usage of CozystackResourceDefinitionSecrets ==="
rg -nP --type=go "CozystackResourceDefinitionSecrets|\.Secrets\." -A 3 -B 3

echo -e "\n=== Searching for secret filtering logic ==="
rg -nP --type=go "LabelSelector.*[Ss]ecret|[Ss]ecret.*LabelSelector" -A 3 -B 3

echo -e "\n=== Searching for include/exclude secret logic ==="
rg -nP --type=go "(Include|Exclude).*[Ss]ecret|[Ss]ecret.*(Include|Exclude)" -A 3 -B 3

Length of output: 2663


Implement reconciler integration for Secrets.Include/Exclude — no usages found

Searches only found the type declaration at api/v1alpha1/cozystackresourcedefinitions_types.go; there is no controller/reconciler code applying these Include/Exclude LabelSelectors. Add secret-filtering logic to the CozystackResourceDefinition reconciler/controller so secrets are listed and filtered per the API contract.

@kvaps
Andrei Kvapil (kvaps) merged commit d991c49 into main Sep 23, 2025
20 checks passed
@kvaps
Andrei Kvapil (kvaps) deleted the feat/cozyrd-secret-selectors branch September 23, 2025 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.

2 participants