Skip to content

feat(ci): allow for multiple artifacthub-values files#1419

Merged
cwrau merged 1 commit intomainfrom
feat/ci/allow-for-multiple-artifacthub-values
May 28, 2025
Merged

feat(ci): allow for multiple artifacthub-values files#1419
cwrau merged 1 commit intomainfrom
feat/ci/allow-for-multiple-artifacthub-values

Conversation

@cwrau
Copy link
Copy Markdown
Member

@cwrau cwrau commented Mar 19, 2025

this allows to extract images from mutually exclusive options

Summary by CodeRabbit

  • New Features
    • Enhanced the chart update process to consolidate image configuration data, streamlining how annotations are applied.
    • Improved support for processing multiple configuration files during releases, ensuring more reliable and consistent updates.

this allows to extract images from mutually exclusive options
@cwrau cwrau requested a review from a team as a code owner March 19, 2025 15:09
@cwrau cwrau requested a review from SyeKlu March 19, 2025 15:09
@cwrau cwrau enabled auto-merge (squash) March 19, 2025 15:09
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 19, 2025

Walkthrough

The pull request updates the image extraction script by enhancing its functions. The getImages function now accepts an additional parameter and uses it to determine the directory path for processing image values, while its conditional checks are revised. The updateChartYaml function now iterates over multiple YAML files to update annotations in the chart, aggregating image data into a unified file. Error handling is added when no values files are found, streamlining the overall image annotation process.

Changes

File Changes Summary
.github/scripts/extract-artifacthub-…sh - getImages: Added a third parameter (valuesFile), updated directory existence checks and helm YAML generation logic to include this parameter.
- updateChartYaml: Replaced previous annotation logic with a loop over multiple artifacthub-values YAML files, aggregates results into an allImages file, and exits with an error if none are found.

Sequence Diagram(s)

sequenceDiagram
    participant S as Script
    participant GI as getImages
    participant UT as updateChartYaml
    participant A as ArtifactHub YAML Files
    participant C as Chart.yaml

    S->>GI: Call getImages(valuesFile)
    GI->>GI: Check if existingValuesDir is a directory
    GI->>S: Return image data (allImages)
    S->>UT: Call updateChartYaml(allImages)
    UT->>A: Loop through artifacthub-values YAML files
    A-->>UT: Return values data
    UT->>C: Update annotations with aggregated images data
Loading

Poem

I'm the rabbit of code, hopping on a spree,
Extracting images and charts so effortlessly.
With values and YAML files in a delightful loop,
My code dance is graceful, a merry little swoop!
In every line and byte, I find joy to decree.
🐇💻 Happy hops in every commit, come join with glee!

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@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: 0

🔭 Outside diff range comments (1)
.github/scripts/extract-artifacthub-images.sh (1)

75-77: 🛠️ Refactor suggestion

Existence Check for Artifacthub-Values File in Main Block:
The script verifies the existence of a single file:

if ! [[ -f "$1/ci/artifacthub-values.yaml" ]]; then

Given the PR’s aim to support multiple artifacthub-values files (using a glob pattern later in the script), consider updating this check to either:

  • Allow for multiple matching files, or
  • Clarify in documentation that one file with the name artifacthub-values.yaml is mandatory even when additional files may be processed.
🧹 Nitpick comments (5)
.github/scripts/extract-artifacthub-images.sh (5)

19-25: Conditional Handling of Existing Directory vs. Helm Chart Generation:
Within getImages, the conditional block checks if an existing directory (derived from parameter 2) is present. If it exists, the script copies it; otherwise, it falls back to generating a helm release YAML (using templateLocalHelmChart and splitYamlIntoDir). This approach effectively supports both scenarios.

One suggestion: consider adding a brief comment or error message for cases where $2 is provided but existingValuesDir isn’t a directory, to improve clarity for future debugging.


30-33: Grep Pipeline for Image Extraction:
Inside the subshell, the script changes into the temporary helm release directory and uses a grep pipeline to extract lines containing an image reference while filtering out lines with "artifacthub-ignore". The added error handler

|| { if [[ "$?" == 2 ]]; then exit 2; fi; }

aims to catch a specific grep error. However, this construct can be brittle since it relies on the exit status of the pipeline; consider capturing and checking the exit status explicitly with a comment clarifying the intent.


40-51: Iterating Over Multiple Artifacthub-Values Files in updateChartYaml:
The function now creates a temporary file (all_images.yaml) and iterates over files matching the glob

"$chart/ci/artifacthub-values"*.yaml

to process multiple values files. This is a step toward more flexible configuration. A couple of points to verify:

  • Confirm that the shell’s globbing behavior (or options like nullglob, if set) won’t cause unexpected iteration over the literal pattern when no files match.
  • Ensure that users are aware of the naming convention (filenames starting with artifacthub-values) required for the new functionality.

51-60: Consolidation Pipeline for Image Data:
The output from getImages is piped through a series of commands—awk, tr, sed, sort, uniq, column, jq, and yq—to aggregate image data into a single file. Please verify that:

  • The awk command correctly parses the expected fields from the output of getImages.
  • The successive transformations (especially filtering and formatting) match the intended image structure for annotations.

Adding inline comments to break down this pipeline might help improve maintainability and ease troubleshooting in the future.


85-95: Processing Multiple Charts in the Absence of Direct Parameters:
In the else branch, the script iterates over all charts in the charts/ directory and processes those with an artifacthub-values.yaml file. Given the support for multiple values files, please confirm that this branch and its file existence check remain consistent with the new multi-file handling logic across all charts.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e6e619 and ea7f841.

📒 Files selected for processing (1)
  • .github/scripts/extract-artifacthub-images.sh (3 hunks)
🔇 Additional comments (3)
.github/scripts/extract-artifacthub-images.sh (3)

13-17: Parameter Handling and Computation of existingValuesDir in getImages:
The function now extracts both existingDir (from parameter 2) and valuesFile (from parameter 3) and computes existingValuesDir as

existingValuesDir="$2/$(basename --suffix=.yaml "$valuesFile")"

Please ensure that:

  • valuesFile always ends with a .yaml suffix so that basename strips it correctly.
  • The case when $2 is empty is handled gracefully downstream.

62-63: Updating Chart.yaml with Aggregated Image Annotations:
The final yq command updates the Chart.yaml file by injecting a new annotation (artifacthub.io/images) with the contents of allImages. Double-check that the sub("\\s*$"; "") expression properly trims trailing whitespace as intended and that the raw file content is correctly interpreted by yq.


79-81: Validation of Provided Artifacthub-Values Directory:
The check

if [[ -v 2 && ! -d "$2/artifacthub-values" ]]; then

ensures that if a second parameter is provided, it must include an artifacthub-values subdirectory. This validation appears sound; just ensure that the expected directory structure is well documented for users.

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