mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-22 06:51:26 +02:00
Merge pull request #2850 from dm0-/rkt
app-emulation/rkt: Allow several --hosts-entry=host args
This commit is contained in:
commit
69814da50e
@ -0,0 +1,68 @@
|
|||||||
|
From ce936a91678b77a2b91440e0198c895519ca8b24 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Luca Bruno <luca.bruno@coreos.com>
|
||||||
|
Date: Mon, 23 Oct 2017 08:49:09 +0000
|
||||||
|
Subject: [PATCH] stage0/run: relax '--hosts-entry' parser
|
||||||
|
|
||||||
|
This tweaks the '--hosts-entry' CLI flag parser to accept multiple
|
||||||
|
time the special value "host" when there are no other conflicting
|
||||||
|
settings.
|
||||||
|
---
|
||||||
|
rkt/run.go | 14 +++++++-------
|
||||||
|
tests/rkt_etc_hosts_test.go | 5 +++++
|
||||||
|
2 files changed, 12 insertions(+), 7 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/rkt/run.go b/rkt/run.go
|
||||||
|
index b852e13a6..ab4121475 100644
|
||||||
|
--- a/rkt/run.go
|
||||||
|
+++ b/rkt/run.go
|
||||||
|
@@ -18,6 +18,7 @@ package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bufio"
|
||||||
|
+ "errors"
|
||||||
|
"fmt"
|
||||||
|
"net"
|
||||||
|
"os"
|
||||||
|
@@ -643,13 +644,8 @@ func parseDNSFlags(flagHostsEntries, flagDNS, flagDNSSearch, flagDNSOpt []string
|
||||||
|
// Parse out --hosts-entries, also looking for the magic value "host"
|
||||||
|
for _, entry := range flagHostsEntries {
|
||||||
|
if entry == "host" {
|
||||||
|
- if len(flagHostsEntries) == 1 {
|
||||||
|
- DNSConfMode.Hosts = "host"
|
||||||
|
- } else {
|
||||||
|
- return DNSConfMode, DNSConfig, &HostsEntries,
|
||||||
|
- fmt.Errorf("cannot pass --hosts-entry=host with multiple hosts-entries")
|
||||||
|
- }
|
||||||
|
- break
|
||||||
|
+ DNSConfMode.Hosts = "host"
|
||||||
|
+ continue
|
||||||
|
}
|
||||||
|
for _, entry := range strings.Split(entry, ",") {
|
||||||
|
vals := strings.SplitN(entry, "=", 2)
|
||||||
|
@@ -677,6 +673,10 @@ func parseDNSFlags(flagHostsEntries, flagDNS, flagDNSSearch, flagDNSOpt []string
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(HostsEntries) > 0 {
|
||||||
|
+ if DNSConfMode.Hosts == "host" {
|
||||||
|
+ return DNSConfMode, DNSConfig, &HostsEntries,
|
||||||
|
+ errors.New("cannot pass --hosts-entry=host with multiple hosts-entries")
|
||||||
|
+ }
|
||||||
|
DNSConfMode.Hosts = "stage0"
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/tests/rkt_etc_hosts_test.go b/tests/rkt_etc_hosts_test.go
|
||||||
|
index 374916834..b3967cf6e 100644
|
||||||
|
--- a/tests/rkt_etc_hosts_test.go
|
||||||
|
+++ b/tests/rkt_etc_hosts_test.go
|
||||||
|
@@ -80,6 +80,11 @@ func TestEtcHosts(t *testing.T) {
|
||||||
|
"--exec=/inspect -- -file-name=/etc/hosts -hash-file",
|
||||||
|
sum,
|
||||||
|
},
|
||||||
|
+ { // Test that multiple '--hosts-entry=host' entries are fine
|
||||||
|
+ "--hosts-entry=host --hosts-entry=host",
|
||||||
|
+ "--exec=/inspect -- -file-name=/etc/hosts -hash-file",
|
||||||
|
+ sum,
|
||||||
|
+ },
|
||||||
|
{ // test that we create our own
|
||||||
|
"--hosts-entry=128.66.0.99=host1",
|
||||||
|
"--exec=/inspect -- -file-name=/etc/hosts -read-file",
|
@ -84,6 +84,8 @@ src_prepare() {
|
|||||||
die "CoreOS versions in ebuild and rkt build scripts are mismatched, expecting ${rkt_coreos_version}!"
|
die "CoreOS versions in ebuild and rkt build scripts are mismatched, expecting ${rkt_coreos_version}!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
epatch "${FILESDIR}/${PN}-1.29.0-allow-multiple-hosts-entry-host.patch"
|
||||||
|
|
||||||
autotools-utils_src_prepare
|
autotools-utils_src_prepare
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user