Skip to content

Commit

Permalink
Issue #166: added disabled dependency validation
Browse files Browse the repository at this point in the history
  • Loading branch information
F1bonacc1 committed Mar 25, 2024
1 parent caa1a4d commit 118a3aa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 0 deletions.
21 changes: 21 additions & 0 deletions issues/issue_166/process-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
is_strict: true

processes:
pc_log:
command: "tail -f -n100 process-compose-${USER}.log"
working_dir: "/tmp"
test:
command: |
echo "TOTO"
sleep 40
depends_on:
runtrial:
# condition: toto # this is accepted and doesn't trigger any error even though
condition: process_completed_successfully

# one shot task, hence why we disable it now
runtrial:
namespace: task
disabled: true
command:
echo "TRIAL DONE"
1 change: 1 addition & 0 deletions src/loader/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func Load(opts *LoaderOptions) (*types.Project, error) {
validateShellConfig,
validatePlatformCompatibility,
validateHealthDependencyHasHealthCheck,
validateDependencyIsEnabled,
)
admitProcesses(opts, mergedProject)
return mergedProject, err
Expand Down
24 changes: 24 additions & 0 deletions src/loader/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,27 @@ func validateHealthDependencyHasHealthCheck(p *types.Project) error {
}
return nil
}

func validateDependencyIsEnabled(p *types.Project) error {
for procName, proc := range p.Processes {
for depName := range proc.DependsOn {
depProc, ok := p.Processes[depName]
if !ok {
errStr := fmt.Sprintf("dependency process '%s' in process '%s' is not defined", depName, procName)
if p.IsStrict {
return fmt.Errorf(errStr)
}
log.Error().Msg(errStr)
continue
}
if depProc.Disabled {
errStr := fmt.Sprintf("dependency process '%s' in process '%s' is disabled", depName, procName)
if p.IsStrict {
return fmt.Errorf(errStr)
}
log.Error().Msg(errStr)
}
}
}
return nil
}

0 comments on commit 118a3aa

Please sign in to comment.