summaryrefslogtreecommitdiff
path: root/plugins/meta/dnsname/config.go
blob: 9c1039bf01d2500db83b5346da5b07771af3d27d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package main

import (
	"errors"

	"github.com/containernetworking/cni/pkg/types"
)

const (
	//	dnsNameConfPath is where we store the conf, pid, and hosts files
	dnsNameConfPath = "/run/containers/cni/dnsname"
	// confFileName is the name of the dns masq conf file
	confFileName = "dnsmasq.conf"
	// hostsFileName is the name of the addnhosts file
	hostsFileName = "addnhosts"
	// pidFileName is the file where the dnsmasq file is stored
	pidFileName = "pidfile"
)

const dnsMasqTemplate = `## WARNING: THIS IS AN AUTOGENERATED FILE
## AND SHOULD NOT BE EDITED MANUALLY AS IT
## LIKELY TO AUTOMATICALLY BE REPLACED.
strict-order
local=/{{.Domain}}/
domain={{.Domain}}
expand-hosts
pid-file={{.PidFile}}
except-interface=lo
bind-dynamic
no-hosts
interface={{.NetworkInterface}}
addn-hosts={{.AddOnHostsFile}}`

var (
	// ErrBinaryNotFound means that the dnsmasq binary was not found
	ErrBinaryNotFound = errors.New("unable to locate dnsmasq in path")
	// ErrNoIPAddressFound means that CNI was unable to resolve an IP address in the CNI configuration
	ErrNoIPAddressFound = errors.New("no ip address was found in the network")
)

// DNSNameConf represents the cni config with the domain name attribute
type DNSNameConf struct {
	types.NetConf
	DomainName string `json:"domainName"`
}

// dnsNameFile describes the plugin's attributes
type dnsNameFile struct {
	AddOnHostsFile   string
	Binary           string
	ConfigFile       string
	Domain           string
	NetworkInterface string
	PidFile          string
}