Skip to content

Commit

Permalink
Merge pull request #35 from MUzairS15/MUzairS15/plugin
Browse files Browse the repository at this point in the history
Fix issues with helm plugin.
  • Loading branch information
Aijeyomah authored Oct 11, 2024
2 parents 50a4e20 + 571eafd commit 569ddcf
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
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."},
)
}

0 comments on commit 569ddcf

Please sign in to comment.