-
Notifications
You must be signed in to change notification settings - Fork 249
/
build_client.go
61 lines (50 loc) · 1.58 KB
/
build_client.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
52
53
54
55
56
57
58
59
60
61
package steps
import (
"context"
"io"
"k8s.io/client-go/rest"
buildapi "github.com/openshift/api/build/v1"
"github.com/openshift/client-go/build/clientset/versioned/scheme"
"github.com/openshift/ci-tools/pkg/steps/loggingclient"
)
type BuildClient interface {
loggingclient.LoggingClient
Logs(namespace, name string, options *buildapi.BuildLogOptions) (io.ReadCloser, error)
NodeArchitectures() []string
ManifestToolDockerCfg() string
LocalRegistryDNS() string
}
type buildClient struct {
loggingclient.LoggingClient
client rest.Interface
nodeArchitectures []string
manifestToolDockerCfg string
localRegistryDNS string
}
func NewBuildClient(client loggingclient.LoggingClient, restClient rest.Interface, nodeArchitectures []string, manifestToolDockerCfg, localRegistryDNS string) BuildClient {
return &buildClient{
LoggingClient: client,
client: restClient,
nodeArchitectures: nodeArchitectures,
manifestToolDockerCfg: manifestToolDockerCfg,
localRegistryDNS: localRegistryDNS,
}
}
func (c *buildClient) Logs(namespace, name string, options *buildapi.BuildLogOptions) (io.ReadCloser, error) {
return c.client.Get().
Namespace(namespace).
Name(name).
Resource("builds").
SubResource("log").
VersionedParams(options, scheme.ParameterCodec).
Stream(context.TODO())
}
func (c *buildClient) NodeArchitectures() []string {
return c.nodeArchitectures
}
func (c *buildClient) ManifestToolDockerCfg() string {
return c.manifestToolDockerCfg
}
func (c *buildClient) LocalRegistryDNS() string {
return c.localRegistryDNS
}