-
Notifications
You must be signed in to change notification settings - Fork 4
/
up.interactive.go
89 lines (67 loc) · 2.1 KB
/
up.interactive.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
package action
import (
"os"
"bunnyshell.com/cli/pkg/interactive"
mutagenConfig "bunnyshell.com/dev/pkg/mutagen/config"
"bunnyshell.com/dev/pkg/util"
)
func (up *Up) ensureSyncPaths(parameters *UpParameters) error {
if parameters.SyncMode == mutagenConfig.None {
return up.ensurePersistentWorkdir(parameters)
}
if err := up.ensureLocalSyncPath(parameters); err != nil {
return err
}
if err := up.ensureRemoteSyncPath(parameters); err != nil {
return err
}
return nil
}
func (up *Up) ensureLocalSyncPath(parameters *UpParameters) error {
if parameters.LocalSyncPath != "" {
return nil
}
cwd, err := os.Getwd()
if err != nil {
return err
}
question := interactive.NewInput("Local Sync Path")
question.Default = cwd
question.Help = "Local path is the folder on your machine that will be synced into the container"
question.SetValidate(util.IsDirectoryValidator)
syncPath, err := question.AskString()
if err != nil {
return err
}
parameters.LocalSyncPath = syncPath
return nil
}
func (up *Up) ensureRemoteSyncPath(parameters *UpParameters) error {
if parameters.RemoteSyncPath != "" {
return nil
}
question := interactive.NewInput("Remote Sync Path")
question.Help = "Remote path is the folder within the container where the application is loaded from\n" +
"This is where the local files will be synced to\n" +
"This folder will be mounted as a persistent volume to persist your changes across multiple development sessions."
syncPath, err := question.AskString()
if err != nil {
return err
}
parameters.RemoteSyncPath = syncPath
return nil
}
func (up *Up) ensurePersistentWorkdir(parameters *UpParameters) error {
if parameters.RemoteSyncPath != "" {
return nil
}
question := interactive.NewInput("Persistent Workdir")
question.Help = "Persistent workdir is the folder within the container where the application is loaded from\n" +
"This folder will be mounted as a persistent volume to persist your changes across multiple development sessions."
syncPath, err := question.AskString()
if err != nil {
return err
}
parameters.RemoteSyncPath = syncPath
return nil
}