git-project-manager/cmd/cache.go

38 lines
780 B
Go
Raw Normal View History

2023-12-04 21:53:01 +00:00
package cmd
import (
2023-12-05 21:56:47 +00:00
"time"
2023-12-04 21:53:01 +00:00
"github.com/spf13/cobra"
2023-12-05 21:56:47 +00:00
"github.com/spf13/viper"
2024-01-15 21:02:15 +00:00
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
2023-12-04 21:53:01 +00:00
)
2024-01-15 21:02:15 +00:00
var projectCache *cache.Cache
2023-12-05 21:56:47 +00:00
2023-12-04 21:53:01 +00:00
var cacheCmd = &cobra.Command{
Use: "cache",
Aliases: []string{"a", "ln"},
Short: "Manage GitLab project cache",
Long: cacheCmdLong,
2023-12-05 21:56:47 +00:00
}
2023-12-10 05:05:39 +00:00
func runCacheCmd(cmd *cobra.Command, args []string) {
2023-12-05 21:56:47 +00:00
initProjectCache(cmd, args)
2024-01-15 21:02:15 +00:00
projectCache.LockCache()
2023-12-05 21:56:47 +00:00
}
func postCacheCmd(cmd *cobra.Command, args []string) {
postProjectCache(cmd, args)
2024-01-15 21:02:15 +00:00
projectCache.UnlockCache()
2023-12-04 21:53:01 +00:00
}
func init() {
rootCmd.AddCommand(cacheCmd)
2023-12-05 21:56:47 +00:00
cacheCmd.PersistentFlags().Duration("ttl", 48*time.Hour,
"Duration before cache is re-built in go time.Duration format")
2023-12-04 21:53:01 +00:00
2023-12-05 21:56:47 +00:00
viper.BindPFlags(cacheCmd.Flags())
2023-12-04 21:53:01 +00:00
}