-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
35 lines (29 loc) · 847 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" json:"name" toml:"name"`
Kind string `yaml:"kind" json:"kind" toml:"kind"`
Prefix string `yaml:"prefix" json:"prefix" toml:"prefix"`
Suffix string `yaml:"suffix" json:"suffix" toml:"suffix"`
Separator string `yaml:"separator" json:"separator" toml:"separator"`
}
// 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
}