dhcp ipam: rename inconsistent options among files
Signed-off-by: SilverBut <SilverBut@users.noreply.github.com>
This commit is contained in:
parent
c627ea807c
commit
a1051f3bf1
@ -71,7 +71,7 @@ func (d *DHCP) Allocate(args *skel.CmdArgs, result *current.Result) error {
|
|||||||
return fmt.Errorf("error parsing netconf: %v", err)
|
return fmt.Errorf("error parsing netconf: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
optsRequesting, optsProviding, err := prepareOptions(args.Args, conf.IPAM.ProvideOptions, conf.IPAM.RequireOptions)
|
optsRequesting, optsProviding, err := prepareOptions(args.Args, conf.IPAM.ProvideOptions, conf.IPAM.RequestOptions)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -68,12 +68,12 @@ type DHCPLease struct {
|
|||||||
optsProviding map[dhcp4.OptionCode][]byte
|
optsProviding map[dhcp4.OptionCode][]byte
|
||||||
}
|
}
|
||||||
|
|
||||||
var acquireOptionsDefault = map[dhcp4.OptionCode]bool{
|
var requestOptionsDefault = map[dhcp4.OptionCode]bool{
|
||||||
dhcp4.OptionRouter: true,
|
dhcp4.OptionRouter: true,
|
||||||
dhcp4.OptionSubnetMask: true,
|
dhcp4.OptionSubnetMask: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
func prepareOptions(cniArgs string, ProvideOptions []ProvideOption, RequireOptions []RequireOption) (
|
func prepareOptions(cniArgs string, ProvideOptions []ProvideOption, RequestOptions []RequestOption) (
|
||||||
optsRequesting map[dhcp4.OptionCode]bool, optsProviding map[dhcp4.OptionCode][]byte, err error) {
|
optsRequesting map[dhcp4.OptionCode]bool, optsProviding map[dhcp4.OptionCode][]byte, err error) {
|
||||||
|
|
||||||
// parse CNI args
|
// parse CNI args
|
||||||
@ -113,7 +113,7 @@ func prepareOptions(cniArgs string, ProvideOptions []ProvideOption, RequireOptio
|
|||||||
// parse necessary options map
|
// parse necessary options map
|
||||||
optsRequesting = make(map[dhcp4.OptionCode]bool)
|
optsRequesting = make(map[dhcp4.OptionCode]bool)
|
||||||
skipRequireDefault := false
|
skipRequireDefault := false
|
||||||
for _, opt := range RequireOptions {
|
for _, opt := range RequestOptions {
|
||||||
if opt.SkipDefault {
|
if opt.SkipDefault {
|
||||||
skipRequireDefault = true
|
skipRequireDefault = true
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ func prepareOptions(cniArgs string, ProvideOptions []ProvideOption, RequireOptio
|
|||||||
}
|
}
|
||||||
optsRequesting[optParsed] = true
|
optsRequesting[optParsed] = true
|
||||||
}
|
}
|
||||||
for k, v := range acquireOptionsDefault {
|
for k, v := range requestOptionsDefault {
|
||||||
// only set if not skipping default and this value does not exists
|
// only set if not skipping default and this value does not exists
|
||||||
if _, ok := optsRequesting[k]; !ok && !skipRequireDefault {
|
if _, ok := optsRequesting[k]; !ok && !skipRequireDefault {
|
||||||
optsRequesting[k] = v
|
optsRequesting[k] = v
|
||||||
|
@ -48,9 +48,9 @@ type IPAMConfig struct {
|
|||||||
ProvideOptions []ProvideOption `json:"provide"`
|
ProvideOptions []ProvideOption `json:"provide"`
|
||||||
// When requesting IP from DHCP server, claiming these options are necessary. Options are necessary unless `optional`
|
// When requesting IP from DHCP server, claiming these options are necessary. Options are necessary unless `optional`
|
||||||
// is set to `false`.
|
// is set to `false`.
|
||||||
// To override default required fields, set `skipDefault` to `false`.
|
// To override default requesting fields, set `skipDefault` to `false`.
|
||||||
// If an field is not optional, but the server failed to provide it, error will be raised.
|
// If an field is not optional, but the server failed to provide it, error will be raised.
|
||||||
RequireOptions []RequireOption `json:"require"`
|
RequestOptions []RequestOption `json:"request"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// DHCPOption represents a DHCP option. It can be a number, or a string defined in manual dhcp-options(5).
|
// DHCPOption represents a DHCP option. It can be a number, or a string defined in manual dhcp-options(5).
|
||||||
@ -64,7 +64,7 @@ type ProvideOption struct {
|
|||||||
ValueFromCNIArg string `json:"fromArg"`
|
ValueFromCNIArg string `json:"fromArg"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequireOption struct {
|
type RequestOption struct {
|
||||||
SkipDefault bool `json:"skipDefault"`
|
SkipDefault bool `json:"skipDefault"`
|
||||||
|
|
||||||
Option DHCPOption `json:"option"`
|
Option DHCPOption `json:"option"`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user