git-project-manager/internal/projects/cache_aliases.go

24 lines
451 B
Go
Raw Normal View History

2023-12-08 21:52:26 +00:00
package projects
import "errors"
func (c *Cache) addAlias(alias string, projectID int) error {
if c.GetAliasByName(alias) != nil {
return errors.New("Failed to add alias, already exists")
}
c.Aliases = append(c.Aliases,
&ProjectAlias{
Alias: alias,
ProjectID: projectID,
})
return nil
}
func (c *Cache) AddAlias(alias string, projectID int) error {
c.lock.Lock()
defer c.lock.Unlock()
return c.addAlias(alias, projectID)
}