summaryrefslogtreecommitdiff
path: root/libpod/options.go
diff options
context:
space:
mode:
authorbaude <bbaude@redhat.com>2018-01-19 08:51:59 -0600
committerAtomic Bot <atomic-devel@projectatomic.io>2018-01-19 15:42:25 +0000
commita4701b56311d5d934543e2b4306b08baa844ec3f (patch)
treebcad38f7cf02a37107bfa61854a01eb58bf9868f /libpod/options.go
parent1710acd18a4630ef704c66bf0cdae76dd658776a (diff)
downloadpodman-a4701b56311d5d934543e2b4306b08baa844ec3f.tar.gz
podman-a4701b56311d5d934543e2b4306b08baa844ec3f.tar.bz2
podman-a4701b56311d5d934543e2b4306b08baa844ec3f.zip
Add --dns-search, --dns-opt, --dns-server and --add-host.
Each of these options are destructive in nature, meaning if the user adds one of them, all current ones are removed from the produced resolv.conf. * dns-server allows the user to specify dns servers. * dns-opt allows the user to specify special resolv.conf options * dns-search allows the user to specify search domains The add-host option is not destructive and truly just adds the host to /etc/hosts. Signed-off-by: baude <bbaude@redhat.com> Closes: #231 Approved by: mheon
Diffstat (limited to 'libpod/options.go')
-rw-r--r--libpod/options.go53
1 files changed, 53 insertions, 0 deletions
diff --git a/libpod/options.go b/libpod/options.go
index ca4d104df..63a72628f 100644
--- a/libpod/options.go
+++ b/libpod/options.go
@@ -1,6 +1,7 @@
package libpod
import (
+ "net"
"path/filepath"
"regexp"
"syscall"
@@ -641,3 +642,55 @@ func WithPodLabels(labels map[string]string) PodCreateOption {
return nil
}
}
+
+// WithDNSSearch sets the additional search domains of a container
+func WithDNSSearch(searchDomains []string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+ ctr.config.DNSSearch = searchDomains
+ return nil
+ }
+}
+
+// WithDNS sets additional name servers for the container
+func WithDNS(dnsServers []string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+ var dns []net.IP
+ for _, i := range dnsServers {
+ result := net.ParseIP(i)
+ if result == nil {
+ return errors.Wrapf(ErrInvalidArg, "invalid IP address %s", i)
+ }
+ dns = append(dns, result)
+ }
+ ctr.config.DNSServer = dns
+ return nil
+ }
+}
+
+// WithDNSOption sets addition dns options for the container
+func WithDNSOption(dnsOptions []string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+ ctr.config.DNSOption = dnsOptions
+ return nil
+ }
+}
+
+// WithHosts sets additional host:IP for the hosts file
+func WithHosts(hosts []string) CtrCreateOption {
+ return func(ctr *Container) error {
+ if ctr.valid {
+ return ErrCtrFinalized
+ }
+ ctr.config.HostAdd = hosts
+ return nil
+ }
+}