Skip to content

Commit 7a8eb3f

Browse files
authored
Merge pull request #31 from coderbirju/add-namespace-option-test
add env variable parsing for healthcheck command
2 parents a038f16 + 9847ae5 commit 7a8eb3f

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/healthcheck/healthcheck_manager_linux.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,20 @@ func CreateTimer(ctx context.Context, container containerd.Container, cfg *confi
4848
containerID := container.ID()
4949
log.G(ctx).Debugf("Creating healthcheck timer unit: %s", containerID)
5050

51+
// Set all environment variables so that they are available for the nerdctl commands run via the systemd service file
5152
cmdOpts := []string{}
5253
if path := os.Getenv("PATH"); path != "" {
5354
cmdOpts = append(cmdOpts, "--setenv=PATH="+path)
5455
}
5556

57+
if nerdctlToml := os.Getenv("NERDCTL_TOML"); nerdctlToml != "" {
58+
cmdOpts = append(cmdOpts, "--setenv=NERDCTL_TOML="+nerdctlToml)
59+
}
60+
61+
if buildKitHost := os.Getenv("BUILDKIT_HOST"); buildKitHost != "" {
62+
cmdOpts = append(cmdOpts, "--setenv=BUILDKIT_HOST="+buildKitHost)
63+
}
64+
5665
// Always use health-interval for timer frequency
5766
cmdOpts = append(cmdOpts, "--unit", containerID, "--on-unit-inactive="+hc.Interval.String(), "--timer-property=AccuracySec=1s")
5867

0 commit comments

Comments
 (0)