37 lines
793 B
Go
37 lines
793 B
Go
package cmd
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects"
|
|
)
|
|
|
|
var cache *projects.Cache
|
|
|
|
var cacheCmd = &cobra.Command{
|
|
Use: "cache",
|
|
Short: "Manage GitLab project cache",
|
|
Long: cacheCmdLong,
|
|
PersistentPreRun: initCacheCmd,
|
|
PersistentPostRun: postCacheCmd,
|
|
}
|
|
|
|
func initCacheCmd(cmd *cobra.Command, args []string) {
|
|
initProjectCache(cmd, args)
|
|
}
|
|
|
|
func postCacheCmd(cmd *cobra.Command, args []string) {
|
|
postProjectCache(cmd, args)
|
|
}
|
|
|
|
func init() {
|
|
rootCmd.AddCommand(cacheCmd)
|
|
|
|
cacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
|
|
"Duration before cache is re-built in go time.Duration format")
|
|
|
|
viper.BindPFlags(cacheCmd.Flags())
|
|
}
|