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"
|
|
|
|
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects"
|
2023-12-04 21:53:01 +00:00
|
|
|
)
|
|
|
|
|
2023-12-05 21:56:47 +00:00
|
|
|
var cache *projects.Cache
|
|
|
|
|
2023-12-04 21:53:01 +00:00
|
|
|
var cacheCmd = &cobra.Command{
|
2023-12-29 15:24:12 +00:00
|
|
|
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)
|
2023-12-10 05:05:39 +00:00
|
|
|
cache.LockCache()
|
2023-12-05 21:56:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func postCacheCmd(cmd *cobra.Command, args []string) {
|
|
|
|
postProjectCache(cmd, args)
|
2023-12-10 05:05:39 +00:00
|
|
|
cache.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
|
|
|
}
|