Add --tz flag to create, run

--tz flag sets timezone inside container
Can be set to IANA timezone as well as `local` to match host machine

Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
Ashley Cui
2020-06-30 17:21:52 -04:00
parent e84695213e
commit 9a1543caec
17 changed files with 197 additions and 0 deletions

View File

@ -1525,6 +1525,30 @@ func withSetAnon() VolumeCreateOption {
}
}
// WithTimezone sets the timezone in the container
func WithTimezone(path string) CtrCreateOption {
return func(ctr *Container) error {
if ctr.valid {
return define.ErrCtrFinalized
}
if path != "local" {
zone := filepath.Join("/usr/share/zoneinfo", path)
file, err := os.Stat(zone)
if err != nil {
return err
}
//We don't want to mount a timezone directory
if file.IsDir() {
return errors.New("Invalid timezone: is a directory")
}
}
ctr.config.Timezone = path
return nil
}
}
// Pod Creation Options
// WithPodName sets the name of the pod.