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

added stage field in spec and solved issue of checking duplicates of multip… #1875

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fixed errors and error logging message
  • Loading branch information
pransh62390 committed Jan 23, 2025
commit 34e2b2a3a290260e363c6827efbc810efc30c518
10 changes: 5 additions & 5 deletions backend/services/spec.go
Original file line number Diff line number Diff line change
@@ -88,7 +88,7 @@ func getVariablesSpecFromEnvMap(envVars map[string]string, stage string) []spec.

func findDuplicatesInStage(variablesSpec []spec.VariableSpec, stage string) (error) {
// Extract the names from VariableSpec
justNames := lo.Map(variablesSpec, func(item VariableSpec, i int) string {
justNames := lo.Map(variablesSpec, func(item spec.VariableSpec, i int) string {
return item.Name
})

@@ -101,7 +101,7 @@ func findDuplicatesInStage(variablesSpec []spec.VariableSpec, stage string) (err
}))

if len(duplicates) > 0 {
return fmt.Errorf("In %v stage, found duplicate variables: %v", stage, duplicates)
return fmt.Errorf("duplicate variable names found in '%s' stage: %v", stage, strings.Join(duplicates, ", "))
}

return nil // No duplicates found
@@ -119,13 +119,13 @@ func GetSpecFromJob(job models.DiggerJob) (*spec.Spec, error) {
commandVariables := getVariablesSpecFromEnvMap(jobSpec.CommandEnvVars, "commands")
runVariables := getVariablesSpecFromEnvMap(jobSpec.RunEnvVars, "run")

if err := checkDuplicatesInStage(stateVariables, "state"); err != nil {
if err := findDuplicatesInStage(stateVariables, "state"); err != nil {
return nil, err
}
if err := checkDuplicatesInStage(commandVariables, "commands"); err != nil {
if err := findDuplicatesInStage(commandVariables, "commands"); err != nil {
return nil, err
}
if err := checkDuplicatesInStage(runVariables, "run"); err != nil {
if err := findDuplicatesInStage(runVariables, "run"); err != nil {
return nil, err
}