github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/lib/repository/info.go (about) 1 package repositoryLib 2 3 import ( 4 "fmt" 5 6 singletonsI18n "github.com/taubyte/tau-cli/i18n/singletons" 7 authClient "github.com/taubyte/tau-cli/singletons/auth_client" 8 ) 9 10 func (info *Info) GetNameFromID() error { 11 client, err := authClient.Load() 12 if err != nil { 13 return singletonsI18n.LoadingAuthClientFailed(err) 14 } 15 16 repo, err := client.GetRepositoryById(info.ID) 17 if err != nil { 18 return fmt.Errorf("getting repo by id failed with: %w", err) 19 } 20 21 info.FullName = repo.Get().FullName() 22 if len(info.FullName) == 0 { 23 return fmt.Errorf("could not find repository with id `%s`", info.ID) 24 } 25 26 return nil 27 } 28 29 func (info *Info) GetIDFromName() error { 30 client, err := authClient.Load() 31 if err != nil { 32 return err 33 } 34 35 repo, err := client.GetRepositoryByName(info.FullName) 36 if err != nil { 37 return err 38 } 39 40 id := repo.Get().ID() 41 if len(id) == 0 { 42 return fmt.Errorf("could not find repository with name `%s`", info.FullName) 43 } 44 45 info.ID = id 46 return nil 47 }