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

     1  package library
     2  
     3  import (
     4  	structureSpec "github.com/taubyte/go-specs/structure"
     5  	repositoryCommands "github.com/taubyte/tau-cli/cli/commands/resources/repository"
     6  	repositoryLib "github.com/taubyte/tau-cli/lib/repository"
     7  )
     8  
     9  type wrapped struct {
    10  	resource *structureSpec.Library
    11  }
    12  
    13  type setter struct {
    14  	resource *structureSpec.Library
    15  }
    16  
    17  type getter struct {
    18  	resource *structureSpec.Library
    19  }
    20  
    21  func (rw wrapped) Set() repositoryCommands.Setter {
    22  	return &setter{rw.resource}
    23  }
    24  
    25  func (rw wrapped) Get() repositoryCommands.Getter {
    26  	return &getter{rw.resource}
    27  }
    28  
    29  func (rw wrapped) UnWrap() *structureSpec.Library {
    30  	return rw.resource
    31  }
    32  
    33  func (g getter) Name() string {
    34  	return g.resource.Name
    35  }
    36  
    37  func (g getter) Description() string {
    38  	return g.resource.Description
    39  }
    40  
    41  func (g getter) RepoName() string {
    42  	return g.resource.RepoName
    43  }
    44  
    45  func (g getter) RepoID() string {
    46  	return g.resource.RepoID
    47  }
    48  
    49  func (g getter) Branch() string {
    50  	return g.resource.Branch
    51  }
    52  
    53  func (g getter) RepositoryURL() string {
    54  	return repositoryLib.GetRepositoryUrl(g.resource.Provider, g.resource.RepoName)
    55  }
    56  
    57  func (s setter) RepoID(id string) {
    58  	s.resource.RepoID = id
    59  }
    60  
    61  func (s setter) RepoName(name string) {
    62  	s.resource.RepoName = name
    63  }
    64  
    65  func Wrap(resource *structureSpec.Library) repositoryCommands.Resource {
    66  	return wrapped{resource}
    67  }