diff --git a/.github/workflows/error-codes-updater.yaml b/.github/workflows/error-codes-updater.yaml index 132ba0ffc5..f283a0284c 100644 --- a/.github/workflows/error-codes-updater.yaml +++ b/.github/workflows/error-codes-updater.yaml @@ -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 @@ -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> diff --git a/cmd/kanvas-snapshot/main.go b/cmd/kanvas-snapshot/main.go index fcfea0b04b..ed87547d81 100644 --- a/cmd/kanvas-snapshot/main.go +++ b/cmd/kanvas-snapshot/main.go @@ -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) @@ -271,3 +270,9 @@ func main() { } } + +func init() { + cobra.OnInitialize(func() { + Log = log.SetupMeshkitLogger("helm-kanvas-snapshot", false, os.Stdout) + }) +} diff --git a/build/Makefile.core.mk b/helpers/Makefile.core.mk similarity index 100% rename from build/Makefile.core.mk rename to helpers/Makefile.core.mk diff --git a/build/component_info.json b/helpers/component_info.json similarity index 100% rename from build/component_info.json rename to helpers/component_info.json diff --git a/internal/errors/error.go b/internal/errors/error.go index 7338417035..001a987f7c 100644 --- a/internal/errors/error.go +++ b/internal/errors/error.go @@ -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 { @@ -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."}, + ) +}