Rename projects to cache package

This commit is contained in:
Ryan McGuire 2024-01-15 16:02:15 -05:00
parent d6833a9ea0
commit e846821c44
26 changed files with 73 additions and 73 deletions

View File

@ -19,7 +19,7 @@ func init() {
} }
func mustHaveAliases(cmd *cobra.Command, args []string) { func mustHaveAliases(cmd *cobra.Command, args []string) {
if len(cache.Aliases) == 0 { if len(projectCache.Aliases) == 0 {
plog.Fatal("No aliases set, nothing to " + cmd.Name()) plog.Fatal("No aliases set, nothing to " + cmd.Name())
} }
} }

View File

@ -7,7 +7,7 @@ import (
"github.com/pterm/pterm" "github.com/pterm/pterm"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cacheProjects "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
) )
@ -26,7 +26,7 @@ func runAddAliasCmd(cmd *cobra.Command, args []string) {
// Check by flag // Check by flag
if projectID := viper.GetInt("alias.add.projectid"); projectID > 0 { if projectID := viper.GetInt("alias.add.projectid"); projectID > 0 {
plog.Debug(fmt.Sprintf("Adding for inbound project ID %d", projectID)) plog.Debug(fmt.Sprintf("Adding for inbound project ID %d", projectID))
project = cache.GetProjectByID(projectID) project = projectCache.GetProjectByID(projectID)
} }
// Check by arg // Check by arg
@ -47,7 +47,7 @@ func runAddAliasCmd(cmd *cobra.Command, args []string) {
} }
func addNewAliases(projectID int) { func addNewAliases(projectID int) {
project := cache.GetProjectByID(projectID) project := projectCache.GetProjectByID(projectID)
if project == nil { if project == nil {
plog.Error("Failed to find project to alias", plog.Args("projectID", projectID)) plog.Error("Failed to find project to alias", plog.Args("projectID", projectID))
return return
@ -62,7 +62,7 @@ func addNewAliases(projectID int) {
if a == "" { if a == "" {
continue continue
} }
if err := cache.AddAlias(a, project.ID, project.Remote); err != nil { if err := projectCache.AddAlias(a, project.ID, project.Remote); err != nil {
plog.Debug("Skipping alias add", plog.Args( plog.Debug("Skipping alias add", plog.Args(
"error", err, "error", err,
"alias", a, "alias", a,
@ -77,11 +77,11 @@ func addNewAliases(projectID int) {
} }
func promptAliasesForProject(p *projects.Project) []string { func promptAliasesForProject(p *projects.Project) []string {
aliases := cache.GetProjectAliases(p) aliases := projectCache.GetProjectAliases(p)
if len(aliases) > 0 { if len(aliases) > 0 {
plog.Info("Adding aliases to project", plog.Args( plog.Info("Adding aliases to project", plog.Args(
"project", p.String(), "project", p.String(),
"existingAliases", cacheProjects.ProjectAliasesString(aliases), "existingAliases", cache.ProjectAliasesString(aliases),
)) ))
} else { } else {
pterm.Info.Printfln("Adding aliases to %s", p.Name) pterm.Info.Printfln("Adding aliases to %s", p.Name)

View File

@ -40,7 +40,7 @@ func runDeleteAliasCmd(cmd *cobra.Command, args []string) {
)) ))
} }
aliasStrings := cache.GetProjectAliasStrings(project) aliasStrings := projectCache.GetProjectAliasStrings(project)
deletionCandidates, err := pterm.DefaultInteractiveMultiselect. deletionCandidates, err := pterm.DefaultInteractiveMultiselect.
WithOptions(aliasStrings). WithOptions(aliasStrings).
@ -70,10 +70,10 @@ func runDeleteAliasCmd(cmd *cobra.Command, args []string) {
"alias", a, "alias", a,
)) ))
cache.DeleteAlias(cache.GetAliasByName(a)) projectCache.DeleteAlias(projectCache.GetAliasByName(a))
} }
fmt.Println(cache.ProjectString(project)) fmt.Println(projectCache.ProjectString(project))
} }
func init() { func init() {

View File

@ -23,7 +23,7 @@ func runListAliasCmd(cmd *cobra.Command, args []string) {
WithLeftPadding(5).WithRightPadding(5). WithLeftPadding(5).WithRightPadding(5).
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}). WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project"))). WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Aliases by Project"))).
Print("\n" + cache.AliasesByProjectString()) Print("\n" + projectCache.AliasesByProjectString())
fmt.Print("\n\n") fmt.Print("\n\n")
} }

