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

fix(kumactl) warn version unknown #2438

Merged
merged 9 commits into from
Jul 27, 2021
Merged
5 changes: 2 additions & 3 deletions app/kumactl/cmd/apply/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
. "github.com/onsi/gomega"
"github.com/spf13/cobra"

kumactl_resources "github.com/kumahq/kuma/app/kumactl/pkg/resources"

"github.com/kumahq/kuma/pkg/core/resources/apis/system"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"

Expand All @@ -31,6 +29,7 @@ import (
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
"github.com/kumahq/kuma/pkg/test/resources/model"
test_store "github.com/kumahq/kuma/pkg/test/store"
"github.com/kumahq/kuma/pkg/util/test"
)

var _ = Describe("kumactl apply", func() {
Expand All @@ -44,7 +43,7 @@ var _ = Describe("kumactl apply", func() {
NewResourceStore: func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
return store, nil
},
NewAPIServerClient: kumactl_resources.NewAPIServerClient,
NewAPIServerClient: test.GetMockNewAPIServerClient(),
},
}
store = core_store.NewPaginationStore(memory_resources.NewStore())
Expand Down
5 changes: 3 additions & 2 deletions app/kumactl/cmd/completion/completion_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import (
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/pkg/util/test"

. "github.com/kumahq/kuma/pkg/test/matchers"
)

Expand All @@ -30,7 +31,7 @@ var _ = Describe("kumactl completion", func() {
DescribeTable("should generate completion code",
func(given testCase) {
// given
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
rootCmd.SetArgs(append([]string{"completion"}, given.extraArgs...))
rootCmd.SetOut(stdout)
rootCmd.SetErr(stderr)
Expand Down
12 changes: 5 additions & 7 deletions app/kumactl/cmd/config/config_control_planes_add_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ import (
"time"
"unicode"

"github.com/kumahq/kuma/pkg/version"

"github.com/kumahq/kuma/app/kumactl/pkg/config"
"github.com/kumahq/kuma/pkg/api-server/types"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/pkg/util/test"
"github.com/kumahq/kuma/pkg/version"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down Expand Up @@ -47,7 +45,7 @@ var _ = Describe("kumactl config control-planes add", func() {
var outbuf *bytes.Buffer

BeforeEach(func() {
rootCmd = cmd.DefaultRootCmd()
rootCmd = test.DefaultTestingRootCmd()

// Different versions of cobra might emit errors to stdout
// or stderr. It's too fragile to depend on precidely what
Expand All @@ -70,7 +68,7 @@ var _ = Describe("kumactl config control-planes add", func() {
// then
Expect(err.Error()).To(MatchRegexp(requiredFlagNotSet("name")))
// and
Expect(outbuf.String()).To(Equal(`Error: required flag(s) "address", "name" not set
Expect(outbuf.String()).To(ContainSubstring(`Error: required flag(s) "address", "name" not set
`))
})

Expand All @@ -84,7 +82,7 @@ var _ = Describe("kumactl config control-planes add", func() {
// then
Expect(err.Error()).To(MatchRegexp(requiredFlagNotSet("address")))
// and
Expect(outbuf.String()).To(Equal(`Error: required flag(s) "address" not set
Expect(outbuf.String()).To(ContainSubstring(`Error: required flag(s) "address" not set
`))
})

Expand Down
4 changes: 2 additions & 2 deletions app/kumactl/cmd/config/config_control_planes_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"path/filepath"
"strings"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/pkg/util/test"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -16,7 +16,7 @@ var _ = Describe("kumactl config control-planes list", func() {

It("should display Control Planes from a given configuration file", func() {
// setup
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
buf := &bytes.Buffer{}
rootCmd.SetOut(buf)

Expand Down
8 changes: 4 additions & 4 deletions app/kumactl/cmd/config/config_control_planes_remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"unicode"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/pkg/util/test"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down Expand Up @@ -36,7 +36,7 @@ var _ = Describe("kumactl config control-planes remove", func() {
var outbuf *bytes.Buffer

BeforeEach(func() {
rootCmd = cmd.DefaultRootCmd()
rootCmd = test.DefaultTestingRootCmd()

// Different versions of cobra might emit errors to stdout
// or stderr. It's too fragile to depend on precidely what
Expand All @@ -59,7 +59,7 @@ var _ = Describe("kumactl config control-planes remove", func() {
// then
Expect(err.Error()).To(MatchRegexp(requiredFlagNotSet("name")))
// and
Expect(outbuf.String()).To(Equal(`Error: required flag(s) "name" not set
Expect(outbuf.String()).To(ContainSubstring(`Error: required flag(s) "name" not set
`))
})

Expand All @@ -73,7 +73,7 @@ var _ = Describe("kumactl config control-planes remove", func() {
// then
Expect(err).To(MatchError(`there is no Control Plane with name "example"`))
// and
Expect(outbuf.String()).To(Equal(`Error: there is no Control Plane with name "example"
Expect(outbuf.String()).To(ContainSubstring(`Error: there is no Control Plane with name "example"
`))
})
})
Expand Down
4 changes: 2 additions & 2 deletions app/kumactl/cmd/config/config_control_planes_switch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"unicode"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/pkg/util/test"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
Expand Down Expand Up @@ -36,7 +36,7 @@ var _ = Describe("kumactl config control-planes use", func() {
var outbuf *bytes.Buffer

BeforeEach(func() {
rootCmd = cmd.DefaultRootCmd()
rootCmd = test.DefaultTestingRootCmd()

// Different versions of cobra might emit errors to stdout
// or stderr. It's too fragile to depend on precidely what
Expand Down
4 changes: 2 additions & 2 deletions app/kumactl/cmd/config/config_view_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"io/ioutil"
"path/filepath"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/pkg/util/test"

. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
Expand All @@ -15,7 +15,7 @@ var _ = Describe("kumactl config view", func() {

It("should display configuration from a given file", func() {
// setup
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
buf := &bytes.Buffer{}
rootCmd.SetOut(buf)

Expand Down
2 changes: 2 additions & 0 deletions app/kumactl/cmd/delete/delete_meshes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
test_model "github.com/kumahq/kuma/pkg/test/resources/model"
"github.com/kumahq/kuma/pkg/util/test"
)

var _ = Describe("kumactl delete mesh", func() {
Expand Down Expand Up @@ -46,6 +47,7 @@ var _ = Describe("kumactl delete mesh", func() {
BeforeEach(func() {
// setup
rootCtx = kumactl_cmd.DefaultRootContext()
rootCtx.Runtime.NewAPIServerClient = test.GetMockNewAPIServerClient()
rootCtx.Runtime.NewResourceStore = func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
return store, nil
}
Expand Down
2 changes: 2 additions & 0 deletions app/kumactl/cmd/delete/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"
"github.com/kumahq/kuma/pkg/util/test"
)

var _ = Describe("kumactl delete ", func() {
Expand All @@ -32,6 +33,7 @@ var _ = Describe("kumactl delete ", func() {
BeforeEach(func() {
// setup
rootCtx = kumactl_cmd.DefaultRootContext()
rootCtx.Runtime.NewAPIServerClient = test.GetMockNewAPIServerClient()
rootCtx.Runtime.NewResourceStore = func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
return store, nil
}
Expand Down
10 changes: 5 additions & 5 deletions app/kumactl/cmd/generate/generate_certificate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"

"github.com/kumahq/kuma/app/kumactl/cmd"
"github.com/kumahq/kuma/app/kumactl/cmd/generate"
"github.com/kumahq/kuma/pkg/tls"
"github.com/kumahq/kuma/pkg/util/test"
)

var _ = Describe("kumactl generate tls-certificate", func() {
Expand Down Expand Up @@ -57,7 +57,7 @@ var _ = Describe("kumactl generate tls-certificate", func() {

It("should generate client certificate", func() {
// given
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
rootCmd.SetArgs([]string{"generate", "tls-certificate",
"--key-file", keyFile.Name(),
"--cert-file", certFile.Name(),
Expand Down Expand Up @@ -91,7 +91,7 @@ Cert was saved in: %s

It("should not allow to specify control plane hostname", func() {
// given
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
rootCmd.SetArgs([]string{"generate", "tls-certificate",
"--key-file", keyFile.Name(),
"--cert-file", certFile.Name(),
Expand Down Expand Up @@ -125,7 +125,7 @@ Cert was saved in: %s

It("should generate server certificate", func() {
// given
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
rootCmd.SetArgs([]string{"generate", "tls-certificate",
"--key-file", keyFile.Name(),
"--cert-file", certFile.Name(),
Expand Down Expand Up @@ -161,7 +161,7 @@ Cert was saved in: %s

It("should validate that cp-hostname is present", func() {
// given
rootCmd := cmd.DefaultRootCmd()
rootCmd := test.DefaultTestingRootCmd()
rootCmd.SetArgs([]string{"generate", "tls-certificate",
"--key-file", keyFile.Name(),
"--cert-file", certFile.Name(),
Expand Down
5 changes: 2 additions & 3 deletions app/kumactl/cmd/generate/generate_dataplane_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ import (
. "github.com/onsi/gomega"
"github.com/spf13/cobra"

kumactl_resources "github.com/kumahq/kuma/app/kumactl/pkg/resources"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
"github.com/kumahq/kuma/app/kumactl/pkg/tokens"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
"github.com/kumahq/kuma/pkg/util/test"
)

type staticDataplaneTokenGenerator struct {
Expand Down Expand Up @@ -45,7 +44,7 @@ var _ = Describe("kumactl generate dataplane-token", func() {
NewDataplaneTokenClient: func(*config_proto.ControlPlaneCoordinates_ApiServer) (tokens.DataplaneTokenClient, error) {
return generator, nil
},
NewAPIServerClient: kumactl_resources.NewAPIServerClient,
NewAPIServerClient: test.GetMockNewAPIServerClient(),
},
}

Expand Down
5 changes: 2 additions & 3 deletions app/kumactl/cmd/generate/generate_zoneingress_token_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ import (
. "github.com/onsi/gomega"
"github.com/spf13/cobra"

kumactl_resources "github.com/kumahq/kuma/app/kumactl/pkg/resources"

"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
"github.com/kumahq/kuma/app/kumactl/pkg/tokens"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
"github.com/kumahq/kuma/pkg/util/test"
)

type staticZoneIngressTokenGenerator struct {
Expand Down Expand Up @@ -45,7 +44,7 @@ var _ = Describe("kumactl generate zone-ingress-token", func() {
NewZoneIngressTokenClient: func(*config_proto.ControlPlaneCoordinates_ApiServer) (tokens.ZoneIngressTokenClient, error) {
return generator, nil
},
NewAPIServerClient: kumactl_resources.NewAPIServerClient,
NewAPIServerClient: test.GetMockNewAPIServerClient(),
},
}

Expand Down
6 changes: 3 additions & 3 deletions app/kumactl/cmd/get/get_circuit_breakers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"strings"
"time"

"github.com/kumahq/kuma/pkg/util/test"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand All @@ -16,8 +18,6 @@ import (
"google.golang.org/protobuf/types/known/durationpb"
"google.golang.org/protobuf/types/known/wrapperspb"

kumactl_resources "github.com/kumahq/kuma/app/kumactl/pkg/resources"

kuma_mesh "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
Expand Down Expand Up @@ -129,7 +129,7 @@ var _ = Describe("kumactl get circuit-breakers", func() {
NewResourceStore: func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
return store, nil
},
NewAPIServerClient: kumactl_resources.NewAPIServerClient,
NewAPIServerClient: test.GetMockNewAPIServerClient(),
},
}

Expand Down
8 changes: 3 additions & 5 deletions app/kumactl/cmd/get/get_dataplanes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ import (
"strings"
"time"

"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_resources "github.com/kumahq/kuma/app/kumactl/pkg/resources"

. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/extensions/table"
. "github.com/onsi/gomega"
Expand All @@ -19,14 +16,15 @@ import (
"github.com/spf13/cobra"

mesh_proto "github.com/kumahq/kuma/api/mesh/v1alpha1"
"github.com/kumahq/kuma/app/kumactl/cmd"
kumactl_cmd "github.com/kumahq/kuma/app/kumactl/pkg/cmd"
config_proto "github.com/kumahq/kuma/pkg/config/app/kumactl/v1alpha1"
mesh_core "github.com/kumahq/kuma/pkg/core/resources/apis/mesh"
core_model "github.com/kumahq/kuma/pkg/core/resources/model"
core_store "github.com/kumahq/kuma/pkg/core/resources/store"
memory_resources "github.com/kumahq/kuma/pkg/plugins/resources/memory"

test_model "github.com/kumahq/kuma/pkg/test/resources/model"
"github.com/kumahq/kuma/pkg/util/test"
)

var _ = Describe("kumactl get dataplanes", func() {
Expand Down Expand Up @@ -104,7 +102,7 @@ var _ = Describe("kumactl get dataplanes", func() {
NewResourceStore: func(*config_proto.ControlPlaneCoordinates_ApiServer) (core_store.ResourceStore, error) {
return store, nil
},
NewAPIServerClient: kumactl_resources.NewAPIServerClient,
NewAPIServerClient: test.GetMockNewAPIServerClient(),
},
}

Expand Down
Loading