Skip to content

Commit

Permalink
Add check for when no port is specified for job or healthcheck and fi…
Browse files Browse the repository at this point in the history
…x integration test
  • Loading branch information
CelineWuest committed Aug 22, 2024
1 parent 5bdd501 commit abdf706
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions pkg/biscepter/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func GetJobFromConfig(r io.Reader) (*Job, error) {
job.Ports = []int{config.Port}
}

if len(job.Ports) == 0 {
return nil, fmt.Errorf("no port specified for job")
}

// Set all the healthchecks
checkTypes := map[string]HealthcheckType{
"http": HttpGet200,
Expand All @@ -86,6 +90,10 @@ func GetJobFromConfig(r io.Reader) (*Job, error) {
return nil, fmt.Errorf("invalid check type supplied for healthcheck %s", check.Type)
}

if check.Port == 0 {
return nil, fmt.Errorf("no port specified for healthcheck %#v", check)
}

job.Healthchecks = append(job.Healthchecks, Healthcheck{
Port: check.Port,
CheckType: checkType,
Expand Down
2 changes: 1 addition & 1 deletion pkg/biscepter/job_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func TestRunCommitByOffset(t *testing.T) {
Ports: []int{3333},

Healthchecks: []biscepter.Healthcheck{
{CheckType: biscepter.Script, Data: "true", Config: biscepter.HealthcheckConfig{Retries: 50, Backoff: 10 * time.Millisecond, MaxBackoff: 10 * time.Millisecond}},
{CheckType: biscepter.Script, Port: 3333, Data: "true", Config: biscepter.HealthcheckConfig{Retries: 50, Backoff: 10 * time.Millisecond, MaxBackoff: 10 * time.Millisecond}},
},

CommitReplacementsBackup: "/dev/null",
Expand Down

0 comments on commit abdf706

Please sign in to comment.