Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ For certain operations, plugins must output result information. The output shoul
### ADD Success

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

- `cniVersion`: The same version supplied on input - the string "1.1.0"
- `interfaces`: An array of all interfaces created by the attachment, including any host-level interfaces:
Expand Down
5 changes: 2 additions & 3 deletions libcni/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ var _ = Describe("Invoking plugins", func() {
debug = &noop_debug.Debug{
ReportResult: `{
"cniVersion": "` + version.Current() + `",
"ips": [{"address": "10.1.2.3/24"}],
"dns": {}
"ips": [{"address": "10.1.2.3/24"}]
}`,
}
Expect(debug.WriteDebug(debugFilePath)).To(Succeed())
Expand Down Expand Up @@ -1001,7 +1000,7 @@ var _ = Describe("Invoking plugins", func() {
},
},
// DNS injected by last plugin
DNS: types.DNS{
DNS: &types.DNS{
Nameservers: []string{"1.2.3.4"},
},
}))
Expand Down
2 changes: 1 addition & 1 deletion libcni/conf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ var _ = Describe("Loading configuration from disk", func() {
Expect(err).NotTo(HaveOccurred())

Expect(resultConfig).To(Equal(&libcni.NetworkConfig{
Network: &types.NetConf{Name: "some-plugin", Type: "bridge", DNS: types.DNS{Nameservers: servers, Domain: "local"}},
Network: &types.NetConf{Name: "some-plugin", Type: "bridge", DNS: &types.DNS{Nameservers: servers, Domain: "local"}},
Bytes: expectedPluginConfig,
}))
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/types/100/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ type Result struct {
Interfaces []*Interface `json:"interfaces,omitempty"`
IPs []*IPConfig `json:"ips,omitempty"`
Routes []*types.Route `json:"routes,omitempty"`
DNS types.DNS `json:"dns,omitempty"`
DNS *types.DNS `json:"dns,omitempty"`
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, we can't change the API here, since it would break upgrades :-(.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will change the way to keep the structure type in another PRs. thank you for comment!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@squeed create another PR for alternative: #1039 PTAL?

}

// Note: DNS should be omit if DNS is empty but default Marshal function
Expand Down Expand Up @@ -168,7 +168,7 @@ func convertFrom04x(from types.Result, toVersion string) (types.Result, error) {
fromResult := from.(*types040.Result)
toResult := &Result{
CNIVersion: toVersion,
DNS: *fromResult.DNS.Copy(),
DNS: fromResult.DNS.Copy(),
Routes: []*types.Route{},
}
for _, fromIntf := range fromResult.Interfaces {
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/100/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func testResult() *current.Result {
{Dst: *routev4, GW: routegwv4},
{Dst: *routev6, GW: routegwv6},
},
DNS: types.DNS{
DNS: &types.DNS{
Nameservers: []string{"1.2.3.4", "1::cafe"},
Domain: "acompany.com",
Search: []string{"somedomain.com", "otherdomain.net"},
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type NetConf struct {
Type string `json:"type,omitempty"`
Capabilities map[string]bool `json:"capabilities,omitempty"`
IPAM IPAM `json:"ipam,omitempty"`
DNS DNS `json:"dns,omitempty"`
DNS *DNS `json:"dns,omitempty"`

RawPrevResult map[string]interface{} `json:"prevResult,omitempty"`
PrevResult Result `json:"-"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/types/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ var _ = Describe("Types", func() {
Gateway: net.ParseIP("abcd:1234:ffff::1"),
},
},
DNS: types.DNS{
DNS: &types.DNS{
Nameservers: []string{"1.2.3.4", "1::cafe"},
Domain: "acompany.com",
Search: []string{"somedomain.com", "otherdomain.net"},
Expand Down