Skip to content

feat: add multi tenant service api key#571

Merged
brunobls merged 3 commits intodevelopfrom
feat/add-multi-tenant-service-api-key
Mar 16, 2026
Merged

feat: add multi tenant service api key#571
brunobls merged 3 commits intodevelopfrom
feat/add-multi-tenant-service-api-key

Conversation

@brunobls
Copy link
Member

@brunobls brunobls commented Mar 16, 2026

Pull Request Checklist

Pull Request Type

  • Manager
  • Worker
  • Frontend
  • Infrastructure
  • Packages
  • Pipeline
  • Tests
  • Documentation

Checklist

Please check each item after it's completed.

  • I have tested these changes locally.
  • I have updated the documentation accordingly.
  • I have added necessary comments to the code, especially in complex areas.
  • I have ensured that my changes adhere to the project's coding standards.
  • I have checked for any potential security issues.
  • I have ensured that all tests pass.
  • I have updated the version appropriately (if applicable).
  • I have confirmed this code is ready for review.

Additional Notes

Obs: Please, always remember to target your PR to develop branch instead of main.

brunobls and others added 2 commits March 16, 2026 13:45
Upgrade lib-commons to pick up WithServiceAPIKey option in tenant manager client.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add service API key field to Config structs, require it when
MULTI_TENANT_ENABLED=true via validation, pass it to the tenant manager
client via WithServiceAPIKey, and cover both paths with unit tests.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@brunobls brunobls requested review from a team as code owners March 16, 2026 16:47
@coderabbitai
Copy link

coderabbitai bot commented Mar 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: a53ebdb1-5ad6-463e-abb1-d7d58c39abdd

📥 Commits

Reviewing files that changed from the base of the PR and between 45f6342 and 47c48ad.

📒 Files selected for processing (1)
  • pkg/mongodb/deadline/deadline.go

Walkthrough

This pull request introduces a new MULTI_TENANT_SERVICE_API_KEY configuration parameter used by manager and worker components. It uncomments circuit-breaker timeout settings in .env.example files, adds MultiTenantServiceAPIKey fields to Config structs, enforces validation that the key is required when MULTI_TENANT_ENABLED is true, passes the key to tenant-manager HTTP client initialization, and adds tests for the validation. The go.mod dependency for lib-commons is bumped to v4.1.0-beta.4.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant Bootstrap
participant Config
participant InitClient
participant TenantManagerService

Bootstrap->>Config: load env (includes MULTI_TENANT_SERVICE_API_KEY, MULTI_TENANT_ENABLED, CIRCUIT_BREAKER timeout)
Config-->>Bootstrap: return cfg
Bootstrap->>Config: validate()
alt MULTI_TENANT_ENABLED == true
    Config-->>Bootstrap: error if MULTI_TENANT_SERVICE_API_KEY empty
end
Bootstrap->>InitClient: newTenantManagerClient(cfg)
InitClient->>InitClient: apply circuit breaker timeout (if configured)
InitClient->>InitClient: include tmclient.WithServiceAPIKey(cfg.MultiTenantServiceAPIKey)
InitClient->>TenantManagerService: HTTP requests include service API key (when multi-tenant)
TenantManagerService-->>InitClient: response
InitClient-->>Bootstrap: client ready
🚥 Pre-merge checks | ✅ 1 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Description check ❓ Inconclusive The description follows the template structure with all checklist items completed, but lacks details about the changes in the Additional Notes section. Add a brief explanation of the multi-tenant service API key feature in the Additional Notes section to provide context for reviewers.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding multi-tenant service API key configuration and validation across manager and worker components.

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

📝 Coding Plan
  • Generate coding plan for human review comments

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

@lerian-studio
Copy link
Contributor

Consider updating CHANGELOG.md to document this change. If this change doesn't need a changelog entry, add the skip-changelog label.

@github-actions
Copy link

github-actions bot commented Mar 16, 2026

🔒 Security Scan Results — manager

Filesystem Scan

✅ No vulnerabilities or secrets found.

Docker Image Scan

✅ No vulnerabilities found.

All security checks passed.

@github-actions
Copy link

github-actions bot commented Mar 16, 2026

🔒 Security Scan Results — worker

Filesystem Scan

✅ No vulnerabilities or secrets found.

Docker Image Scan

✅ No vulnerabilities found.

All security checks passed.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@components/manager/.env.example`:
- Around line 165-167: Add a single trailing newline at the end of the
.env.example file so the file ends with a blank line; ensure the file terminates
after the last commented variable (e.g.,
MULTI_TENANT_CIRCUIT_BREAKER_TIMEOUT_SEC and MULTI_TENANT_SERVICE_API_KEY) to
satisfy dotenv-linter and standard POSIX newline expectations.

In `@components/worker/.env.example`:
- Line 124: Add a trailing newline at EOF in components/worker/.env.example to
satisfy dotenv-linter's EndingBlankLine rule; simply ensure the last line
containing "#MULTI_TENANT_SERVICE_API_KEY=" is followed by a single newline
character so the file ends with a blank line.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 702ec6d0-3c24-4c7e-b98e-f53103c1f9ec

📥 Commits

Reviewing files that changed from the base of the PR and between 5461549 and 45f6342.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • components/manager/.env.example
  • components/manager/internal/bootstrap/config.go
  • components/manager/internal/bootstrap/config_test.go
  • components/manager/internal/bootstrap/init_tenant.go
  • components/worker/.env.example
  • components/worker/internal/bootstrap/config.go
  • components/worker/internal/bootstrap/config_multitenant.go
  • components/worker/internal/bootstrap/config_test.go
  • components/worker/internal/bootstrap/config_validation.go
  • go.mod

…eter

ComputeStatus was using time.Now() internally, causing
AdvanceRecurrence tests with hardcoded dates to become flaky once
the real clock passed those dates. Accept an optional now variadic
so AdvanceRecurrence can forward its own reference time while
existing callers remain unchanged.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@lerian-studio
Copy link
Contributor

Consider updating CHANGELOG.md to document this change. If this change doesn't need a changelog entry, add the skip-changelog label.

@lerian-studio
Copy link
Contributor

📊 Unit Test Coverage Report: reporter-manager

Metric Value
Overall Coverage 87.3% ✅ PASS
Threshold 85%

Coverage by Package

Package Coverage
github.com/LerianStudio/reporter/components/manager/internal/adapters/http/in 87.3%
github.com/LerianStudio/reporter/components/manager/internal/services 88.6%

Generated by Go PR Analysis workflow

@lerian-studio
Copy link
Contributor

📊 Unit Test Coverage Report: reporter-worker

Metric Value
Overall Coverage 90.7% ✅ PASS
Threshold 85%

Coverage by Package

Package Coverage
github.com/LerianStudio/reporter/components/worker/internal/services 92.6%

Generated by Go PR Analysis workflow

Copy link
Contributor

@gandalf-at-lerian gandalf-at-lerian left a comment

Choose a reason for hiding this comment

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

Same service API key plumbing as fetcher — consistent across both repos. Bonus: ComputeStatus now accepts optional now param instead of relying on time.Now() — much better for deterministic tests. lib-commons v4 bump to beta.4. LGTM ✅

@brunobls brunobls merged commit 95be9d7 into develop Mar 16, 2026
30 checks passed
@brunobls brunobls deleted the feat/add-multi-tenant-service-api-key branch March 16, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants