github.com/azure/draft-classic@v0.16.0/pkg/draft/pack/repo/installer/local_installer.go (about) 1 package installer 2 3 import ( 4 "path/filepath" 5 6 "github.com/Azure/draft/pkg/draft/draftpath" 7 "github.com/Azure/draft/pkg/draft/pack/repo" 8 "github.com/Azure/draft/pkg/osutil" 9 ) 10 11 // LocalInstaller installs pack repos from the filesystem 12 type LocalInstaller struct { 13 base 14 } 15 16 // NewLocalInstaller creates a new LocalInstaller 17 func NewLocalInstaller(source string, home draftpath.Home) (*LocalInstaller, error) { 18 19 i := &LocalInstaller{ 20 base: newBase(source, home), 21 } 22 23 return i, nil 24 } 25 26 // Path is where the pack repo will be symlinked to. 27 func (i *LocalInstaller) Path() string { 28 if i.Source == "" { 29 return "" 30 } 31 return filepath.Join(i.DraftHome.Packs(), filepath.Base(i.Source)) 32 } 33 34 // Install creates a symlink to the pack repo directory in $DRAFT_HOME 35 func (i *LocalInstaller) Install() error { 36 if !isPackRepo(i.Source) { 37 return repo.ErrHomeMissing 38 } 39 40 src, err := filepath.Abs(i.Source) 41 if err != nil { 42 return err 43 } 44 45 return osutil.SymlinkWithFallback(src, i.Path()) 46 } 47 48 // Update updates a local repository 49 func (i *LocalInstaller) Update() error { 50 return nil 51 }