Add a -clean flag to the cmd
diff --git a/cmd/apid/main.go b/cmd/apid/main.go
index b9995b5..6abd2fc 100644
--- a/cmd/apid/main.go
+++ b/cmd/apid/main.go
@@ -3,7 +3,7 @@
import (
// import plugins to ensure they're bound into the executable
_ "github.com/30x/apidApigeeSync"
- _ "github.com/30x/apidVerifyAPIKey"
+ //_ "github.com/30x/apidVerifyAPIKey"
_ "github.com/30x/apidGatewayDeploy"
// other imports
@@ -15,17 +15,29 @@
func main() {
configFlag := flag.String("config", "", "path to the yaml config file [./apid_config.yaml]")
-
- flag.Parse()
+ cleanFlag := flag.Bool("clean", false, "start clean, deletes all existing data from local_storage_path")
configFile := *configFlag
if configFile != "" {
os.Setenv("APID_CONFIG_FILE", configFile)
}
+ flag.Parse()
+
apid.Initialize(factory.DefaultServicesFactory())
log := apid.Log()
+ config := apid.Config()
+
+ if *cleanFlag {
+ localStorage := config.GetString("local_storage_path")
+ log.Infof("removing existing data from: %s", localStorage)
+ err := os.RemoveAll(localStorage)
+ if err != nil {
+ log.Panic("Failed to clean data directory: %v", err)
+ }
+ }
+
log.Debug("initializing...")
apid.InitializePlugins()