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