Merge pull request #3836 from chenzhiwei/hostname

Allow customizing pod hostname
This commit is contained in:
OpenShift Merge Robot
2019-08-19 13:33:15 +02:00
committed by GitHub
8 changed files with 86 additions and 8 deletions

View File

@ -1497,6 +1497,24 @@ func WithPodName(name string) PodCreateOption {
}
}
// WithPodHostname sets the hostname of the pod.
func WithPodHostname(hostname string) PodCreateOption {
return func(pod *Pod) error {
if pod.valid {
return define.ErrPodFinalized
}
// Check the hostname against a regex
if !nameRegex.MatchString(hostname) {
return regexError
}
pod.config.Hostname = hostname
return nil
}
}
// WithPodLabels sets the labels of a pod.
func WithPodLabels(labels map[string]string) PodCreateOption {
return func(pod *Pod) error {