View File

@ -5,10 +5,10 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
) )
var cache *projects.Cache var projectCache *cache.Cache
var cacheCmd = &cobra.Command{ var cacheCmd = &cobra.Command{
Use: "cache", Use: "cache",
@ -19,12 +19,12 @@ var cacheCmd = &cobra.Command{
func runCacheCmd(cmd *cobra.Command, args []string) { func runCacheCmd(cmd *cobra.Command, args []string) {
initProjectCache(cmd, args) initProjectCache(cmd, args)
cache.LockCache() projectCache.LockCache()
} }
func postCacheCmd(cmd *cobra.Command, args []string) { func postCacheCmd(cmd *cobra.Command, args []string) {
postProjectCache(cmd, args) postProjectCache(cmd, args)
cache.UnlockCache() projectCache.UnlockCache()
} }
func init() { func init() {

View File

@ -21,7 +21,7 @@ var clearCmd = &cobra.Command{
func clearCache(cmd *cobra.Command, args []string) { func clearCache(cmd *cobra.Command, args []string) {
slog.Debug("Preparing to clear local cache") slog.Debug("Preparing to clear local cache")
cache.Clear(conf.Cache.Clear.ClearAliases) projectCache.Clear(conf.Cache.Clear.ClearAliases)
} }
func init() { func init() {

View File

@ -15,9 +15,9 @@ var dumpCmd = &cobra.Command{
PostRun: postCacheCmd, PostRun: postCacheCmd,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if conf.Dump.Full { if conf.Dump.Full {
fmt.Println(cache.DumpString(true, searchStringFromArgs(args))) fmt.Println(projectCache.DumpString(true, searchStringFromArgs(args)))
} else { } else {
plog.Info(cache.String()) plog.Info(projectCache.String())
} }
}, },
} }

View File

@ -17,7 +17,7 @@ wants to find a new project.`,
} }
func loadCache(cmd *cobra.Command, args []string) { func loadCache(cmd *cobra.Command, args []string) {
cache.Refresh() projectCache.Refresh()
} }
func init() { func init() {

View File

@ -13,11 +13,11 @@ var unlockCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
initProjectCache(cmd, args) initProjectCache(cmd, args)
if viper.GetBool("cache.unlock.force") { if viper.GetBool("cache.unlock.force") {
cache.UnlockCache() projectCache.UnlockCache()
} else if yes, _ := pterm.DefaultInteractiveConfirm. } else if yes, _ := pterm.DefaultInteractiveConfirm.
WithDefaultValue(false). WithDefaultValue(false).
Show("Are you sure you want to manually unlock?"); yes { Show("Are you sure you want to manually unlock?"); yes {
cache.UnlockCache() projectCache.UnlockCache()
} else { } else {
plog.Error("You failed to confirm cache unlock") plog.Error("You failed to confirm cache unlock")
} }

View File

@ -3,7 +3,7 @@ package cmd
import ( import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
"github.com/spf13/viper" "github.com/spf13/viper"
cacheProjects "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
) )
@ -33,12 +33,12 @@ func getProject(args []string) *projects.Project {
} else { } else {
plog.Debug("Houston, we have a project", plog.Args( plog.Debug("Houston, we have a project", plog.Args(
"project", project.String(), "project", project.String(),
"aliases", cacheProjects.ProjectAliasesString( "aliases", cache.ProjectAliasesString(
cache.GetProjectAliases(project)), projectCache.GetProjectAliases(project)),
)) ))
} }
if len(cache.GetProjectAliases(project)) == 0 { if len(projectCache.GetProjectAliases(project)) == 0 {
plog.Info("New project, set aliases or press enter for default") plog.Info("New project, set aliases or press enter for default")
addNewAliases(project.ID) addNewAliases(project.ID)
} }
@ -63,7 +63,7 @@ func init() {
} }
func mustHaveProjects(cmd *cobra.Command, args []string) { func mustHaveProjects(cmd *cobra.Command, args []string) {
if len(cache.Projects) == 0 { if len(projectCache.Projects) == 0 {
plog.Fatal("No projects to " + cmd.Name() + ", try running cache load") plog.Fatal("No projects to " + cmd.Name() + ", try running cache load")
} }
} }

View File

@ -34,11 +34,11 @@ func projectGoCmdRun(cmd *cobra.Command, args []string) {
plog.Fatal("No project selected, nowhere to go") plog.Fatal("No project selected, nowhere to go")
} }
cache.GoTo(project) projectCache.GoTo(project)
project.SetRepo(cache.OpenProject(cmd.Context(), project)) project.SetRepo(projectCache.OpenProject(cmd.Context(), project))
plog.Debug("Project ready", plog.Args( plog.Debug("Project ready", plog.Args(
"path", cache.GetProjectPath(project), "path", projectCache.GetProjectPath(project),
"project", project, "project", project,
)) ))
@ -46,8 +46,8 @@ func projectGoCmdRun(cmd *cobra.Command, args []string) {
// This should be read by any source command, for instance // This should be read by any source command, for instance
// `cd "$(gitlab-project-manager projects cd somealias)"` // `cd "$(gitlab-project-manager projects cd somealias)"`
fmt.Println(cache.GetProjectPath(project)) fmt.Println(projectCache.GetProjectPath(project))
exec.Command("cd", cache.GetProjectPath(project)).Run() exec.Command("cd", projectCache.GetProjectPath(project)).Run()
} }
func init() { func init() {

View File

@ -17,7 +17,7 @@ var projectListCmd = &cobra.Command{
func projectListCmdRun(cmd *cobra.Command, args []string) { func projectListCmdRun(cmd *cobra.Command, args []string) {
gitlabs := viper.GetStringSlice("project.gitlabs") gitlabs := viper.GetStringSlice("project.gitlabs")
fmt.Println(cache.DumpString(viper.GetBool("project.list.all"), searchStringFromArgs(args), gitlabs...)) fmt.Println(projectCache.DumpString(viper.GetBool("project.list.all"), searchStringFromArgs(args), gitlabs...))
} }
func init() { func init() {

View File

@ -63,7 +63,7 @@ func projectOpenCmdRun(cmd *cobra.Command, args []string) {
} }
// Check the project // Check the project
path := cache.GetProjectPath(project) path := projectCache.GetProjectPath(project)
if _, err := os.Stat(path); err != nil { if _, err := os.Stat(path); err != nil {
plog.Fatal("Unable to open project", plog.Args("error", err)) plog.Fatal("Unable to open project", plog.Args("error", err))
} }

View File

@ -33,7 +33,7 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
// Try to find project from current directory // Try to find project from current directory
if viper.GetBool("project.show.current") { if viper.GetBool("project.show.current") {
var err error var err error
project, err = cache.GetProjectFromCwd() project, err = projectCache.GetProjectFromCwd()
if err != nil { if err != nil {
// Not an error because we're still going to try to find a project // Not an error because we're still going to try to find a project
plog.Warn("Failed to get project from current directory", plog.Args( plog.Warn("Failed to get project from current directory", plog.Args(
@ -67,11 +67,11 @@ func projectShowCmdRun(cmd *cobra.Command, args []string) {
WithLeftPadding(5).WithRightPadding(5). WithLeftPadding(5).WithRightPadding(5).
WithBoxStyle(&pterm.Style{pterm.FgLightBlue}). WithBoxStyle(&pterm.Style{pterm.FgLightBlue}).
WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Project Information"))). WithTitle(pterm.Bold.Sprint(pterm.LightGreen("Project Information"))).
Println(cache.ProjectString(project)) Println(projectCache.ProjectString(project))
fmt.Println() fmt.Println()
if inCwd { if inCwd {
project.SetRepo(cache.OpenProject(cmd.Context(), project)) project.SetRepo(projectCache.OpenProject(cmd.Context(), project))
fmt.Fprintln(os.Stderr, project.GetGitInfo()+"\n") fmt.Fprintln(os.Stderr, project.GetGitInfo()+"\n")
} }
} }

View File

@ -11,13 +11,13 @@ import (
func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) ( func validProjectsFunc(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective) { []string, cobra.ShellCompDirective) {
initProjectCache(cmd, args) initProjectCache(cmd, args)
return cache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp return projectCache.ProjectStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
} }
func validAliasesFunc(cmd *cobra.Command, args []string, toComplete string) ( func validAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective) { []string, cobra.ShellCompDirective) {
initProjectCache(cmd, args) initProjectCache(cmd, args)
return cache.AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp return projectCache.AliasStrings(toComplete), cobra.ShellCompDirectiveNoFileComp
} }
func validProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete string) ( func validProjectsOrAliasesFunc(cmd *cobra.Command, args []string, toComplete string) (
@ -53,8 +53,8 @@ func validLogLevelsFunc(cmd *cobra.Command, args []string, toComplete string) (
func validProjectIdFunc(cmd *cobra.Command, args []string, toComplete string) ( func validProjectIdFunc(cmd *cobra.Command, args []string, toComplete string) (
[]string, cobra.ShellCompDirective) { []string, cobra.ShellCompDirective) {
initProjectCache(cmd, args) initProjectCache(cmd, args)
matchingIds := make([]string, 0, len(cache.Projects)) matchingIds := make([]string, 0, len(projectCache.Projects))
for _, p := range cache.Projects { for _, p := range projectCache.Projects {
idString := strconv.FormatInt(int64(p.ID), 10) idString := strconv.FormatInt(int64(p.ID), 10)
if strings.HasPrefix(idString, toComplete) { if strings.HasPrefix(idString, toComplete) {
matchingIds = append(matchingIds, idString) matchingIds = append(matchingIds, idString)

View File

@ -4,7 +4,7 @@ import (
"context" "context"
fzf "github.com/ktr0731/go-fuzzyfinder" fzf "github.com/ktr0731/go-fuzzyfinder"
cacheProjects "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes/projects"
"golang.org/x/exp/slices" "golang.org/x/exp/slices"
) )
@ -40,7 +40,7 @@ func fzfFindProject(opts *fzfProjectOpts) *projects.Project {
func fzfCwdOrSearchProjectAliases(opts *fzfProjectOpts) *projects.Project { func fzfCwdOrSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
var project *projects.Project var project *projects.Project
if opts.Search == "." { if opts.Search == "." {
project, _ = cache.GetProjectFromCwd() project, _ = projectCache.GetProjectFromCwd()
} else { } else {
project = fzfSearchProjectAliases(opts) project = fzfSearchProjectAliases(opts)
} }
@ -51,13 +51,13 @@ func fzfCwdOrSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
// match if one is given // match if one is given
func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project { func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
var project *projects.Project var project *projects.Project
var alias *cacheProjects.ProjectAlias var alias *cache.ProjectAlias
if alias = cache.GetAliasByName(opts.Search, opts.Gitlabs...); alias != nil { if alias = projectCache.GetAliasByName(opts.Search, opts.Gitlabs...); alias != nil {
project = cache.GetProjectByAlias(alias) project = projectCache.GetProjectByAlias(alias)
plog.Info("Perfect alias match... flawless") plog.Info("Perfect alias match... flawless")
} else { } else {
// Get fuzzy if we don't have an exact match // Get fuzzy if we don't have an exact match
aliases := cache.FuzzyFindAlias(opts.Search) aliases := projectCache.FuzzyFindAlias(opts.Search)
if len(aliases) > 1 { if len(aliases) > 1 {
// If multiple aliases were found, switch over to project // If multiple aliases were found, switch over to project
// by alias mode with merging // by alias mode with merging
@ -65,7 +65,7 @@ func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
project, _ = fzfProjectFromAliases(opts, aliases) project, _ = fzfProjectFromAliases(opts, aliases)
} else if len(aliases) == 1 { } else if len(aliases) == 1 {
alias = aliases[0] alias = aliases[0]
project = cache.GetProjectByAlias(alias) project = projectCache.GetProjectByAlias(alias)
} }
} }
return project return project
@ -75,12 +75,12 @@ func fzfSearchProjectAliases(opts *fzfProjectOpts) *projects.Project {
// a single one. Replaced by fzfProjectFromAliases in fzfSearchProjectAliases // a single one. Replaced by fzfProjectFromAliases in fzfSearchProjectAliases
// as merging is preferred, but can be used if it's ever desirable to // as merging is preferred, but can be used if it's ever desirable to
// return a single alias from all aliases // return a single alias from all aliases
func fzfAliasFromAliases(opts *fzfProjectOpts, aliases []*cacheProjects.ProjectAlias) *cacheProjects.ProjectAlias { func fzfAliasFromAliases(opts *fzfProjectOpts, aliases []*cache.ProjectAlias) *cache.ProjectAlias {
var alias *cacheProjects.ProjectAlias var alias *cache.ProjectAlias
i, err := fzf.Find( i, err := fzf.Find(
aliases, aliases,
func(i int) string { func(i int) string {
return aliases[i].Alias + " -> " + cache.GetProjectByAlias(aliases[i]).PathWithNamespace return aliases[i].Alias + " -> " + projectCache.GetProjectByAlias(aliases[i]).PathWithNamespace
}, },
fzf.WithContext(opts.Ctx), fzf.WithContext(opts.Ctx),
fzf.WithHeader("Choose an Alias"), fzf.WithHeader("Choose an Alias"),
@ -95,7 +95,7 @@ func fzfAliasFromAliases(opts *fzfProjectOpts, aliases []*cacheProjects.ProjectA
// Given a list of aliases, merge them together and use the resulting // Given a list of aliases, merge them together and use the resulting
// list of projects to return a project // list of projects to return a project
func fzfProjectFromAliases(opts *fzfProjectOpts, aliases []*cacheProjects.ProjectAlias) ( func fzfProjectFromAliases(opts *fzfProjectOpts, aliases []*cache.ProjectAlias) (
*projects.Project, error) { *projects.Project, error) {
mergedProjects := projectsFromAliases(aliases) mergedProjects := projectsFromAliases(aliases)
if len(mergedProjects) == 1 { if len(mergedProjects) == 1 {
@ -104,7 +104,7 @@ func fzfProjectFromAliases(opts *fzfProjectOpts, aliases []*cacheProjects.Projec
return fzfProjectFromProjects(opts, mergedProjects) return fzfProjectFromProjects(opts, mergedProjects)
} }
func projectsFromAliases(aliases []*cacheProjects.ProjectAlias) []*projects.Project { func projectsFromAliases(aliases []*cache.ProjectAlias) []*projects.Project {
projects := make([]*projects.Project, 0) projects := make([]*projects.Project, 0)
ALIASES: ALIASES:
@ -115,7 +115,7 @@ ALIASES:
continue ALIASES continue ALIASES
} }
} }
projects = append(projects, cache.GetProjectByAlias(a)) projects = append(projects, projectCache.GetProjectByAlias(a))
} }
return projects return projects
@ -126,9 +126,9 @@ ALIASES:
func fzfProject(opts *fzfProjectOpts) (*projects.Project, error) { func fzfProject(opts *fzfProjectOpts) (*projects.Project, error) {
var searchableProjects []*projects.Project var searchableProjects []*projects.Project
if opts.MustHaveAlias { if opts.MustHaveAlias {
searchableProjects = cache.GetProjectsWithAliases() searchableProjects = projectCache.GetProjectsWithAliases()
} else { } else {
searchableProjects = cache.Projects searchableProjects = projectCache.Projects
} }
// Filter out unwanted gitlabs if provided // Filter out unwanted gitlabs if provided
searchableProjects = filterProjectsWithGitlabs(searchableProjects, opts.Gitlabs...) searchableProjects = filterProjectsWithGitlabs(searchableProjects, opts.Gitlabs...)
@ -141,11 +141,11 @@ func fzfProjectFromProjects(opts *fzfProjectOpts, projects []*projects.Project)
i, err := fzf.Find(projects, i, err := fzf.Find(projects,
func(i int) string { func(i int) string {
// Display the project along with its aliases // Display the project along with its aliases
return cache.GetProjectStringWithAliases(projects[i]) return projectCache.GetProjectStringWithAliases(projects[i])
}, },
fzf.WithPreviewWindow( fzf.WithPreviewWindow(
func(i, width, height int) string { func(i, width, height int) string {
return cache.ProjectString(projects[i]) return projectCache.ProjectString(projects[i])
}, },
), ),
fzf.WithContext(opts.Ctx), fzf.WithContext(opts.Ctx),
@ -158,8 +158,8 @@ func fzfProjectFromProjects(opts *fzfProjectOpts, projects []*projects.Project)
} }
func fzfPreviewWindow(i, w, h int) string { func fzfPreviewWindow(i, w, h int) string {
p := cache.Projects[i] p := projectCache.Projects[i]
return cache.ProjectString(p) return projectCache.ProjectString(p)
} }
func filterProjectsWithGitlabs(gitProjects []*projects.Project, gitlabs ...string) []*projects.Project { func filterProjectsWithGitlabs(gitProjects []*projects.Project, gitlabs ...string) []*projects.Project {

View File

@ -7,8 +7,8 @@ import (
"strings" "strings"
"github.com/spf13/cobra" "github.com/spf13/cobra"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/cache"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/config"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/projects"
"gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes" "gitlab.sweetwater.com/it/devops/tools/gitlab-project-manager/internal/remotes"
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
@ -59,7 +59,7 @@ func initProjectCache(cmd *cobra.Command, args []string) {
os.Exit(1) os.Exit(1)
} }
cacheOpts := &projects.CacheOpts{ cacheOpts := &cache.CacheOpts{
ProjectsPath: conf.ProjectPath, ProjectsPath: conf.ProjectPath,
Path: conf.Cache.File, Path: conf.Cache.File,
TTL: conf.Cache.Ttl, TTL: conf.Cache.Ttl,
@ -67,12 +67,12 @@ func initProjectCache(cmd *cobra.Command, args []string) {
Gitlabs: gitlabs, Gitlabs: gitlabs,
Config: &conf, Config: &conf,
} }
if cache, err = projects.NewProjectCache(cacheOpts); err != nil { if projectCache, err = cache.NewProjectCache(cacheOpts); err != nil {
plog.Error("Failed to prepare project cache", plog.Args("error", err)) plog.Error("Failed to prepare project cache", plog.Args("error", err))
os.Exit(1) os.Exit(1)
} }
if err := cache.Read(); err != nil { if err := projectCache.Read(); err != nil {
plog.Error("Cache load failed", plog.Args("error", err)) plog.Error("Cache load failed", plog.Args("error", err))
os.Exit(1) os.Exit(1)
} }
@ -81,7 +81,7 @@ func initProjectCache(cmd *cobra.Command, args []string) {
} }
func postProjectCache(cmd *cobra.Command, args []string) { func postProjectCache(cmd *cobra.Command, args []string) {
cache.Write() projectCache.Write()
} }
func initProjectPath(cmd *cobra.Command, args []string) { func initProjectPath(cmd *cobra.Command, args []string) {

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"strings" "strings"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"strings" "strings"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"strings" "strings"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"bytes" "bytes"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"errors" "errors"

View File

@ -1,4 +1,4 @@
package projects package cache
import ( import (
"context" "context"