Skip to content
This repository has been archived by the owner on Sep 12, 2023. It is now read-only.

Commit

Permalink
feat: Remove k8s.io/kubernetes from go mod (#111)
Browse files Browse the repository at this point in the history
* feat: Remove k8s.io/kubernetes from go mod

Signed-off-by: cegao <[email protected]>

* fix: Fix import order

Signed-off-by: cegao <[email protected]>
  • Loading branch information
gaocegege authored Feb 1, 2021
1 parent fe6f909 commit 3fbe0ce
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 18 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ require (
k8s.io/client-go v0.16.9
k8s.io/code-generator v0.16.9
k8s.io/kube-openapi v0.0.0-20190816220812-743ec37842bf
k8s.io/kubernetes v1.16.9
volcano.sh/volcano v0.4.0
)

Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,7 @@ k8s.io/kube-proxy v0.16.9/go.mod h1:UOKCVRn6vgVgjUhV0v/vFdxcv07aIeKH0JyZM9Tli6w=
k8s.io/kube-scheduler v0.16.9/go.mod h1:mDruQFpyAyhsCC0/vZBqGjwp0oyGhSPzkejf9aFH46Q=
k8s.io/kubectl v0.16.9/go.mod h1:FZ8ibvEMKjHC1yfi+vr8eBVX3VpoVOkrcdVJz5e6T3o=
k8s.io/kubelet v0.16.9/go.mod h1:KVj02L3uHVoEDC7buGK7WA/S8b42G8OFbvaYROws+0U=
k8s.io/kubernetes v1.16.2 h1:k0f/OVp6Yfv+UMTm6VYKhqjRgcvHh4QhN9coanjrito=
k8s.io/kubernetes v1.16.2/go.mod h1:SmhGgKfQ30imqjFVj8AI+iW+zSyFsswNErKYeTfgoH0=
k8s.io/kubernetes v1.16.9 h1:6x0VA8SChStHc3UmiFcXolDgoYLfiOpQ8KryhJZA6bk=
k8s.io/kubernetes v1.16.9/go.mod h1:bpUsy1qP0W6EtkxrPluP02p2+wyVN+95lkjPKnLQZtc=
Expand Down
6 changes: 3 additions & 3 deletions pkg/controller.v1/common/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@ import (
"strconv"
"strings"

"github.com/kubeflow/common/pkg/controller.v1/control"
"github.com/kubeflow/common/pkg/controller.v1/expectation"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
log "github.com/sirupsen/logrus"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/controller"

apiv1 "github.com/kubeflow/common/pkg/apis/common/v1"
commonutil "github.com/kubeflow/common/pkg/util"
Expand Down Expand Up @@ -249,7 +249,7 @@ func (jc *JobController) GetPodsForJob(jobObject interface{}) ([]*v1.Pod, error)
}
return fresh, nil
})
cm := controller.NewPodControllerRefManager(jc.PodControl, job, selector, jc.Controller.GetAPIGroupVersionKind(), canAdoptFunc)
cm := control.NewPodControllerRefManager(jc.PodControl, job, selector, jc.Controller.GetAPIGroupVersionKind(), canAdoptFunc)
return cm.ClaimPods(pods)
}

Expand Down
14 changes: 9 additions & 5 deletions pkg/controller.v1/control/pod_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ package control

import (
"encoding/json"
testutilv1 "github.com/kubeflow/common/test_job/test_util/v1"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
clientset "k8s.io/client-go/kubernetes"
clientscheme "k8s.io/client-go/kubernetes/scheme"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
utiltesting "k8s.io/client-go/util/testing"
"k8s.io/kubernetes/pkg/api/testapi"

testutilv1 "github.com/kubeflow/common/test_job/test_util/v1"
)

