Documentation
¶
Overview ¶
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Armen Pan <panarm@esquel.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
Copyright © 2022 Armen Pan <panarm@esquel.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AdduserCmd = &cobra.Command{ Use: "adduser", Short: "add API key for owner", RunE: func(cmd *cobra.Command, args []string) error { return core.GetContainer().Invoke(func(auth *auth.AuthService) error { if username == "" { username = owner + "-user" + randstr.Dec(3) } key, err := auth.CreateUser(owner, username, remark, apikey, storecode) if err != nil { return err } fmt.Println("API key created.", key) return nil }) }, }
adduserCmd represents the adduser command
var CleanupCmd = &cobra.Command{ Use: "dbcleanup", Short: "run DB clean up", RunE: func(cmd *cobra.Command, args []string) error { return ginshared.GetContainer().Invoke(schedule.DoCleanup("cleanup", tables, col, duration)) }, }
versionCmd represents the version command
var CloseOnlyNotified = core.CloseOnlyNotified
var EncryptConfig = &cobra.Command{ Use: "encrypt", Short: "encrypt all configs to a single file ", Run: func(cmd *cobra.Command, args []string) { os.Remove(core.EncryptedFile) fmt.Printf("delete %s if existed\n", core.EncryptedFile) core.GetContainer().Invoke(func(logger *zap.Logger) error { return core.EncryptConfig() }) }, }
var GenconfigCmd = &cobra.Command{ Use: "genconfig", Short: "no need to gen config any more. ", Run: func(cmd *cobra.Command, args []string) { }, }
genconfigCmd represents the genconfig command
var HashCmd = &cobra.Command{ Use: "hash", Short: "hash raw password for api key", Args: cobra.MaximumNArgs(1), Run: func(cmd *cobra.Command, args []string) { rawKey := "" if len(args) == 1 { rawKey = args[0] } else { fmt.Print("enter raw api key(len(rawKey) > 5):") reader := bufio.NewReader(os.Stdin) input, err := reader.ReadString('\n') if err != nil { fmt.Println("Error reading input:", err) return } if len(input) <= 1 { return } rawKey = input[:len(input)-1] } if len(rawKey) < 5 { return } fmt.Println("going to hash ", rawKey[:2]+"****"+rawKey[len(rawKey)-2:]) hashed := auth.Hash(rawKey) fmt.Print(hashed) }, }
hashCmd represents the hash command
var RunJobCmd = &cobra.Command{ Use: "job", Short: "run job now", RunE: func(cmd *cobra.Command, args []string) error { return core.GetContainer().Invoke(func(p Schedule) error { if len(args) == 0 { keys := schedule.List() println("available jobs:") for _, k := range keys { println(k) } return nil } return schedule.Run(args[0]) }) }, }
var ScheduleCmd = &cobra.Command{ Use: "schedule", Short: "start the schedule job only", RunE: func(cmd *cobra.Command, args []string) error { return core.GetContainer().Invoke(func(p Schedule) error { core.NotifyStarted() CloseOnlyNotified() core.NotifyStopping() return nil }) }, }
scheduleCmd represents the schedule command
var VersionCmd = &cobra.Command{ Use: "version", Short: "show app version ", Long: `check app version`, RunE: func(cmd *cobra.Command, args []string) error { return core.GetContainer().Invoke(func(log *zap.Logger) { core.PrintVersion() }) }, }
versionCmd represents the version command
Functions ¶
This section is empty.