-
Notifications
You must be signed in to change notification settings - Fork 5
/
config.go
51 lines (40 loc) · 1.03 KB
/
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
45
46
47
48
49
50
51
package spool
import (
"fmt"
"google.golang.org/api/option"
)
type Config struct {
projectID string
instanceID string
databaseID string
opts []option.ClientOption
}
func NewConfig(projectID, instanceID, databaseID string, opts ...option.ClientOption) *Config {
return &Config{
projectID: projectID,
instanceID: instanceID,
databaseID: databaseID,
opts: opts,
}
}
func (c *Config) ProjectID() string {
return c.projectID
}
func (c *Config) InstanceID() string {
return c.instanceID
}
func (c *Config) DatabaseID() string {
return c.databaseID
}
func (c *Config) Instance() string {
return fmt.Sprintf("projects/%s/instances/%s", c.projectID, c.instanceID)
}
func (c *Config) Database() string {
return fmt.Sprintf("projects/%s/instances/%s/databases/%s", c.projectID, c.instanceID, c.databaseID)
}
func (c *Config) ClientOptions() []option.ClientOption {
return c.opts
}
func (c *Config) WithDatabaseID(databaseID string) *Config {
return NewConfig(c.projectID, c.instanceID, databaseID, c.ClientOptions()...)
}