Skip to content
This repository was archived by the owner on Sep 9, 2026. It is now read-only.

NO-ISSUE: Add SharedTenant and SystemTenant named constants - #557

Merged
jhernand merged 1 commit into
osac-project:mainfrom
jhernand:add_shared_tenant_and_system_tenant_constants
May 20, 2026
Merged

jhernand merged 1 commit into
osac-project:mainfrom
jhernand:add_shared_tenant_and_system_tenant_constants

Conversation

@jhernand

Copy link
Copy Markdown
Contributor

Summary

Introduces SharedTenant and SystemTenant variables in the auth package so that the
"shared" and "system" tenant strings are defined once and referenced everywhere, reducing the
risk of typos and making future renames easier. The SharedTenants and SystemTenants sets now
derive from these variables instead of inline strings, and all test files that previously hardcoded
"shared" in metadata tenant fields now use auth.SharedTenant.

Addresses the review feedback in
#543 (review).

Test plan

  • All unit tests pass (ginkgo run -r internal).

@openshift-ci-robot

Copy link
Copy Markdown

@jhernand: This pull request explicitly references no jira issue.

Details

In response to this:

Summary

Introduces SharedTenant and SystemTenant variables in the auth package so that the
"shared" and "system" tenant strings are defined once and referenced everywhere, reducing the
risk of typos and making future renames easier. The SharedTenants and SystemTenants sets now
derive from these variables instead of inline strings, and all test files that previously hardcoded
"shared" in metadata tenant fields now use auth.SharedTenant.

Addresses the review feedback in
#543 (review).

Test plan

  • All unit tests pass (ginkgo run -r internal).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci
openshift-ci Bot requested review from trewest and tzumainn May 19, 2026 10:58
@openshift-ci

openshift-ci Bot commented May 19, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jhernand

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: 49f21ddd-6482-40a2-aeb5-fe855dfa4cdb

📥 Commits

Reviewing files that changed from the base of the PR and between b1b60d3 and 7c0a6aa.

📒 Files selected for processing (14)
  • internal/auth/default_tenancy_logic.go
  • internal/auth/default_tenancy_logic_test.go
  • internal/auth/tenancy_logic.go
  • internal/servers/clusters_server_test.go
  • internal/servers/compute_instances_server_test.go
  • internal/servers/network_classes_server_test.go
  • internal/servers/private_clusters_server_test.go
  • internal/servers/private_compute_instances_server_test.go
  • internal/servers/private_public_ips_server_test.go
  • internal/servers/private_subnets_server_test.go
  • internal/servers/public_ips_server_test.go
  • internal/servers/security_groups_server_test.go
  • internal/servers/subnets_server_test.go
  • internal/servers/virtual_networks_server_test.go
🚧 Files skipped from review as they are similar to previous changes (13)
  • internal/servers/public_ips_server_test.go
  • internal/servers/virtual_networks_server_test.go
  • internal/auth/default_tenancy_logic_test.go
  • internal/servers/subnets_server_test.go
  • internal/auth/default_tenancy_logic.go
  • internal/auth/tenancy_logic.go
  • internal/servers/security_groups_server_test.go
  • internal/servers/compute_instances_server_test.go
  • internal/servers/network_classes_server_test.go
  • internal/servers/private_compute_instances_server_test.go
  • internal/servers/clusters_server_test.go
  • internal/servers/private_subnets_server_test.go
  • internal/servers/private_public_ips_server_test.go

Summary by CodeRabbit

  • Refactor

    • Standardized tenant identifiers across the codebase by introducing shared constants to replace scattered string literals.
  • Tests

    • Updated test fixtures throughout the suite to use the new tenant constants instead of hard-coded tenant strings, ensuring consistent test data.

Walkthrough

This PR replaces hardcoded tenant string literal "shared" with an explicit SharedTenant constant across the codebase. The auth package now exports SystemTenant and SharedTenant string variables and restructures tenant set initialization to use these constants. The DetermineDefaultTenant function is updated to reference the SharedTenant constant, and all server test files add imports of the auth package and update their metadata fixtures to use auth.SharedTenant instead of the hardcoded string.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: introducing named constants for SharedTenant and SystemTenant in the auth package.
Description check ✅ Passed The description is directly related to the changeset, explaining the purpose of introducing the constants, their usage in reducing typos, and referencing the review feedback that prompted the change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/auth/tenancy_logic.go`:
- Around line 40-50: SystemTenant and SharedTenant are exported mutable vars;
change them to exported consts to make tenant identifiers immutable (e.g.,
replace var SystemTenant/SharedTenant string declarations with const
SystemTenant = "system" and const SharedTenant = "shared") and leave
SystemTenants and SharedTenants as vars created via
collections.NewSet(SystemTenant)/collections.NewSet(SharedTenant) so the sets
still initialize from the const values; update tenancy_logic.go accordingly,
preserving names and exports.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Enterprise

Run ID: afe81620-8d0f-464b-bd31-5994edb498a3

📥 Commits

Reviewing files that changed from the base of the PR and between e6cf15a and b1b60d3.

📒 Files selected for processing (14)
  • internal/auth/default_tenancy_logic.go
  • internal/auth/default_tenancy_logic_test.go
  • internal/auth/tenancy_logic.go
  • internal/servers/clusters_server_test.go
  • internal/servers/compute_instances_server_test.go
  • internal/servers/network_classes_server_test.go
  • internal/servers/private_clusters_server_test.go
  • internal/servers/private_compute_instances_server_test.go
  • internal/servers/private_public_ips_server_test.go
  • internal/servers/private_subnets_server_test.go
  • internal/servers/public_ips_server_test.go
  • internal/servers/security_groups_server_test.go
  • internal/servers/subnets_server_test.go
  • internal/servers/virtual_networks_server_test.go

Comment thread internal/auth/tenancy_logic.go Outdated
Comment thread internal/auth/tenancy_logic.go Outdated
// SharedTenants is the set of tenants that are always visible to all users.
var SharedTenants = collections.NewSet("shared")
// Tenants that are always visible to all users.
var (

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.

Coderabbit also commented on this - any reason for using var and not const?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, no reason, fixed.

The `"shared"` and `"system"` tenant strings were used as literals in
multiple places across production code and tests. This introduces
`SharedTenant` and `SystemTenant` variables in the `auth` package so
that the values are defined once and referenced everywhere, reducing
the risk of typos and making future renames easier.

The `SharedTenants` and `SystemTenants` sets now derive from these
variables instead of inline strings. All test files that previously
hardcoded `"shared"` in metadata tenant fields now use
`auth.SharedTenant`.

Related: osac-project#543 (review)
Signed-off-by: Juan Hernandez <juan.hernandez@redhat.com>
@jhernand
jhernand force-pushed the add_shared_tenant_and_system_tenant_constants branch from b1b60d3 to 7c0a6aa Compare May 19, 2026 14:19
@omer-vishlitzky

Copy link
Copy Markdown
Contributor

/retest

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants