-
Notifications
You must be signed in to change notification settings - Fork 57
/
pack.go
122 lines (100 loc) · 3.55 KB
/
pack.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package ruby
import (
"github.com/cloud66-oss/starter/bundle"
"github.com/cloud66-oss/starter/common"
"github.com/cloud66-oss/starter/packs"
)
type Pack struct {
packs.PackBase
Analysis *Analysis
}
const (
rubyRailsStencilTemplatePath = "https://raw.githubusercontent.com/cloud66/stencils-ruby-rails/{{.branch}}/" // this way we only have to add the filename. We should start by download the templates.json, do a couples of checks and after that download the stuff
rubyRailsGithubURL = "https://github.com/cloud66/stencils-ruby-rails.git"
)
func (p *Pack) Name() string {
return "ruby"
}
func (p *Pack) LanguageVersion() string {
return ""
}
func (p *Pack) FilesToBeAnalysed() []string {
return []string{"Gemfile", "Procfile", "config/database.yml"}
}
func (p *Pack) Framework() string {
return p.Analysis.Framework
}
func (p *Pack) FrameworkVersion() string {
return p.Analysis.FrameworkVersion
}
func (p *Pack) GetSupportedLanguageVersions() []string {
return nil
}
func (p *Pack) SetSupportedLanguageVersions(version []string) {
}
func (p *Pack) Detector() packs.Detector {
return &Detector{PackElement: packs.PackElement{Pack: p}}
}
func (p *Pack) Analyze(rootDir string, environment string, shouldPrompt bool, git_repo string, git_branch string) error {
var err error
a := Analyzer{
AnalyzerBase: packs.AnalyzerBase{
PackElement: packs.PackElement{Pack: p},
RootDir: rootDir,
ShouldPrompt: shouldPrompt,
GitURL: git_repo,
GitBranch: git_branch,
Environment: environment}}
p.Analysis, err = a.Analyze()
return err
}
func (p *Pack) WriteDockerfile(templateDir string, outputDir string, shouldPrompt bool) error {
w := DockerfileWriter{
packs.DockerfileWriterBase{
PackElement: packs.PackElement{Pack: p},
TemplateWriterBase: packs.TemplateWriterBase{
TemplateDir: templateDir,
OutputDir: outputDir,
ShouldPrompt: shouldPrompt}}}
return w.Write(p.Analysis.DockerfileContext)
}
func (p *Pack) WriteServiceYAML(templateDir string, outputDir string, shouldPrompt bool) error {
w := ServiceYAMLWriter{
packs.ServiceYAMLWriterBase{
PackElement: packs.PackElement{Pack: p},
TemplateWriterBase: packs.TemplateWriterBase{
TemplateDir: templateDir,
OutputDir: outputDir,
ShouldPrompt: shouldPrompt}}}
return w.Write(p.Analysis.ServiceYAMLContext)
}
func (p *Pack) WriteDockerComposeYAML(templateDir string, outputDir string, shouldPrompt bool) error {
w := DockerComposeYAMLWriter{
packs.DockerComposeYAMLWriterBase{
PackElement: packs.PackElement{Pack: p},
TemplateWriterBase: packs.TemplateWriterBase{
TemplateDir: templateDir,
OutputDir: outputDir,
ShouldPrompt: shouldPrompt}}}
return w.Write(p.Analysis.DockerComposeYAMLContext)
}
func (p *Pack) WriteKubesConfig(outputDir string, shouldPrompt bool) error {
common.PrintlnWarning("You can not generate a Kubernetes configuration file using this pack. Nothing to do.")
return nil
}
func (p *Pack) CreateSkycapFiles(outputDir string, templateDir string, branch string) error {
var templateRepository = p.StencilRepositoryPath()
return bundle.CreateSkycapFiles(outputDir, templateRepository, branch, p.Name(), rubyRailsGithubURL, p.Analysis.ServiceYAMLContext.Services, p.Analysis.ServiceYAMLContext.Dbs)
}
func (p *Pack) GetMessages() []string {
return p.Analysis.Messages.Items
}
func (p *Pack) GetDatabases() []string {
return []string{}
}
func (p *Pack) GetStartCommands() []string {
return p.Analysis.ListOfStartCommands
}
func (p *Pack) StencilRepositoryPath() string {
return rubyRailsStencilTemplatePath
}