Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update k8s dependencies to v0.20.7 #1344

Merged
merged 7 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 11 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ require (
github.com/gregjones/httpcache v0.0.0-20190212212710-3befbb6ad0cc // indirect
github.com/mitchellh/go-homedir v1.1.0
github.com/mitchellh/mapstructure v1.3.1 // indirect
github.com/pelletier/go-toml v1.8.0 // indirect
github.com/smartystreets/assertions v1.0.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/cobra v1.1.3
Expand All @@ -17,16 +16,17 @@ require (
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
gopkg.in/ini.v1 v1.56.0 // indirect
gotest.tools/v3 v3.0.3
k8s.io/api v0.19.7
k8s.io/apimachinery v0.19.7
k8s.io/cli-runtime v0.19.7
k8s.io/client-go v0.19.7
k8s.io/code-generator v0.19.7
knative.dev/eventing v0.23.1-0.20210603165844-0ca9a9c8c1f2
knative.dev/hack v0.0.0-20210601210329-de04b70e00d0
knative.dev/networking v0.0.0-20210603073844-5521a8b92648
knative.dev/pkg v0.0.0-20210602095030-0e61d6763dd6
knative.dev/serving v0.23.1-0.20210603181344-68a1b38b50b0
k8s.io/api v0.20.7
k8s.io/apiextensions-apiserver v0.20.7
k8s.io/apimachinery v0.20.7
k8s.io/cli-runtime v0.20.7
k8s.io/client-go v0.20.7
k8s.io/code-generator v0.20.7
knative.dev/eventing v0.23.1-0.20210614135520-b0b32c47d7d3
knative.dev/hack v0.0.0-20210614141220-66ab1a098940
knative.dev/networking v0.0.0-20210614195820-29c1fb2f824d
knative.dev/pkg v0.0.0-20210614053220-ed09cd052101
knative.dev/serving v0.23.1-0.20210614141420-380a090c2039
sigs.k8s.io/yaml v1.2.0
)

Expand Down
507 changes: 438 additions & 69 deletions go.sum

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions hack/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ run() {


codegen() {
#TODO: Workaround to update go-licenses until prow-tests image is updated
local temp_dir="$(mktemp -d)"
pushd "${temp_dir}" > /dev/null 2>&1
GO111MODULE=on go get github.com/google/go-licenses@latest || return 1
popd > /dev/null 2>&1
# Update dependencies
update_deps

Expand Down
2 changes: 1 addition & 1 deletion hack/update-k8s-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ set -o nounset
set -o pipefail

export GO111MODULE=on
export K8S_VERSION="${1:-v0.18.12}"
export K8S_VERSION="${1:-v0.20.7}"

K8S_DEPS=(
"k8s.io/api"
Expand Down
45 changes: 27 additions & 18 deletions pkg/dynamic/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,20 @@ import (
"testing"

"gotest.tools/v3/assert"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"

eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
"knative.dev/eventing/pkg/apis/messaging"
messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1"
sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1"
sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2"
dynamicclientfake "knative.dev/pkg/injection/clients/dynamicclient/fake"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"

"knative.dev/client/pkg/util"
Expand Down Expand Up @@ -108,7 +113,7 @@ func TestListSources(t *testing.T) {

t.Run("source list empty", func(t *testing.T) {
client := createFakeKnDynamicClient(testNamespace,
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
)
sources, err := client.ListSources(context.Background())
assert.NilError(t, err)
Expand All @@ -117,11 +122,10 @@ func TestListSources(t *testing.T) {

t.Run("source list non empty", func(t *testing.T) {
client := createFakeKnDynamicClient(testNamespace,
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1alpha1", "ApiServerSource"),
newSourceUnstructuredObj("c1", "sources.knative.dev/v1alpha1", "CronJobSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1beta2", "PingSource"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1", "ApiServerSource"),
)
sources, err := client.ListSources(context.Background(), WithTypeFilter("pingsource"), WithTypeFilter("ApiServerSource"))
assert.NilError(t, err)
Expand All @@ -141,14 +145,16 @@ func TestListSourcesUsingGVKs(t *testing.T) {

t.Run("source list with given GVKs", func(t *testing.T) {
client := createFakeKnDynamicClient(testNamespace,
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1alpha1", "ApiServerSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1beta2", "PingSource"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1", "ApiServerSource"),
)
assert.Check(t, client.RawClient() != nil)
gv := schema.GroupVersion{Group: "sources.knative.dev", Version: "v1alpha1"}
gvks := []schema.GroupVersionKind{gv.WithKind("ApiServerSource"), gv.WithKind("PingSource")}
gvks := []schema.GroupVersionKind{
{Group: "sources.knative.dev", Version: "v1beta2", Kind: "PingSource"},
{Group: "sources.knative.dev", Version: "v1", Kind: "ApiServerSource"},
}

s, err := client.ListSourcesUsingGVKs(context.Background(), &gvks)
assert.NilError(t, err)
Expand All @@ -174,11 +180,14 @@ func TestListSourcesUsingGVKs(t *testing.T) {
// See also the one in the fake package. Duplicated here to avoid a dependency loop.
func createFakeKnDynamicClient(testNamespace string, objects ...runtime.Object) KnDynamicClient {
scheme := runtime.NewScheme()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could technically drop the need for the gvrToListKind if you add the correct types to the scheme

ie. for k8s types invoke scheme.AddToScheme(scheme) from https://github.com/kubernetes/client-go/blob/1bccfc8c60977e2ce3235394daff128996818f7b/kubernetes/scheme/register.go#L135

You can do this with eventing and serving and save yourself from maintaining this list. Unsure if there's something that prevents you from importing those.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had some issues where I couldn't provide unstructured types to the fake dynamic client. There would be an error with the way the fake client interacts with its object tracker

So I wrote some code for the fake injection client to rewire these schemes to use unstructured.* types
https://github.com/knative/pkg/pull/2145/files#diff-8438a08a79f266761b674dbf8748084e62be792ce56e7d7b598d148c069946e5L40

Unsure if you would need to do the same - if so maybe we pull that bit of logic out out injection and into some sort of fakedynamic package in knative.dev/pkg

scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1alpha1", Kind: "Service"}, &servingv1.Service{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1", Kind: "Broker"}, &eventingv1.Broker{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1", Kind: "Channel"}, &messagingv1.Channel{})
client := dynamicfake.NewSimpleDynamicClient(scheme, objects...)
return NewKnDynamicClient(client, testNamespace)
servingv1.AddToScheme(scheme)
eventingv1.AddToScheme(scheme)
messagingv1.AddToScheme(scheme)
sourcesv1.AddToScheme(scheme)
sourcesv1beta2.AddToScheme(scheme)
apiextensionsv1.AddToScheme(scheme)
_, dynamicClient := dynamicclientfake.With(context.TODO(), scheme, objects...)
return NewKnDynamicClient(dynamicClient, testNamespace)
}

func newSourceCRDObj(name string) *unstructured.Unstructured {
Expand Down
26 changes: 15 additions & 11 deletions pkg/dynamic/fake/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,30 @@
package fake

import (
v1 "k8s.io/api/core/v1"
"context"

apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
dynamicfake "k8s.io/client-go/dynamic/fake"

"knative.dev/client/pkg/dynamic"

eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
messagingv1 "knative.dev/eventing/pkg/apis/messaging/v1"
sourcesv1 "knative.dev/eventing/pkg/apis/sources/v1"
sourcesv1beta2 "knative.dev/eventing/pkg/apis/sources/v1beta2"
dynamicclientfake "knative.dev/pkg/injection/clients/dynamicclient/fake"
servingv1 "knative.dev/serving/pkg/apis/serving/v1"
)

// CreateFakeKnDynamicClient gives you a dynamic client for testing containing the given objects.
func CreateFakeKnDynamicClient(testNamespace string, objects ...runtime.Object) dynamic.KnDynamicClient {
scheme := runtime.NewScheme()
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "", Version: "v1", Kind: "Service"}, &v1.Service{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1", Kind: "Service"}, &servingv1.Service{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "serving.knative.dev", Version: "v1", Kind: "Route"}, &servingv1.Route{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1", Kind: "Broker"}, &eventingv1.Broker{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "eventing.knative.dev", Version: "v1", Kind: "Subscription"}, &messagingv1.Subscription{})
scheme.AddKnownTypeWithName(schema.GroupVersionKind{Group: "messaging.knative.dev", Version: "v1", Kind: "Channel"}, &messagingv1.Channel{})
client := dynamicfake.NewSimpleDynamicClient(scheme, objects...)
return dynamic.NewKnDynamicClient(client, testNamespace)
servingv1.AddToScheme(scheme)
eventingv1.AddToScheme(scheme)
messagingv1.AddToScheme(scheme)
sourcesv1.AddToScheme(scheme)
sourcesv1beta2.AddToScheme(scheme)
apiextensionsv1.AddToScheme(scheme)
_, dynamicClient := dynamicclientfake.With(context.TODO(), scheme, objects...)
Copy link
Contributor Author

@dsimansk dsimansk Jun 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dprotaso @navidshaikh wdyt about the above change? It works for our test setup, I've gone through and changed various initialization of fake dynamic client to use the common function.

Indeed I had to use knative/pkg for unstructured object to get them converted properly.

Finally, Navid do you see any problem in bringing apiextensions-apiserver dependency for the scheme?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looks good - I might PR a change to k8s to fix this problem but it'll take weeks/months for us to switch over to it

return dynamic.NewKnDynamicClient(dynamicClient, testNamespace)
}
5 changes: 1 addition & 4 deletions pkg/kn/commands/channel/list_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,8 @@ import (
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"

dynamicfake "k8s.io/client-go/dynamic/fake"
dynamicfakeClient "knative.dev/client/pkg/dynamic/fake"

"knative.dev/client/pkg/dynamic"
clientdynamic "knative.dev/client/pkg/dynamic"
"knative.dev/client/pkg/kn/commands"
"knative.dev/client/pkg/util"
Expand Down Expand Up @@ -112,8 +110,7 @@ func TestChannelListTypesNoHeaders(t *testing.T) {
}

func TestListBuiltInChannelTypes(t *testing.T) {
fakeDynamic := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
channel, err := listBuiltInChannelTypes(context.Background(), dynamic.NewKnDynamicClient(fakeDynamic, "current"))
channel, err := listBuiltInChannelTypes(context.Background(), dynamicfakeClient.CreateFakeKnDynamicClient("current"))
assert.NilError(t, err)
if channel == nil {
t.Fatal("channel = nil, want not nil")
Expand Down
43 changes: 21 additions & 22 deletions pkg/kn/commands/source/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ import (
"strings"
"testing"

"knative.dev/client/pkg/dynamic/fake"

"gotest.tools/v3/assert"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"

dynamicfake "k8s.io/client-go/dynamic/fake"
clientdynamic "knative.dev/client/pkg/dynamic"
"knative.dev/client/pkg/kn/commands"
"knative.dev/client/pkg/util"
)
Expand Down Expand Up @@ -73,8 +73,8 @@ func TestSourceListTypesNoSourcesWithJsonOutput(t *testing.T) {

func TestSourceListTypes(t *testing.T) {
output, err := sourceFakeCmd([]string{"source", "list-types"},
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1", "ApiServerSource"),
)
assert.NilError(t, err)
assert.Check(t, util.ContainsAll(output[0], "TYPE", "S", "NAME", "DESCRIPTION"))
Expand All @@ -84,16 +84,15 @@ func TestSourceListTypes(t *testing.T) {

func TestSourceListTypesNoHeaders(t *testing.T) {
output, err := sourceFakeCmd([]string{"source", "list-types", "--no-headers"},
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1", "PingSource"),
)
assert.NilError(t, err)
assert.Check(t, util.ContainsNone(output[0], "TYPE", "NAME", "DESCRIPTION"))
assert.Check(t, util.ContainsAll(output[0], "PingSource"))
}

func TestListBuiltInSourceTypes(t *testing.T) {
fakeDynamic := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme())
sources, err := listBuiltInSourceTypes(context.Background(), clientdynamic.NewKnDynamicClient(fakeDynamic, "current"))
sources, err := listBuiltInSourceTypes(context.Background(), fake.CreateFakeKnDynamicClient("current"))
assert.NilError(t, err)
if sources == nil {
t.Fatal("sources = nil, want not nil")
Expand All @@ -109,7 +108,7 @@ func TestSourceListNoSourcesInstalled(t *testing.T) {

func TestSourceListEmpty(t *testing.T) {
output, err := sourceFakeCmd([]string{"source", "list", "-o", "json"},
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
)
assert.NilError(t, err)
outputJson := strings.Join(output[:], "\n")
Expand All @@ -118,12 +117,12 @@ func TestSourceListEmpty(t *testing.T) {

func TestSourceList(t *testing.T) {
output, err := sourceFakeCmd([]string{"source", "list"},
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("sinkbindings", "sources.knative.dev", "v1alpha1", "SinkBinding"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"),
newSourceUnstructuredObj("s1", "sources.knative.dev/v1alpha1", "SinkBinding"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1alpha1", "ApiServerSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
newSourceCRDObjWithSpec("sinkbindings", "sources.knative.dev", "v1", "SinkBinding"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1beta2", "PingSource"),
newSourceUnstructuredObj("s1", "sources.knative.dev/v1", "SinkBinding"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1", "ApiServerSource"),
)
assert.NilError(t, err)
assert.Check(t, util.ContainsAll(output[0], "NAME", "TYPE", "RESOURCE", "SINK", "READY"))
Expand All @@ -146,8 +145,8 @@ func TestSourceListUntyped(t *testing.T) {

func TestSourceListNoHeaders(t *testing.T) {
output, err := sourceFakeCmd([]string{"source", "list", "--no-headers"},
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1beta2", "PingSource"),
)
assert.NilError(t, err)
assert.Check(t, util.ContainsNone(output[0], "NAME", "TYPE", "RESOURCE", "SINK", "READY"))
Expand Down Expand Up @@ -208,12 +207,12 @@ func newSourceUnstructuredObj(name, apiVersion, kind string) *unstructured.Unstr

func TestSourceListAllNamespace(t *testing.T) {
output, err := sourceFakeCmd([]string{"source", "list", "--all-namespaces"},
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1alpha1", "PingSource"),
newSourceCRDObjWithSpec("sinkbindings", "sources.knative.dev", "v1alpha1", "SinkBinding"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1alpha1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1alpha1", "PingSource"),
newSourceUnstructuredObj("s1", "sources.knative.dev/v1alpha1", "SinkBinding"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1alpha1", "ApiServerSource"),
newSourceCRDObjWithSpec("pingsources", "sources.knative.dev", "v1beta2", "PingSource"),
newSourceCRDObjWithSpec("sinkbindings", "sources.knative.dev", "v1", "SinkBinding"),
newSourceCRDObjWithSpec("apiserversources", "sources.knative.dev", "v1", "ApiServerSource"),
newSourceUnstructuredObj("p1", "sources.knative.dev/v1beta2", "PingSource"),
newSourceUnstructuredObj("s1", "sources.knative.dev/v1", "SinkBinding"),
newSourceUnstructuredObj("a1", "sources.knative.dev/v1", "ApiServerSource"),
)
assert.NilError(t, err)
assert.Check(t, util.ContainsAll(output[0], "NAMESPACE", "NAME", "TYPE", "RESOURCE", "SINK", "READY"))
Expand Down
11 changes: 6 additions & 5 deletions pkg/kn/commands/testing_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package commands
import (
"bytes"

"knative.dev/client/pkg/dynamic/fake"

"github.com/spf13/cobra"
"k8s.io/apimachinery/pkg/runtime"
clienttesting "k8s.io/client-go/testing"
Expand All @@ -26,7 +28,6 @@ import (
clientservingv1 "knative.dev/client/pkg/serving/v1"
v1 "knative.dev/client/pkg/sources/v1"

dynamicfake "k8s.io/client-go/dynamic/fake"
sourcesv1fake "knative.dev/eventing/pkg/client/clientset/versioned/typed/sources/v1/fake"

clientdynamic "knative.dev/client/pkg/dynamic"
Expand Down Expand Up @@ -67,17 +68,17 @@ func CreateSourcesTestKnCommand(cmd *cobra.Command, knParams *KnParams) (*cobra.
}

// CreateDynamicTestKnCommand helper for creating test commands using dynamic client
func CreateDynamicTestKnCommand(cmd *cobra.Command, knParams *KnParams, objects ...runtime.Object) (*cobra.Command, *dynamicfake.FakeDynamicClient, *bytes.Buffer) {
func CreateDynamicTestKnCommand(cmd *cobra.Command, knParams *KnParams, objects ...runtime.Object) (*cobra.Command, *clientdynamic.KnDynamicClient, *bytes.Buffer) {
buf := new(bytes.Buffer)
fakeDynamic := dynamicfake.NewSimpleDynamicClient(runtime.NewScheme(), objects...)
fakeDynamic := fake.CreateFakeKnDynamicClient(FakeNamespace, objects...)
knParams.Output = buf
knParams.NewDynamicClient = func(namespace string) (clientdynamic.KnDynamicClient, error) {
return clientdynamic.NewKnDynamicClient(fakeDynamic, FakeNamespace), nil
return fakeDynamic, nil
}

knParams.fixedCurrentNamespace = FakeNamespace
knCommand := NewTestCommand(cmd, knParams)
return knCommand, fakeDynamic, buf
return knCommand, &fakeDynamic, buf

}

Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2015 Dmitri Shuralyov
Copyright (c) 2019 Josh Bleecher Snyder

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
Loading