Skip to content

Commit 0192e76

Browse files
Merge pull request #20709 from mfojtik/build-10-gitserver
move git server to external build client
2 parents d107ca8 + 0fc50b6 commit 0192e76

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

pkg/gitserver/autobuild/autobuild.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ import (
1313
kclientcmd "k8s.io/client-go/tools/clientcmd"
1414
kapi "k8s.io/kubernetes/pkg/apis/core"
1515

16-
buildapi "github.com/openshift/origin/pkg/build/apis/build"
17-
buildclient "github.com/openshift/origin/pkg/build/generated/internalclientset"
18-
buildclientinternal "github.com/openshift/origin/pkg/build/generated/internalclientset/typed/build/internalversion"
16+
buildv1 "github.com/openshift/api/build/v1"
17+
buildv1client "github.com/openshift/client-go/build/clientset/versioned"
18+
buildv1clienttyped "github.com/openshift/client-go/build/clientset/versioned/typed/build/v1"
1919
"github.com/openshift/origin/pkg/gitserver"
2020

2121
s2igit "github.com/openshift/source-to-image/pkg/scm/git"
@@ -24,7 +24,7 @@ import (
2424
type AutoLinkBuilds struct {
2525
Namespaces []string
2626
Builders []kapi.ObjectReference
27-
Client buildclientinternal.BuildConfigsGetter
27+
Client buildv1clienttyped.BuildConfigsGetter
2828

2929
CurrentNamespace string
3030

@@ -46,7 +46,7 @@ func NewAutoLinkBuildsFromEnvironment() (*AutoLinkBuilds, error) {
4646
if err != nil {
4747
return nil, err
4848
}
49-
buildClient, err := buildclient.NewForConfig(clientConfig)
49+
buildClient, err := buildv1client.NewForConfig(clientConfig)
5050
if err != nil {
5151
return nil, err
5252
}
@@ -100,7 +100,7 @@ func clientFromConfig(path string) (*restclient.Config, string, error) {
100100
func (a *AutoLinkBuilds) Link() (map[string]gitserver.Clone, error) {
101101
log.Printf("Linking build configs in namespace(s) %v to the gitserver", a.Namespaces)
102102
errs := []error{}
103-
builders := []*buildapi.BuildConfig{}
103+
builders := []*buildv1.BuildConfig{}
104104
for _, namespace := range a.Namespaces {
105105
list, err := a.Client.BuildConfigs(namespace).List(metav1.ListOptions{})
106106
if err != nil {
@@ -200,7 +200,7 @@ func (a *AutoLinkBuilds) Link() (map[string]gitserver.Clone, error) {
200200
return clones, errors.NewAggregate(errs)
201201
}
202202

203-
func hasItem(items []*buildapi.BuildConfig, item kapi.ObjectReference) bool {
203+
func hasItem(items []*buildv1.BuildConfig, item kapi.ObjectReference) bool {
204204
for _, c := range items {
205205
if c.Namespace == item.Namespace && c.Name == item.Name {
206206
return true

pkg/gitserver/getbuildconfigs.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ import (
88
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
99
restclient "k8s.io/client-go/rest"
1010

11-
buildapi "github.com/openshift/origin/pkg/build/apis/build"
12-
buildclient "github.com/openshift/origin/pkg/build/generated/internalclientset"
11+
buildv1 "github.com/openshift/api/build/v1"
12+
buildv1client "github.com/openshift/client-go/build/clientset/versioned"
1313
)
1414

1515
const gitRepositoryAnnotationKey = "openshift.io/git-repository"
1616

17-
func GetRepositoryBuildConfigs(c buildclient.Interface, name string, out io.Writer) error {
17+
func GetRepositoryBuildConfigs(c buildv1client.Interface, name string, out io.Writer) error {
1818

1919
ns := os.Getenv("POD_NAMESPACE")
20-
buildConfigList, err := c.Build().BuildConfigs(ns).List(metav1.ListOptions{})
20+
buildConfigList, err := c.BuildV1().BuildConfigs(ns).List(metav1.ListOptions{})
2121
if err != nil {
2222
return err
2323
}
2424

25-
matchingBuildConfigs := []*buildapi.BuildConfig{}
25+
matchingBuildConfigs := []*buildv1.BuildConfig{}
2626

2727
for i := range buildConfigList.Items {
2828
bc := &buildConfigList.Items[i]
@@ -53,12 +53,12 @@ func GetRepositoryBuildConfigs(c buildclient.Interface, name string, out io.Writ
5353
}
5454

5555
// GetClient returns a build client.
56-
func GetClient() (buildclient.Interface, error) {
56+
func GetClient() (buildv1client.Interface, error) {
5757
clientConfig, err := restclient.InClusterConfig()
5858
if err != nil {
5959
return nil, fmt.Errorf("failed to get client config: %v", err)
6060
}
61-
buildClient, err := buildclient.NewForConfig(clientConfig)
61+
buildClient, err := buildv1client.NewForConfig(clientConfig)
6262
if err != nil {
6363
return nil, fmt.Errorf("error obtaining OpenShift client: %v", err)
6464
}

pkg/gitserver/getbuildconfigs_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import (
77

88
"k8s.io/apimachinery/pkg/runtime"
99

10-
buildapi "github.com/openshift/origin/pkg/build/apis/build"
11-
buildfake "github.com/openshift/origin/pkg/build/generated/internalclientset/fake"
10+
buildv1 "github.com/openshift/api/build/v1"
11+
buildfake "github.com/openshift/client-go/build/clientset/versioned/fake"
1212
)
1313

14-
func bc(name string, annotation string) *buildapi.BuildConfig {
15-
obj := &buildapi.BuildConfig{}
14+
func bc(name string, annotation string) *buildv1.BuildConfig {
15+
obj := &buildv1.BuildConfig{}
1616
obj.Name = name
1717
obj.Namespace = "test"
1818
obj.Annotations = map[string]string{}

0 commit comments

Comments
 (0)