-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathutils.go
More file actions
40 lines (31 loc) · 952 Bytes
/
utils.go
File metadata and controls
40 lines (31 loc) · 952 Bytes
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
package controller
import (
"fmt"
"github.com/drycc/builder/pkg/conf"
drycc "github.com/drycc/controller-sdk-go"
"github.com/drycc/pkg/log"
)
// New creates a new SDK client configured as the builder.
func New(host, port string) (*drycc.Client, error) {
client, err := drycc.New(true, fmt.Sprintf("http://%s:%s/", host, port), "")
if err != nil {
return client, err
}
client.UserAgent = "drycc-builder"
builderKey, err := conf.GetBuilderKey()
if err != nil {
return client, err
}
client.HooksToken = builderKey
return client, nil
}
// CheckAPICompat checks for API compatibility errors and warns about them.
func CheckAPICompat(c *drycc.Client, err error) error {
if err == drycc.ErrAPIMismatch {
log.Info("WARNING: SDK and Controller API versions do not match. SDK: %s Controller: %s",
drycc.APIVersion, c.ControllerAPIVersion)
// API mismatch isn't fatal, so after warning continue on.
return nil
}
return err
}