Skip to content

Commit 87c9109

Browse files
authored
Expose ready check to manifest (#130)
1 parent 9cc6639 commit 87c9109

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

internal/local_runner.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ func (d *LocalRunner) AreReady() bool {
313313

314314
// then ensure it is ready if it has a ready function
315315
svc := d.getService(name)
316-
if svc.readyCheck != nil {
316+
if svc.ReadyCheck != nil {
317317
if !task.ready {
318318
return false
319319
}
@@ -647,21 +647,21 @@ func (d *LocalRunner) toDockerComposeService(s *Service) (map[string]interface{}
647647
service["environment"] = envs
648648
}
649649

650-
if s.readyCheck != nil {
650+
if s.ReadyCheck != nil {
651651
var test []string
652-
if s.readyCheck.QueryURL != "" {
652+
if s.ReadyCheck.QueryURL != "" {
653653
// This is pretty much hardcoded for now.
654-
test = []string{"CMD-SHELL", "chmod +x /artifacts/scripts/query.sh && /artifacts/scripts/query.sh " + s.readyCheck.QueryURL}
654+
test = []string{"CMD-SHELL", "chmod +x /artifacts/scripts/query.sh && /artifacts/scripts/query.sh " + s.ReadyCheck.QueryURL}
655655
} else {
656-
test = s.readyCheck.Test
656+
test = s.ReadyCheck.Test
657657
}
658658

659659
service["healthcheck"] = map[string]interface{}{
660660
"test": test,
661-
"interval": s.readyCheck.Interval.String(),
662-
"timeout": s.readyCheck.Timeout.String(),
663-
"retries": s.readyCheck.Retries,
664-
"start_period": s.readyCheck.StartPeriod.String(),
661+
"interval": s.ReadyCheck.Interval.String(),
662+
"timeout": s.ReadyCheck.Timeout.String(),
663+
"retries": s.ReadyCheck.Retries,
664+
"start_period": s.ReadyCheck.StartPeriod.String(),
665665
}
666666
}
667667

internal/manifest.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ func (s *Manifest) Validate() error {
142142

143143
if dep.Condition == DependsOnConditionHealthy {
144144
// if we depedn on the service to be healthy, it must have a ready check
145-
if service.readyCheck == nil {
145+
if service.ReadyCheck == nil {
146146
return fmt.Errorf("service %s depends on service %s, but it does not have a ready check", ss.Name, dep.Name)
147147
}
148148
}
@@ -246,7 +246,7 @@ type Service struct {
246246
// list of environment variables to set for the service
247247
Env map[string]string `json:"env,omitempty"`
248248

249-
readyCheck *ReadyCheck
249+
ReadyCheck *ReadyCheck `json:"ready_check,omitempty"`
250250

251251
DependsOn []DependsOn `json:"depends_on,omitempty"`
252252

@@ -408,17 +408,17 @@ func (s *Service) WithArtifact(localPath string, artifactName string) *Service {
408408
}
409409

410410
func (s *Service) WithReady(check ReadyCheck) *Service {
411-
s.readyCheck = &check
411+
s.ReadyCheck = &check
412412
return s
413413
}
414414

415415
type ReadyCheck struct {
416-
QueryURL string
417-
Test []string
418-
Interval time.Duration
419-
StartPeriod time.Duration
420-
Timeout time.Duration
421-
Retries int
416+
QueryURL string `json:"query_url"`
417+
Test []string `json:"test"`
418+
Interval time.Duration `json:"interval"`
419+
StartPeriod time.Duration `json:"start_period"`
420+
Timeout time.Duration `json:"timeout"`
421+
Retries int `json:"retries"`
422422
}
423423

424424
func (s *Service) DependsOnHealthy(name string) *Service {

0 commit comments

Comments
 (0)