-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
38 lines (31 loc) · 839 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
36
37
38
package migrate
import (
"github.com/alexfalkowski/go-service/os"
)
type (
// URL for migrate.
URL string
// Database for migrate.
Database struct {
Name string `yaml:"name,omitempty" json:"name,omitempty" toml:"name,omitempty"`
Source string `yaml:"source,omitempty" json:"source,omitempty" toml:"source,omitempty"`
URL URL `yaml:"url,omitempty" json:"url,omitempty" toml:"url,omitempty"`
}
// Config for migrate.
Config struct {
Databases []*Database `yaml:"databases,omitempty" json:"databases,omitempty" toml:"databases,omitempty"`
}
)
// Database by name.
func (c *Config) Database(name string) *Database {
for _, d := range c.Databases {
if d.Name == name {
return d
}
}
return nil
}
// GetURL for database.
func (d *Database) GetURL() (string, error) {
return os.ReadFile(string(d.URL))
}