Skip to content

Commit

Permalink
Change 100's Result DNS as pointer to remove empty DNS field
Browse files Browse the repository at this point in the history
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 <tohayash@redhat.com>
  • Loading branch information
s1061123 committed Oct 26, 2023
1 parent 9a05940 commit bd61a0a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,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
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"`
}

// convertFrom100 does nothing except set the version; the types are the same
Expand Down Expand Up @@ -145,7 +145,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/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

0 comments on commit bd61a0a

Please sign in to comment.