-
Notifications
You must be signed in to change notification settings - Fork 20
/
main.go
121 lines (97 loc) · 3.8 KB
/
main.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
package main
import (
"log"
"os"
"github.com/go-git/go-billy/v5/osfs"
"github.com/pivotal-cf/jhanda"
"github.com/pivotal-cf/kiln/internal/baking"
"github.com/pivotal-cf/kiln/internal/builder"
"github.com/pivotal-cf/kiln/internal/commands"
"github.com/pivotal-cf/kiln/internal/component"
"github.com/pivotal-cf/kiln/internal/pivnet"
"github.com/pivotal-cf/kiln/pkg/cargo"
)
var version = "unknown"
func main() {
errLogger := log.New(os.Stderr, "", 0)
outLogger := log.New(os.Stdout, "", 0)
var global struct {
Help bool `short:"h" long:"help" description:"prints this usage information" default:"false"`
Version bool `short:"v" long:"version" description:"prints the kiln release version" default:"false"`
}
args, err := jhanda.Parse(&global, os.Args[1:])
if err != nil {
log.Fatal(err)
}
globalFlagsUsage, err := jhanda.PrintUsage(global)
if err != nil {
log.Fatal(err)
}
var command string
if len(args) > 0 {
command, args = args[0], args[1:]
}
if global.Version {
command = "version"
}
if global.Help {
command = "help"
}
if command == "" {
command = "help"
}
fs := osfs.New("")
releaseManifestReader := builder.NewReleaseManifestReader()
releasesService := baking.NewReleasesService(errLogger, releaseManifestReader)
pivnetService := new(pivnet.Service)
localReleaseDirectory := component.NewLocalReleaseDirectory(outLogger)
mrsProvider := commands.MultiReleaseSourceProvider(func(kilnfile cargo.Kilnfile, allowOnlyPublishable bool) component.MultiReleaseSource {
repo := component.NewReleaseSourceRepo(kilnfile)
return repo.Filter(allowOnlyPublishable)
})
ruFinder := commands.ReleaseUploaderFinder(func(kilnfile cargo.Kilnfile, sourceID string) (component.ReleaseUploader, error) {
repo := component.NewReleaseSourceRepo(kilnfile)
return repo.FindReleaseUploader(sourceID)
})
rpFinder := commands.RemotePatherFinder(func(kilnfile cargo.Kilnfile, sourceID string) (component.RemotePather, error) {
repo := component.NewReleaseSourceRepo(kilnfile)
return repo.FindRemotePather(sourceID)
})
commandSet := jhanda.CommandSet{}
fetch := commands.NewFetch(outLogger, mrsProvider, localReleaseDirectory)
commandSet["fetch"] = fetch
bakeCommand := commands.NewBake(fs, releasesService, outLogger, errLogger, fetch)
bakeCommand.KilnVersion = version
commandSet["bake"] = bakeCommand
commandSet["re-bake"] = commands.NewReBake(bakeCommand)
commandSet["test"] = commands.NewTileTest()
commandSet["help"] = commands.NewHelp(os.Stdout, globalFlagsUsage, commandSet)
commandSet["version"] = commands.NewVersion(outLogger, version)
commandSet["update-release"] = commands.NewUpdateRelease(outLogger, fs, mrsProvider)
commandSet["upload-release"] = commands.UploadRelease{
FS: fs,
Logger: outLogger,
ReleaseUploaderFinder: ruFinder,
}
commandSet["sync-with-local"] = commands.NewSyncWithLocal(fs, localReleaseDirectory, rpFinder, outLogger)
commandSet["publish"] = commands.NewPublish(outLogger, errLogger, osfs.New(""))
commandSet["update-stemcell"] = commands.UpdateStemcell{
Logger: outLogger,
MultiReleaseSourceProvider: mrsProvider,
FS: osfs.New(""),
}
// commandSet["fetch"] = commands.NewFetch(outLogger, mrsProvider, localReleaseDirectory)
commandSet["glaze"] = commands.NewGlaze()
commandSet["generate-osm-manifest"] = commands.NewOSM(outLogger, nil)
commandSet["find-release-version"] = commands.NewFindReleaseVersion(outLogger, mrsProvider)
commandSet["find-stemcell-version"] = commands.NewFindStemcellVersion(outLogger, pivnetService)
commandSet["validate"] = commands.NewValidate(osfs.New(""))
commandSet["release-notes"], err = commands.NewReleaseNotesCommand()
if err != nil {
log.Fatal(err)
}
err = commandSet.Execute(command, args)
if err != nil {
log.Fatal(err)
}
}