Skip to content

Commit 50646c9

Browse files
committed
Change 100's Result DNS as pointer to remove empty DNS field
This commit changes DNS as pointer to remove empty DNS field in Result. This will simplify Result format. This also changes SPEC to mention all keys are optional, other than 'cniVerison'. Signed-off-by: Tomofumi Hayashi <[email protected]>
1 parent 9a05940 commit 50646c9

File tree

7 files changed

+8
-7
lines changed

7 files changed

+8
-7
lines changed

SPEC.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -523,6 +523,7 @@ For certain operations, plugins must output result information. The output shoul
523523
### ADD Success
524524

525525
Plugins must output a JSON object with the following keys upon a successful `ADD` operation:
526+
All keys are optional other than `cniVersion`.
526527

527528
- `cniVersion`: The same version supplied on input - the string "1.1.0"
528529
- `interfaces`: An array of all interfaces created by the attachment, including any host-level interfaces:

libcni/api_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ var _ = Describe("Invoking plugins", func() {
10031003
},
10041004
},
10051005
// DNS injected by last plugin
1006-
DNS: types.DNS{
1006+
DNS: &types.DNS{
10071007
Nameservers: []string{"1.2.3.4"},
10081008
},
10091009
}))

libcni/conf_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ var _ = Describe("Loading configuration from disk", func() {
496496
Expect(err).NotTo(HaveOccurred())
497497

498498
Expect(resultConfig).To(Equal(&libcni.NetworkConfig{
499-
Network: &types.NetConf{Name: "some-plugin", Type: "bridge", DNS: types.DNS{Nameservers: servers, Domain: "local"}},
499+
Network: &types.NetConf{Name: "some-plugin", Type: "bridge", DNS: &types.DNS{Nameservers: servers, Domain: "local"}},
500500
Bytes: expectedPluginConfig,
501501
}))
502502
})

pkg/types/100/types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ type Result struct {
9292
Interfaces []*Interface `json:"interfaces,omitempty"`
9393
IPs []*IPConfig `json:"ips,omitempty"`
9494
Routes []*types.Route `json:"routes,omitempty"`
95-
DNS types.DNS `json:"dns,omitempty"`
95+
DNS *types.DNS `json:"dns,omitempty"`
9696
}
9797

9898
// convertFrom100 does nothing except set the version; the types are the same
@@ -145,7 +145,7 @@ func convertFrom04x(from types.Result, toVersion string) (types.Result, error) {
145145
fromResult := from.(*types040.Result)
146146
toResult := &Result{
147147
CNIVersion: toVersion,
148-
DNS: *fromResult.DNS.Copy(),
148+
DNS: fromResult.DNS.Copy(),
149149
Routes: []*types.Route{},
150150
}
151151
for _, fromIntf := range fromResult.Interfaces {

pkg/types/100/types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func testResult() *current.Result {
7272
{Dst: *routev4, GW: routegwv4},
7373
{Dst: *routev6, GW: routegwv6},
7474
},
75-
DNS: types.DNS{
75+
DNS: &types.DNS{
7676
Nameservers: []string{"1.2.3.4", "1::cafe"},
7777
Domain: "acompany.com",
7878
Search: []string{"somedomain.com", "otherdomain.net"},

pkg/types/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ type NetConf struct {
6464
Type string `json:"type,omitempty"`
6565
Capabilities map[string]bool `json:"capabilities,omitempty"`
6666
IPAM IPAM `json:"ipam,omitempty"`
67-
DNS DNS `json:"dns,omitempty"`
67+
DNS *DNS `json:"dns,omitempty"`
6868

6969
RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
7070
PrevResult Result `json:"-"`

pkg/types/types_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ var _ = Describe("Types", func() {
176176
Gateway: net.ParseIP("abcd:1234:ffff::1"),
177177
},
178178
},
179-
DNS: types.DNS{
179+
DNS: &types.DNS{
180180
Nameservers: []string{"1.2.3.4", "1::cafe"},
181181
Domain: "acompany.com",
182182
Search: []string{"somedomain.com", "otherdomain.net"},

0 commit comments

Comments
 (0)