mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
Merge pull request #3836 from chenzhiwei/hostname
Allow customizing pod hostname
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user