-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.go
44 lines (38 loc) · 948 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
39
40
41
42
43
44
package firebase
type (
// Config stores firebase app configuration settings
Config struct {
Name string
Credentials *Credentials
CredentialsPath string
}
// Option is the signature for configuration options
Option func(*Config) error
)
func defaultConfig() *Config {
return &Config{
Name: defaultAppName,
CredentialsPath: "firebase-credentials.json",
}
}
// WithName sets the name of the app
func WithName(name string) func(*Config) error {
return func(c *Config) error {
c.Name = normalizeName(name)
return nil
}
}
// WithCredentialsPath sets the path to load credentials from
func WithCredentialsPath(path string) func(*Config) error {
return func(c *Config) error {
c.CredentialsPath = path
return nil
}
}
// WithCredentials sets the credentials
func WithCredentials(creds *Credentials) func(*Config) error {
return func(c *Config) error {
c.Credentials = creds
return nil
}
}