Skip to content
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

Fix issues with helm plugin. #35

Merged
merged 10 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions .github/workflows/error-codes-updater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ jobs:

- name: Run Utility For Plugin
run: |
cd ./cmd
~/errorutil update -d . -i ./helpers -o ./helpers
output=$(~/errorutil -d . analyze -i ./helpers -o ./helpers | wc -c)
if [ "$output" -ne 0 ]; then
exit 1
fi
echo '{ "errors_export": "" }' | jq --slurpfile export ../server/helpers/errorutil_errors_export.json '.errors_export = $export[0]' > ../docs/_data/errorref/mesheryctl_errors_export.json
echo '{ "errors_export": "" }' | jq --slurpfile export ./helpers/errorutil_errors_export.json '.errors_export = $export[0]' > ./helpers/errorutil_errors_export.json

- name: Pull changes from remote
run: git pull origin master
Expand All @@ -54,7 +53,7 @@ jobs:
if: ${{ github.event_name != 'pull_request' }} # Skip for pull requests
uses: stefanzweifel/git-auto-commit-action@v5
with:
file_pattern: mesheryctl/helpers server/helpers/ **.go docs/
file_pattern: helpers
commit_user_name: l5io
commit_user_email: ci@layer5.io
commit_author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
Expand Down
9 changes: 7 additions & 2 deletions cmd/kanvas-snapshot/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ var generateKanvasSnapshotCmd = &cobra.Command{
Flags:
-f, --file string URI to Helm chart (required)
-n, --name string (optional name for the Meshery design
-e, --email string (optional) email address to notify when snapshot is ready
-e, --email string email address to notify when snapshot is ready (required)
-h Help for Helm Kanvas Snapshot plugin`,

RunE: func(cmd *cobra.Command, args []string) error {
Log = log.SetupMeshkitLogger("helm-kanvas-snapshot", false, os.Stdout)
// Use the extracted name from URI if not provided
if designName == "" {
designName = ExtractNameFromURI(chartURI)
Expand Down Expand Up @@ -271,3 +270,9 @@ func main() {
}

}

func init() {
cobra.OnInitialize(func() {
Log = log.SetupMeshkitLogger("helm-kanvas-snapshot", false, os.Stdout)
})
}
File renamed without changes.
File renamed without changes.
22 changes: 16 additions & 6 deletions internal/errors/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
)

var (
ErrInvalidChartURICode = "kanvas-snapshot-900"
ErrCreatingMesheryDesignCode = "kanvas-snapshot-901"
ErrGeneratingSnapshotCode = "kanvas-snapshot-902"
ErrHTTPPostRequestCode = "kanvas-snapshot-903"
ErrDecodingAPICode = "kanvas-snapshot-905"
ErrUnexpectedResponseCodeCode = "kanvas-snapshot-906"
ErrInvalidChartURICode = "kanvas-snapshot-900"
ErrCreatingMesheryDesignCode = "kanvas-snapshot-901"
ErrGeneratingSnapshotCode = "kanvas-snapshot-902"
ErrHTTPPostRequestCode = "kanvas-snapshot-903"
ErrDecodingAPICode = "kanvas-snapshot-905"
ErrUnexpectedResponseCodeCode = "kanvas-snapshot-906"
ErrRequiredFieldNotProvidedCode = "kanvas-snapshot-907"
)

func ErrInvalidChartURI(err error) error {
Expand Down Expand Up @@ -68,3 +69,12 @@ func ErrUnexpectedResponseCode(statusCode int, body string) error {
[]string{"Check the request details and ensure the Meshery API is functioning correctly."},
)
}

func ErrRequiredFieldNotProvided(err error, field string) error {
return errors.New(ErrRequiredFieldNotProvidedCode, errors.Alert,
[]string{"All required flags are not passed."},
[]string{err.Error()},
[]string{"Required flag \"%s\" is not passed."},
[]string{"Ensure value for flag \"%s\" is correctly provided."},
)
}
Loading