github.com/taubyte/tau-cli@v0.1.13-0.20240326000942-487f0d57edfc/cli/commands/resources/repository/import.go (about)

     1  package repositoryCommands
     2  
     3  import (
     4  	repositoryI18n "github.com/taubyte/tau-cli/i18n/repository"
     5  	loginLib "github.com/taubyte/tau-cli/lib/login"
     6  	authClient "github.com/taubyte/tau-cli/singletons/auth_client"
     7  	"github.com/urfave/cli/v2"
     8  )
     9  
    10  func (lib *repositoryCommands) Import(ctx *cli.Context) error {
    11  	profile, err := loginLib.GetSelectedProfile()
    12  	if err != nil {
    13  		return err
    14  	}
    15  
    16  	resource, err := lib.PromptsGetOrSelect(ctx)
    17  	if err != nil {
    18  		return err
    19  	}
    20  
    21  	auth, err := authClient.Load()
    22  	if err != nil {
    23  		return err
    24  	}
    25  
    26  	repoName := resource.Get().RepoName()
    27  	if err = auth.RegisterRepository(resource.Get().RepoID()); err != nil {
    28  		return repositoryI18n.RegisteringRepositoryFailed(repoName, err)
    29  	}
    30  
    31  	repositoryI18n.Imported(repoName, profile.Network)
    32  	repositoryI18n.TriggerBuild()
    33  
    34  	return nil
    35  }