Skip to content

Commit bd61a0a

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 bd61a0a

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
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:

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/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:"-"`

0 commit comments

Comments
 (0)