-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
35 lines (29 loc) · 997 Bytes
/
config.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
package generator
import (
"fmt"
)
// Application fto generate identifiers.
type Application struct {
Name string `yaml:"name,omitempty" json:"name,omitempty" toml:"name,omitempty"`
Kind string `yaml:"kind,omitempty" json:"kind,omitempty" toml:"kind,omitempty"`
Prefix string `yaml:"prefix,omitempty" json:"prefix,omitempty" toml:"prefix,omitempty"`
Suffix string `yaml:"suffix,omitempty" json:"suffix,omitempty" toml:"suffix,omitempty"`
Separator string `yaml:"separator,omitempty" json:"separator,omitempty" toml:"separator,omitempty"`
}
// ID for the application.
func (a *Application) ID(id string) string {
return fmt.Sprintf("%s%s%s%s%s", a.Prefix, a.Separator, id, a.Separator, a.Suffix)
}
// Config for generator.
type Config struct {
Applications []*Application `yaml:"applications"`
}
// Application by name.
func (c *Config) Application(name string) *Application {
for _, d := range c.Applications {
if d.Name == name {
return d
}
}
return nil
}