Use extra_hosts instead of add_hosts

This commit is contained in:
Gábor Egyed 2021-08-20 20:50:11 +02:00 committed by Leo Antunes
parent 9847889000
commit 120c2ccb14
3 changed files with 6 additions and 4 deletions

View file

@ -25,6 +25,8 @@ type dockerClientPinger interface {
Ping(context.Context) (types.Ping, error)
}
const dockerLabel string = "net.costela.docker-etchosts.extra_hosts";
func getAllIPsToNames(client dockerClienter) (ipsToNamesMap, error) {
containers, err := client.ContainerList(context.Background(), types.ContainerListOptions{})
if err != nil {
@ -90,7 +92,7 @@ func getIPsToNames(client dockerClienter, id string) (ipsToNamesMap, error) {
names = appendNames(names, name)
}
if label, ok := containerFull.Config.Labels["com.costela.docker-etchosts.add_hosts"]; ok {
if label, ok := containerFull.Config.Labels[dockerLabel]; ok {
if (strings.HasPrefix(label, "[")) {
var parsed []string;
err := json.Unmarshal([]byte(label), &parsed)