blob: 44ca7e6dc7e2abe51d2d7b1fedfa8f6535f02503 (
plain)
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
|
package config
import (
"os"
"time"
)
type Config struct {
APIKey string
BaseURL string
Timeout time.Duration
MaxRetries int
UserAgent string
}
func New() *Config {
return &Config{
APIKey: os.Getenv("DBORG_API_KEY"),
BaseURL: "https://db.org.ai",
Timeout: 30 * time.Second,
MaxRetries: 3,
UserAgent: "dborg-cli/1.0",
}
}
func (c *Config) WithAPIKey(key string) *Config {
c.APIKey = key
return c
}
func (c *Config) Validate() error {
if c.APIKey == "" {
return ErrMissingAPIKey
}
return nil
}
|