Skip to content
Merged
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
17 changes: 13 additions & 4 deletions cnm/plugin/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,13 @@ var args = common.ArgumentList{
Type: "bool",
DefaultValue: false,
},
{
Name: common.OptStoreFileLocation,
Shorthand: common.OptStoreFileLocationAlias,
Description: "Set store file absolute path",
Type: "string",
DefaultValue: platform.CNMRuntimePath,
},
}

// Prints description and version information.
Expand All @@ -116,6 +123,7 @@ func main() {
ipamQueryUrl, _ := common.GetArg(common.OptIpamQueryUrl).(string)
ipamQueryInterval, _ := common.GetArg(common.OptIpamQueryInterval).(int)
vers := common.GetArg(common.OptVersion).(bool)
storeFileLocation := common.GetArg(common.OptStoreFileLocation).(string)

if vers {
printVersion()
Expand Down Expand Up @@ -143,16 +151,17 @@ func main() {
return
}

err = common.CreateDirectory(platform.CNMRuntimePath)
err = common.CreateDirectory(storeFileLocation)
if err != nil {
fmt.Printf("Failed to create File Store directory Error:%v", err.Error())
log.Errorf("Failed to create File Store directory %s, due to Error:%v", storeFileLocation, err.Error())
return
}

// Create the key value store.
config.Store, err = store.NewJsonFileStore(platform.CNMRuntimePath + name + ".json")
storeFileName := storeFileLocation + name + ".json"
config.Store, err = store.NewJsonFileStore(storeFileName)
if err != nil {
fmt.Printf("Failed to create store: %v\n", err)
log.Errorf("Failed to create store file: %s, due to error %v\n", storeFileName, err)
return
}

Expand Down
22 changes: 16 additions & 6 deletions cns/service/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,13 @@ var args = acn.ArgumentList{
Type: "int",
DefaultValue: "120",
},
{
Name: acn.OptStoreFileLocation,
Shorthand: acn.OptStoreFileLocationAlias,
Description: "Set store file absolute path",
Type: "string",
DefaultValue: platform.CNMRuntimePath,
},
}

// Prints description and version information.
Expand Down Expand Up @@ -195,6 +202,7 @@ func main() {
telemetryEnabled := acn.GetArg(acn.OptTelemetry).(bool)
httpConnectionTimeout := acn.GetArg(acn.OptHttpConnectionTimeout).(int)
httpResponseHeaderTimeout := acn.GetArg(acn.OptHttpResponseHeaderTimeout).(int)
storeFileLocation := acn.GetArg(acn.OptStoreFileLocation).(string)

if vers {
printVersion()
Expand Down Expand Up @@ -231,16 +239,17 @@ func main() {
// Log platform information.
log.Printf("Running on %v", platform.GetOSInfo())

err = acn.CreateDirectory(platform.CNMRuntimePath)
err = acn.CreateDirectory(storeFileLocation)
if err != nil {
log.Errorf("Failed to create File Store directory Error:%v", err.Error())
log.Errorf("Failed to create File Store directory %s, due to Error:%v", storeFileLocation, err.Error())
return
}

// Create the key value store.
config.Store, err = store.NewJsonFileStore(platform.CNMRuntimePath + name + ".json")
storeFileName := storeFileLocation + name + ".json"
config.Store, err = store.NewJsonFileStore(storeFileName)
if err != nil {
log.Errorf("Failed to create store: %v\n", err)
log.Errorf("Failed to create store file: %s, due to error %v\n", storeFileName, err)
return
}

Expand Down Expand Up @@ -310,9 +319,10 @@ func main() {
}

// Create the key value store.
pluginConfig.Store, err = store.NewJsonFileStore(platform.CNMRuntimePath + pluginName + ".json")
pluginStoreFile := storeFileLocation + pluginName + ".json"
pluginConfig.Store, err = store.NewJsonFileStore(pluginStoreFile)
if err != nil {
log.Errorf("Failed to create store: %v\n", err)
log.Errorf("Failed to create plugin store file %s, due to error : %v\n", pluginStoreFile, err)
return
}

Expand Down
4 changes: 4 additions & 0 deletions common/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,8 @@ const (
// HTTP response header timeout
OptHttpResponseHeaderTimeout = "http-response-header-timeout"
OptHttpResponseHeaderTimeoutAlias = "httprespheadertimeout"

// Store file location
OptStoreFileLocation = "store-file-path"
OptStoreFileLocationAlias = "storefilepath"
)