Repository: compose-spec/compose-go
Pull request #437 (2023-07-13 22:54:12)

add support of healthcheck.start_interval attribut
Implementation of https://github.com/compose-spec/compose-spec/pull/383


Patch:
diff --git a/loader/full-example.yml b/loader/full-example.yml
index 9f818f8..c1e5914 100644
--- a/loader/full-example.yml
+++ b/loader/full-example.yml
@@ -181,6 +181,7 @@ services:
       timeout: 1s
       retries: 5
       start_period: 15s
+      start_interval: 5s
 
     # Any valid image reference - repo, tag, id, sha
     image: redis
diff --git a/schema/compose-spec.json b/schema/compose-spec.json
index d71f2bf..d39aa35 100644
--- a/schema/compose-spec.json
+++ b/schema/compose-spec.json
@@ -457,7 +457,8 @@
           ]
         },
         "timeout": {"type": "string", "format": "duration"},
-        "start_period": {"type": "string", "format": "duration"}
+        "start_period": {"type": "string", "format": "duration"},
+        "start_interval": {"type": "string", "format": "duration"}
       },
       "additionalProperties": false,
       "patternProperties": {"^x-": {}}
diff --git a/types/types.go b/types/types.go
index 394a039..a9a515f 100644
--- a/types/types.go
+++ b/types/types.go
@@ -603,12 +603,13 @@ type DeployConfig struct {
 
 // HealthCheckConfig the healthcheck configuration for a service
 type HealthCheckConfig struct {
-	Test        HealthCheckTest `yaml:"test,omitempty" json:"test,omitempty"`
-	Timeout     *Duration       `yaml:"timeout,omitempty" json:"timeout,omitempty"`
-	Interval    *Duration       `yaml:"interval,omitempty" json:"interval,omitempty"`
-	Retries     *uint64         `yaml:"retries,omitempty" json:"retries,omitempty"`
-	StartPeriod *Duration       `yaml:"start_period,omitempty" json:"start_period,omitempty"`
-	Disable     bool            `yaml:"disable,omitempty" json:"disable,omitempty"`
+	Test          HealthCheckTest `yaml:"test,omitempty" json:"test,omitempty"`
+	Timeout       *Duration       `yaml:"timeout,omitempty" json:"timeout,omitempty"`
+	Interval      *Duration       `yaml:"interval,omitempty" json:"interval,omitempty"`
+	Retries       *uint64         `yaml:"retries,omitempty" json:"retries,omitempty"`
+	StartPeriod   *Duration       `yaml:"start_period,omitempty" json:"start_period,omitempty"`
+	StartInterval *Duration       `yaml:"start_interval,omitempty" json:"start_interval,omitempty"`
+	Disable       bool            `yaml:"disable,omitempty" json:"disable,omitempty"`
 
 	Extensions Extensions `yaml:"#extensions,inline" json:"-"`
 }


Test patch:
diff --git a/loader/full-struct_test.go b/loader/full-struct_test.go
index 513e245..db8d204 100644
--- a/loader/full-struct_test.go
+++ b/loader/full-struct_test.go
@@ -195,11 +195,12 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
 				"x-foo": "bar",
 			},
 			HealthCheck: &types.HealthCheckConfig{
-				Test:        types.HealthCheckTest([]string{"CMD-SHELL", "echo \"hello world\""}),
-				Interval:    durationPtr(10 * time.Second),
-				Timeout:     durationPtr(1 * time.Second),
-				Retries:     uint64Ptr(5),
-				StartPeriod: durationPtr(15 * time.Second),
+				Test:          types.HealthCheckTest([]string{"CMD-SHELL", "echo \"hello world\""}),
+				Interval:      durationPtr(10 * time.Second),
+				Timeout:       durationPtr(1 * time.Second),
+				Retries:       uint64Ptr(5),
+				StartPeriod:   durationPtr(15 * time.Second),
+				StartInterval: durationPtr(5 * time.Second),
 			},
 			Hostname: "foo",
 			Image:    "redis",
@@ -751,6 +752,7 @@ services:
       interval: 10s
       retries: 5
       start_period: 15s
+      start_interval: 5s
     image: redis
     ipc: host
     labels:
@@ -1358,7 +1360,8 @@ func fullExampleJSON(workingDir, homeDir string) string {
         "timeout": "1s",
         "interval": "10s",
         "retries": 5,
-        "start_period": "15s"
+        "start_period": "15s",
+        "start_interval": "5s"
       },
       "image": "redis",
       "ipc": "host",