Skip to content

Commit

Permalink
Add path flag to loxicmd save to non default /etc/loxilb directory #7…
Browse files Browse the repository at this point in the history
…06 in loxilb
  • Loading branch information
inhogog2 committed Jun 28, 2024
1 parent 1128eb3 commit a81cabb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion cmd/dump/save.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ type SaveOptions struct {
SaveEPConfig bool
SaveBFDConfig bool
SaveAllConfig bool
ConfigPath string
}

// saveCmd represents the save command
Expand All @@ -46,6 +47,9 @@ func SaveCmd(saveOpts *SaveOptions, restOptions *api.RESTOptions) *cobra.Command
_ = cmd
_ = args
dpath := "/etc/loxilb/"
if saveOpts.ConfigPath != "" {
dpath = saveOpts.ConfigPath
}
if !saveOpts.SaveIpConfig && !saveOpts.SaveAllConfig &&
!saveOpts.SaveLBConfig && !saveOpts.SaveSessionConfig &&
!saveOpts.SaveUlClConfig && !saveOpts.SaveFWConfig &&
Expand All @@ -57,7 +61,7 @@ func SaveCmd(saveOpts *SaveOptions, restOptions *api.RESTOptions) *cobra.Command
if _, err := os.Stat(dpath); errors.Is(err, os.ErrNotExist) {
err := os.Mkdir(dpath, os.ModePerm)
if err != nil {
fmt.Println("Can't create config dir /etc/loxilb/")
fmt.Println("Can't create config dir %v", dpath)
return
}
}
Expand Down
4 changes: 3 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,15 @@ loxicmd aim to provide all of the configuation for the loxilb.`,
saveCmd.Flags().BoolVarP(&saveOptions.SaveFWConfig, "firewall", "", false, "Saves firewall configuration")
saveCmd.Flags().BoolVarP(&saveOptions.SaveEPConfig, "endpoint", "", false, "Saves endpoint configuration")
saveCmd.Flags().BoolVarP(&saveOptions.SaveBFDConfig, "bfd", "", false, "Saves BFD configuration")
saveCmd.Flags().StringVarP(&saveOptions.ConfigPath, "config-path", "c", "", "config file patch setting")

saveCmd.MarkFlagsMutuallyExclusive("all", "ip", "lb", "session", "ulcl", "firewall", "endpoint", "bfd")

applyCmd.Flags().StringVarP(&applyOptions.IpConfigFile, "ip", "i", "", "IP config file to apply")
applyCmd.Flags().StringVarP(&applyOptions.Intf, "per-intf", "", "", "Apply configuration only for specific interface")
applyCmd.Flags().BoolVarP(&applyOptions.Route, "ipv4route", "r", false, "Apply route configuration only for specific interface")
applyCmd.Flags().StringVarP(&applyOptions.ConfigPath, "config-path", "c", "/opt/loxilb/ipconfig/", "Configuration path only for applying per interface config")

applyCmd.Flags().StringVarP(&applyOptions.ConfigPath, "config-path", "c", "/etc/loxilb/ipconfig/", "Configuration path only for applying per interface config")
applyCmd.Flags().StringVarP(&applyOptions.LBConfigFile, "lb", "l", "", "Load Balancer config file to apply")
applyCmd.Flags().StringVarP(&applyOptions.SessionConfigFile, "session", "", "", "Session config file to apply")
applyCmd.Flags().StringVarP(&applyOptions.SessionUlClConfigFile, "ulcl", "", "", "Ulcl config file to apply")
Expand Down

0 comments on commit a81cabb

Please # to comment.