forked from copilot-extensions/function-calling-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinfo.go
More file actions
57 lines (46 loc) · 1.21 KB
/
info.go
File metadata and controls
57 lines (46 loc) · 1.21 KB
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
52
53
54
55
56
57
package config
import (
"fmt"
"os"
)
type Info struct {
// Port is the local port on which the application will run
Port string
// FQDN (for Fully-Qualified Domain Name) is the internet facing host address
// where application will live (e.g. https://example.com)
FQDN string
// ClientID comes from your configured GitHub app
ClientID string
// ClientSecret comes from your configured GitHub app
ClientSecret string
}
const (
portEnv = "PORT"
clientIdEnv = "CLIENT_ID"
clientSecretEnv = "CLIENT_SECRET"
fqdnEnv = "FQDN"
)
func New() (*Info, error) {
port := os.Getenv(portEnv)
if port == "" {
return nil, fmt.Errorf("%s environment variable required", portEnv)
}
fqdn := os.Getenv(fqdnEnv)
if fqdn == "" {
return nil, fmt.Errorf("%s environment variable required", fqdnEnv)
}
clientID := os.Getenv(clientIdEnv)
if clientID == "" {
return nil, fmt.Errorf("%s environment variable required", clientIdEnv)
}
clientSecret := os.Getenv(clientSecretEnv)
if clientSecret == "" {
return nil, fmt.Errorf("%s environment variable required", clientSecretEnv)
}
return &Info{
Port: port,
FQDN: fqdn,
ClientID: clientID,
ClientSecret: clientSecret,
}, nil
}