-
Notifications
You must be signed in to change notification settings - Fork 279
/
factory.go
52 lines (42 loc) · 1.12 KB
/
factory.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
package writer
import (
"fmt"
"github.com/buildpacks/pack"
"github.com/buildpacks/pack/internal/config"
"github.com/buildpacks/pack/logging"
"github.com/buildpacks/pack/internal/style"
)
type Factory struct{}
type BuilderWriter interface {
Print(
logger logging.Logger,
localRunImages []config.RunImage,
local, remote *pack.BuilderInfo,
localErr, remoteErr error,
builderInfo SharedBuilderInfo,
) error
}
type SharedBuilderInfo struct {
Name string `json:"builder_name" yaml:"builder_name" toml:"builder_name"`
Trusted bool `json:"trusted" yaml:"trusted" toml:"trusted"`
IsDefault bool `json:"default" yaml:"default" toml:"default"`
}
type BuilderWriterFactory interface {
Writer(kind string) (BuilderWriter, error)
}
func NewFactory() *Factory {
return &Factory{}
}
func (f *Factory) Writer(kind string) (BuilderWriter, error) {
switch kind {
case "human-readable":
return NewHumanReadable(), nil
case "json":
return NewJSON(), nil
case "yaml":
return NewYAML(), nil
case "toml":
return NewTOML(), nil
}
return nil, fmt.Errorf("output format %s is not supported", style.Symbol(kind))
}