Remove nameserver 127.0.0.1 line rather then dumping resolv.conf

We have a bug report complaining about docker dumping the contents of the
hosts resolv.conf if it container 127.0.0.1.  They asked that instead
of dropping the file altogether, that we just remove the line.

This patch removes the 127.0.0.1 lines, if they exist and then
checks if any nameserver lines exist.

Docker-DCO-1.1-Signed-off-by: Dan Walsh <dwalsh@redhat.com> (github: rhatdan)
Nitpicking but you want \s+ here, not \s*

On Sep 23, 2014, at 9:30 AM, Alexandr Morozov <notifications@github.com> wrote:

> In utils/utils.go:
> 
> > @@ -332,6 +332,43 @@ func CheckLocalDns(resolvConf []byte) bool {
> >  	return true
> >  }
> >  
> > +// RemoveLocalDns looks into the /etc/resolv.conf,
> > +// and removes any local nameserver entries.
> > +func RemoveLocalDns(resolvConf []byte) []byte {
> > +	var newResolvConf string
> > +	var truncLine string
> > +	for _, line := range strings.Split(string(resolvConf), "\n") {
> I don't understand why we need so complicated logic for this. This can be done with regexp.Replace and regexp like ^nameserver\s*127.0.[01].1
> 
> —
> Reply to this email directly or view it on GitHub.
>