Skip to content

Conversation

@lingyzhuang
Copy link
Contributor

@lingyzhuang lingyzhuang commented Dec 2, 2025

Add function ProductName in integration.go, get product name from metadata instead of hardcoded.
Jira: RHTAP-6037

Summary by CodeRabbit

  • Refactor
    • Refactored product name resolution for ACS, Trusted Artifact Signer, and Trustification integrations to use a centralized approach, improving system maintainability and consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Dec 2, 2025

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This PR refactors how product names are determined for ACS, TrustedArtifactSigner, and Trustification integrations. A new helper function ProductName() dynamically resolves product names by querying available charts and using a resolver, replacing hard-coded constants in three integration struct constructors.

Changes

Cohort / File(s) Summary
Helper Function
pkg/subcmd/integration.go
Adds ProductName(name string) helper that loads charts, iterates through them, uses a resolver to determine which product provides the given integration, and returns the product name. Updates imports to include fmt, slices, chartfs, and resolver.
Integration Constructors
pkg/subcmd/integration_acs.go, pkg/subcmd/integration_trustedartifactsigner.go, pkg/subcmd/integration_trustification.go
Each integration struct adds a new pName string field to store the product name. Constructors extended to accept pName parameter and initialize the field. Hard-coded product name constants removed. Run() methods updated to use pName field instead of constants when enabling/disabling products.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Verify the ProductName() function correctly resolves product names across all available charts
  • Confirm all three integration constructors are called with the computed product name at their call sites
  • Ensure the resolver behavior is correct and no edge cases are missed (e.g., when a product name cannot be resolved)
  • Validate that removing the hard-coded constants doesn't break any other references

Possibly related PRs

  • Disable product after adding integration #1477 — Both PRs modify the same integration product-disable flow and refactor how product names are provided/used across IntegrationACS, IntegrationTrustedArtifactSigner, and IntegrationTrustification.

Suggested labels

lgtm

Suggested reviewers

  • otaviof
  • jkopriva
  • xinredhat

Poem

🐰 Three integrations now dance with flair,
No more constants hardcoded there!
A helper function charts the way,
Dynamic product names—hip hooray! 🎉

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: removing hardcoded product names and replacing them with dynamically computed values.

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.

@openshift-ci
Copy link

openshift-ci bot commented Dec 2, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: lingyzhuang
Once this PR has been reviewed and has the lgtm label, please assign lcarva for approval. For more information see the Code Review Process.

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

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

@lingyzhuang lingyzhuang force-pushed the remove-hardcoded-product-name branch 3 times, most recently from c2893e4 to 9d371c8 Compare December 3, 2025 08:47
@lingyzhuang lingyzhuang marked this pull request as ready for review December 3, 2025 08:49
@lingyzhuang lingyzhuang requested a review from Roming22 December 3, 2025 08:50
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: 1

🧹 Nitpick comments (4)
pkg/subcmd/integration.go (1)

44-69: Resolve product names once and consider handling resolution failures per-integration

The wiring of ProductName(string(integrations.X)) into the ACS, TrustedArtifactSigner, and Trustification constructors looks consistent. Two small follow‑ups you may want to consider:

  • Resolve each product name once into a local variable before constructing the slice, instead of calling ProductName inline three times; this makes error handling and logging per integration clearer if you adopt an error‑returning ProductName.
  • If product resolution can fail in some environments (e.g., missing charts), decide whether you’d rather:
    • log and omit the affected integration subcommand, or
    • keep the subcommand but let Run fail with a clean error when EnableDisableProduct is called.

This doesn’t block the current change but will make the behavior more predictable and testable once ProductName stops panicking.

pkg/subcmd/integration_trustedartifactsigner.go (1)

22-22: pName wiring for TrustedArtifactSigner looks correct

The new pName field is correctly:

  • accepted in NewIntegrationTrustedArtifactSigner,
  • stored on the struct, and
  • used in Run via EnableDisableProduct(t.pName, false).

Assuming callers pass the resolved product name (as done in integration.go), this cleanly removes the hardcoded product constant without changing behavior.

Also applies to: 52-57, 66-71, 82-85

pkg/subcmd/integration_acs.go (1)

22-22: ACS integration now correctly uses injected product name instead of a constant

The ACS subcommand now:

  • stores pName on the struct,
  • uses a.pName when calling EnableDisableProduct, and
  • receives pName via the constructor.

This aligns with the new ProductName helper and removes the hardcoded product string without altering the run‑time flow.

Also applies to: 52-59, 68-73, 82-87

pkg/subcmd/integration_trustification.go (1)

22-22: Trustification integration follows the same configurable product-name pattern

For Trustification, pName is:

  • defined on the struct,
  • injected via NewIntegrationTrustification, and
  • used in Run in the EnableDisableProduct call.

This mirrors the ACS and TrustedArtifactSigner changes and removes the hardcoded product name cleanly.

Also applies to: 52-59, 68-73, 82-87

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 62879c4 and 9d371c8.

📒 Files selected for processing (4)
  • pkg/subcmd/integration.go (3 hunks)
  • pkg/subcmd/integration_acs.go (4 hunks)
  • pkg/subcmd/integration_trustedartifactsigner.go (4 hunks)
  • pkg/subcmd/integration_trustification.go (4 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/subcmd/integration.go (4)
pkg/chartfs/chartfs.go (1)
  • NewChartFSForCWD (164-170)
pkg/resolver/dependency.go (1)
  • NewDependency (105-107)
pkg/integrations/manager.go (3)
  • ACS (25-25)
  • TrustedArtifactSigner (34-34)
  • Trustification (35-35)
pkg/subcmd/integration_trustification.go (1)
  • NewIntegrationTrustification (68-90)
🪛 GitHub Check: SonarCloud Code Analysis
pkg/subcmd/integration.go

[failure] 23-23: Return an error instead of using panic for normal error conditions.

See more on https://sonarcloud.io/project/issues?id=redhat-appstudio_rhtap-cli&issues=AZriOUd_DZwLf3i1ShNs&open=AZriOUd_DZwLf3i1ShNs&pullRequest=1565


[failure] 33-33: Return an error instead of using panic for normal error conditions.

See more on https://sonarcloud.io/project/issues?id=redhat-appstudio_rhtap-cli&issues=AZrfxzk3E71EE0vcRuFR&open=AZrfxzk3E71EE0vcRuFR&pullRequest=1565


[failure] 19-19: Return an error instead of using panic for normal error conditions.

See more on https://sonarcloud.io/project/issues?id=redhat-appstudio_rhtap-cli&issues=AZrfxzk3E71EE0vcRuFP&open=AZrfxzk3E71EE0vcRuFP&pullRequest=1565

@lingyzhuang lingyzhuang force-pushed the remove-hardcoded-product-name branch from 9d371c8 to 844ec49 Compare December 5, 2025 04:17
@sonarqubecloud
Copy link

sonarqubecloud bot commented Dec 5, 2025

@konflux-ci-qe-bot
Copy link

@lingyzhuang: The following test has Failed, say /retest to rerun failed tests.

PipelineRun Name Status Rerun command Build Log Test Log
e2e-4.19-w7mlg Failed /retest View Pipeline Log View Test Logs

Inspecting Test Artifacts

To inspect your test artifacts, follow these steps:

  1. Install ORAS (see the ORAS installation guide).
  2. Download artifacts with the following commands:
mkdir -p oras-artifacts
cd oras-artifacts
oras pull quay.io/konflux-test-storage/rhtap-team/rhtap-cli:e2e-4.19-w7mlg

Test results analysis

<not enabled>

OCI Artifact Browser URL

<not enabled>

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.

2 participants