diff --git a/cmd/execute.go b/cmd/execute.go index e9bb985..d182795 100644 --- a/cmd/execute.go +++ b/cmd/execute.go @@ -30,7 +30,7 @@ func getExecuteCmd() *cobra.Command { Use: "execute", Short: "Execute pipeline based on the specified recipe", RunE: func(cmd *cobra.Command, args []string) error { - return executePipeline(recipePath, batchSize, progressType, nil) + return executePipeline(recipePath, progressType, batchSize, nil) }, } runCmd.PersistentFlags().StringVarP(&recipePath, "recipe-path", "R", defaultRecipePath, "Path of the recipe file") @@ -41,7 +41,7 @@ func getExecuteCmd() *cobra.Command { return runCmd } -func executePipeline(recipePath string, batchSize int, progressType string, enrich func(*recipe.Recipe) error) error { +func executePipeline(recipePath, progressType string, batchSize int, enrich func(*recipe.Recipe) error) error { rcp, err := loadRecipe(recipePath, defaultRecipeType, defaultRecipeFormat) if err != nil { return err diff --git a/cmd/profile.go b/cmd/profile.go index 513e590..89fdb1e 100644 --- a/cmd/profile.go +++ b/cmd/profile.go @@ -32,8 +32,6 @@ func getProfileCmd() *cobra.Command { }, } runCmd.PersistentFlags().StringVarP(&recipePath, "recipe-path", "R", defaultRecipePath, "Path of the recipe file") - - runCmd.AddCommand(getResourceCmd()) return runCmd } diff --git a/cmd/resource.go b/cmd/resource.go index 77ad369..f6bc4a5 100644 --- a/cmd/resource.go +++ b/cmd/resource.go @@ -1,10 +1,8 @@ package cmd import ( - "errors" "fmt" - "github.com/gojek/optimus-extension-valor/model" "github.com/gojek/optimus-extension-valor/recipe" "github.com/spf13/cobra" @@ -36,11 +34,7 @@ func getResourceCmd() *cobra.Command { Path: path, }) } - err := executePipeline(recipePath, batchSize, progressType, enrich) - if e, ok := err.(*model.Error); ok { - return errors.New(string(e.JSON())) - } - return err + return executePipeline(recipePath, progressType, batchSize, enrich) }, } resourceCmd.Flags().StringVarP(&name, "name", "n", "", "name of the resource recipe to be used") diff --git a/core/core.go b/core/core.go index 9b617d1..4f4c15c 100644 --- a/core/core.go +++ b/core/core.go @@ -200,6 +200,7 @@ func (p *Pipeline) executeOnResource(resourceRcp *recipe.Resource, nameToValidat counter += batch } progress.Wait() + if outputError.Length() > 0 { return outputError } @@ -244,10 +245,11 @@ func (p *Pipeline) getFrameworkNameToEvaluator(nameToFramework map[string]*model } }(name, framework, wg, mtx) } + wg.Wait() + if outputError.Length() > 0 { return nil, outputError } - wg.Wait() return outputEvaluator, nil } diff --git a/model/error.go b/model/error.go index 6330668..89850d8 100644 --- a/model/error.go +++ b/model/error.go @@ -61,7 +61,7 @@ func (e *Error) Length() int { func (e *Error) buildMap() map[string]interface{} { output := make(map[string]interface{}) for key, value := range e.keyToValue { - if customErr, ok := value.(Error); ok { + if customErr, ok := value.(*Error); ok { mV := customErr.buildMap() output[key] = mV } else {