Skip to content

Helm converter for exporting Meshery Designs #717

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

fyzanshaik
Copy link

@fyzanshaik fyzanshaik commented Apr 10, 2025

Description

This PR fixes #14206

Notes for Reviewers

Signed commits

  • Yes, I signed my commits.

Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Copy link

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

Choose a reason for hiding this comment

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

Hello @fyzanshaik, 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!

Summary of Changes

This pull request introduces a Helm converter that exports Meshery Designs into Helm charts. It takes a pattern file as input, converts it to a Kubernetes manifest, and then packages it into a Helm chart. The chart includes a Chart.yaml file with metadata, a values.yaml file for default values, a manifest.yaml file containing the Kubernetes manifest, and helper templates. The generated chart is then packaged and saved as a .tgz file.

Highlights

  • Helm Conversion: Implements the core logic for converting Meshery Designs to Helm charts.
  • Chart Creation: Creates the necessary files and directories for a valid Helm chart, including Chart.yaml, values.yaml, and a templates directory.
  • Packaging: Packages the generated Helm chart into a .tgz archive using the Helm SDK.
  • Sanitization: Includes a function to sanitize the Helm chart name based on the Meshery Design name.

Changelog

Click here to see the changelog
  • converter/helm.go
    • Implements the HelmConverter struct and its Convert method.
    • Uses the K8sConverter to generate a Kubernetes manifest from the Meshery Design.
    • Creates a temporary directory structure for building the Helm chart.
    • Generates Chart.yaml with metadata extracted from the Meshery Design.
    • Creates a default values.yaml file.
    • Writes the Kubernetes manifest to templates/manifest.yaml.
    • Adds helper templates for chart labels and name.
    • Packages the chart using the Helm SDK.
    • Returns the packaged chart data as a byte array.
    • Includes a sanitizeHelmName function to ensure the chart name is valid.
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 in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

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 is currently in preview and may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments to provide feedback.

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.


A chart for the helm,
From designs, a new realm,
K8s takes flight,
With manifests bright,
A package to overwhelm.

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.

Copy link

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

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 a Helm converter for exporting Meshery Designs. The code is well-structured and addresses the intended functionality. However, there are a few areas that could benefit from improvement to enhance robustness and maintainability.

Summary of Findings

  • Error Handling: The code includes error handling, but there are instances where more specific error messages could provide better context for debugging.
  • Code Clarity: Some sections of the code could be made more readable with additional comments or minor refactoring.
  • Resource Cleanup: While the code attempts to clean up temporary resources, ensuring comprehensive cleanup in all scenarios is crucial.

Merge Readiness

The pull request is almost ready for merging. Addressing the identified issues, particularly those related to error handling and resource cleanup, would significantly improve the code's reliability. I am unable to directly approve this pull request, and recommend that others review and approve this code before merging. At a minimum, the high severity issues should be addressed before merging.

Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
@fyzanshaik fyzanshaik self-assigned this Apr 10, 2025
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
@leecalcote leecalcote requested review from n2h9 and Tanishq1604 April 10, 2025 16:28
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
@fyzanshaik
Copy link
Author

/gemini review

Copy link

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

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 a Helm converter for exporting Meshery Designs, which enhances Meshery's capabilities. The implementation appears well-structured, with clear error handling and temporary directory management. However, there are a few areas that could be improved for robustness and clarity.

Summary of Findings

  • Error Handling for k8s Manifest Converter: The TODO comment in converter/errors.go indicates a need for error handling functions for the k8s manifest converter. Implementing these functions would improve the reliability and maintainability of the code.
  • Resource Cleanup: While the code includes a defer function to remove the build directory, there's a potential issue if the program exits before this function is executed. Ensuring more robust cleanup mechanisms would enhance the stability of the converter.
  • Error Severity Level: The ErrHelmPackage is marked as Alert severity, but packaging failures can have significant consequences. Consider increasing the severity level to Critical to reflect the potential impact.

Merge Readiness

The pull request introduces valuable functionality to Meshery. However, addressing the identified issues, particularly the error handling for the k8s manifest converter and the resource cleanup, would significantly improve the code's reliability. I recommend addressing these issues before merging. I am unable to approve this pull request, and other reviewers should review and approve this code before merging.

@fyzanshaik
Copy link
Author

fyzanshaik commented Apr 13, 2025

@aabidsofi19 All requested changes have been made. Error codes are left currently as I have no knowledge about them. Need your assistance, also would like to know if we should add Error handling functions for k8s-manifest too in this PR?

Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
@n2h9
Copy link

n2h9 commented Apr 13, 2025

Error codes are left currently as I have no knowledge about them.

Hey @fyzanshaik hello 😇 👋 !

I think you need to

  • rename your file with errors from errors.go to error.go
  • put a placeholder to your error codes, any of this will work fine: "meshkit-replace-me", "meshkit-replace_me", "replace-me", "replace_me".
  • run the command make errorutil

it will replace the placeholders with correct codes.

You could also reference to this guide: https://docs.meshery.io/project/contributing/contributing-error

Signed-off-by: fyzanshaik <fyzan.shaik@gmail.com>
@n2h9
Copy link

n2h9 commented Apr 13, 2025

Hey @fyzanshaik hello 👋 😇 !

Great progress 🤗 !

Maybe it makes sense to add a unit test for HelmConverter: smth like give a test pattern file and check the converted chart content, what do you think?

@fyzanshaik
Copy link
Author

@n2h9 Sounds great I am not sure about how I can write tests will let you know!

@leecalcote
Copy link
Member

@n2h9 excellent reviews. 👍

@leecalcote
Copy link
Member

...

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.

5 participants