summaryrefslogtreecommitdiff
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/api/handlers/compat/images_build.go36
-rw-r--r--pkg/bindings/images/build.go22
2 files changed, 58 insertions, 0 deletions
diff --git a/pkg/api/handlers/compat/images_build.go b/pkg/api/handlers/compat/images_build.go
index e06f93b89..392f688dd 100644
--- a/pkg/api/handlers/compat/images_build.go
+++ b/pkg/api/handlers/compat/images_build.go
@@ -77,6 +77,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
Devices string `schema:"devices"`
Dockerfile string `schema:"dockerfile"`
DropCapabilities string `schema:"dropcaps"`
+ DNSServers string `schema:"dnsservers"`
+ DNSOptions string `schema:"dnsoptions"`
+ DNSSearch string `schema:"dnssearch"`
Excludes string `schema:"excludes"`
ForceRm bool `schema:"forcerm"`
From string `schema:"from"`
@@ -160,6 +163,36 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
devices = m
}
+ var dnsservers = []string{}
+ if _, found := r.URL.Query()["dnsservers"]; found {
+ var m = []string{}
+ if err := json.Unmarshal([]byte(query.DNSServers), &m); err != nil {
+ utils.BadRequest(w, "dnsservers", query.DNSServers, err)
+ return
+ }
+ dnsservers = m
+ }
+
+ var dnsoptions = []string{}
+ if _, found := r.URL.Query()["dnsoptions"]; found {
+ var m = []string{}
+ if err := json.Unmarshal([]byte(query.DNSOptions), &m); err != nil {
+ utils.BadRequest(w, "dnsoptions", query.DNSOptions, err)
+ return
+ }
+ dnsoptions = m
+ }
+
+ var dnssearch = []string{}
+ if _, found := r.URL.Query()["dnssearch"]; found {
+ var m = []string{}
+ if err := json.Unmarshal([]byte(query.DNSSearch), &m); err != nil {
+ utils.BadRequest(w, "dnssearches", query.DNSSearch, err)
+ return
+ }
+ dnssearch = m
+ }
+
var output string
if len(query.Tag) > 0 {
output = query.Tag[0]
@@ -285,6 +318,9 @@ func BuildImage(w http.ResponseWriter, r *http.Request) {
CPUQuota: query.CpuQuota,
CPUShares: query.CpuShares,
CPUSetCPUs: query.CpuSetCpus,
+ DNSServers: dnsservers,
+ DNSOptions: dnsoptions,
+ DNSSearch: dnssearch,
HTTPProxy: query.HTTPProxy,
Memory: query.Memory,
MemorySwap: query.MemSwap,
diff --git a/pkg/bindings/images/build.go b/pkg/bindings/images/build.go
index 27706fd2c..1cbd28c37 100644
--- a/pkg/bindings/images/build.go
+++ b/pkg/bindings/images/build.go
@@ -87,6 +87,28 @@ func Build(ctx context.Context, containerFiles []string, options entities.BuildO
params.Add("devices", d)
}
+ if dnsservers := options.CommonBuildOpts.DNSServers; len(dnsservers) > 0 {
+ c, err := jsoniter.MarshalToString(dnsservers)
+ if err != nil {
+ return nil, err
+ }
+ params.Add("dnsservers", c)
+ }
+ if dnsoptions := options.CommonBuildOpts.DNSOptions; len(dnsoptions) > 0 {
+ c, err := jsoniter.MarshalToString(dnsoptions)
+ if err != nil {
+ return nil, err
+ }
+ params.Add("dnsoptions", c)
+ }
+ if dnssearch := options.CommonBuildOpts.DNSSearch; len(dnssearch) > 0 {
+ c, err := jsoniter.MarshalToString(dnssearch)
+ if err != nil {
+ return nil, err
+ }
+ params.Add("dnssearch", c)
+ }
+
if caps := options.DropCapabilities; len(caps) > 0 {
c, err := jsoniter.MarshalToString(caps)
if err != nil {