Skip to content

Commit

Permalink
fix: bug caused by error loading evaluator
Browse files Browse the repository at this point in the history
  • Loading branch information
irainia committed Mar 17, 2022
1 parent 4f87f21 commit 7b4719b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 13 deletions.
4 changes: 2 additions & 2 deletions cmd/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down
2 changes: 0 additions & 2 deletions cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
8 changes: 1 addition & 7 deletions cmd/resource.go
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 3 additions & 1 deletion core/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ func (p *Pipeline) executeOnResource(resourceRcp *recipe.Resource, nameToValidat
counter += batch
}
progress.Wait()

if outputError.Length() > 0 {
return outputError
}
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion model/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 7b4719b

Please sign in to comment.