Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code cleanup #1198

Merged
merged 1 commit into from
Sep 12, 2020
Merged
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
19 changes: 6 additions & 13 deletions cmd/routed-eni-cni-plugin/cni.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,32 +84,25 @@ func init() {

// LoadNetConf converts inputs (i.e. stdin) to NetConf
func LoadNetConf(bytes []byte) (*NetConf, logger.Logger, error) {
var conf NetConf
// Default config
conf := NetConf{
MTU: "9001",
VethPrefix: "eni",
}

if err := json.Unmarshal(bytes, &conf); err != nil {
return nil, nil, errors.Wrap(err, "add cmd: error loading config from args")
}

//logConfig
logConfig := logger.Configuration{
LogLevel: conf.PluginLogLevel,
LogLocation: conf.PluginLogFile,
}
log := logger.New(&logConfig)

// MTU
if conf.MTU == "" {
log.Debug("MTU not set, defaulting to 9001")
conf.MTU = "9001"
}

// Default the host-side veth prefix to 'eni'.
if conf.VethPrefix == "" {
conf.VethPrefix = "eni"
}
if len(conf.VethPrefix) > 4 {
return nil, nil, errors.New("conf.VethPrefix can be at most 4 characters long")
}

return &conf, log, nil
}

Expand Down