func TestCreatePods(t *testing.T) {
ns := metav1.NamespaceDefault
body := runtime.EncodeOrDie(testapi.Default.Codec(), &v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "empty_pod"}})
body := runtime.EncodeOrDie(
clientscheme.Codecs.LegacyCodec(v1.SchemeGroupVersion),
&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "empty_pod"}})
fakeHandler := utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: body,
Expand Down Expand Up @@ -67,7 +70,8 @@ func TestCreatePods(t *testing.T) {
},
Spec: podTemplate.Spec,
}
fakeHandler.ValidateRequest(t, testapi.Default.ResourcePath("pods", metav1.NamespaceDefault, ""), "POST", nil)
fakeHandler.ValidateRequest(t,
"/api/v1/namespaces/default/pods", "POST", nil)
var actualPod = &v1.Pod{}
err = json.Unmarshal([]byte(fakeHandler.RequestBody), actualPod)
assert.NoError(t, err, "unexpected error: %v", err)
Expand Down
21 changes: 14 additions & 7 deletions pkg/controller.v1/control/service_control_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ package control

import (
"encoding/json"
testutilv1 "github.com/kubeflow/common/test_job/test_util/v1"
"net/http/httptest"
"testing"

"github.com/stretchr/testify/assert"
"k8s.io/api/core/v1"
v1 "k8s.io/api/core/v1"
apiequality "k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
clientset "k8s.io/client-go/kubernetes"
clientscheme "k8s.io/client-go/kubernetes/scheme"
restclient "k8s.io/client-go/rest"
"k8s.io/client-go/tools/record"
utiltesting "k8s.io/client-go/util/testing"
"k8s.io/kubernetes/pkg/api/testapi"

testutilv1 "github.com/kubeflow/common/test_job/test_util/v1"
)

func TestCreateService(t *testing.T) {
ns := metav1.NamespaceDefault
body := runtime.EncodeOrDie(testapi.Default.Codec(), &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "empty_service"}})
body := runtime.EncodeOrDie(
clientscheme.Codecs.LegacyCodec(v1.SchemeGroupVersion),
&v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "empty_service"}})
fakeHandler := utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: body,
Expand Down Expand Up @@ -70,7 +73,8 @@ func TestCreateService(t *testing.T) {
Namespace: ns,
},
}
fakeHandler.ValidateRequest(t, testapi.Default.ResourcePath("services", metav1.NamespaceDefault, ""), "POST", nil)
fakeHandler.ValidateRequest(t,
"/api/v1/namespaces/default/services", "POST", nil)
var actualService = &v1.Service{}
err = json.Unmarshal([]byte(fakeHandler.RequestBody), actualService)
assert.NoError(t, err, "unexpected error: %v", err)
Expand All @@ -80,7 +84,9 @@ func TestCreateService(t *testing.T) {

func TestCreateServicesWithControllerRef(t *testing.T) {
ns := metav1.NamespaceDefault
body := runtime.EncodeOrDie(testapi.Default.Codec(), &v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "empty_service"}})
body := runtime.EncodeOrDie(
clientscheme.Codecs.LegacyCodec(v1.SchemeGroupVersion),
&v1.Service{ObjectMeta: metav1.ObjectMeta{Name: "empty_service"}})
fakeHandler := utiltesting.FakeHandler{
StatusCode: 200,
ResponseBody: body,
Expand Down Expand Up @@ -119,7 +125,8 @@ func TestCreateServicesWithControllerRef(t *testing.T) {
OwnerReferences: []metav1.OwnerReference{*ownerRef},
},
}
fakeHandler.ValidateRequest(t, testapi.Default.ResourcePath("services", metav1.NamespaceDefault, ""), "POST", nil)
fakeHandler.ValidateRequest(t,
"/api/v1/namespaces/default/services", "POST", nil)
var actualService = &v1.Service{}
err = json.Unmarshal([]byte(fakeHandler.RequestBody), actualService)
assert.NoError(t, err, "unexpected error: %v", err)
Expand Down
2 changes: 0 additions & 2 deletions pkg/controller.v1/expectation/expectation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
"k8s.io/apimachinery/pkg/util/clock"
"k8s.io/apimachinery/pkg/util/uuid"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/securitycontext"
)

var (
Expand Down Expand Up @@ -56,7 +55,6 @@ func newReplicationController(replicas int) *v1.ReplicationController {
Image: "foo/bar",
TerminationMessagePath: v1.TerminationMessagePathDefault,
ImagePullPolicy: v1.PullIfNotPresent,
SecurityContext: securitycontext.ValidSecurityContextWithContainerDefaults(),
},
},
RestartPolicy: v1.RestartPolicyAlways,
Expand Down

0 comments on commit 3fbe0ce

Please sign in to comment.