-
Notifications
You must be signed in to change notification settings - Fork 4
/
dockerfile_builder.go
executable file
·59 lines (49 loc) · 1023 Bytes
/
dockerfile_builder.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
package dockerfile
import (
"embed"
"errors"
"github.com/manifoldco/promptui"
)
//go:embed templates/*
var templatesContent embed.FS
type DockerfileData struct {
EntryFile string
Version string
ProjectName string
}
func validateProjectName(input string) error {
if len(input) < 1 {
return errors.New("The project name is required")
}
return nil
}
func validateEntryfile(input string) error {
if len(input) < 1 {
return errors.New("The entry file is required")
}
return nil
}
func setProjectName() (string, error) {
var projectName string
prompt := promptui.Prompt{
Label: "Type your project name",
Validate: validateProjectName,
}
projectName, err := prompt.Run()
if err != nil {
return "", err
}
return projectName, nil
}
func setEntryfile() (string, error) {
var entryfile string
prompt := promptui.Prompt{
Label: "Type your entry file",
Validate: validateEntryfile,
}
entryfile, err := prompt.Run()
if err != nil {
return "", err
}
return entryfile, nil
}