Skip to content

Commit

Permalink
feat(kumactl) traffic logging plurar form
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubdyszkiewicz committed Sep 18, 2019
1 parent 102b002 commit e70be1f
Show file tree
Hide file tree
Showing 15 changed files with 1,230 additions and 32 deletions.
2 changes: 1 addition & 1 deletion app/kumactl/cmd/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ func NewGetCmd(pctx *kumactl_cmd.RootContext) *cobra.Command {
cmd.AddCommand(newGetDataplanesCmd(ctx))
cmd.AddCommand(newGetProxyTemplatesCmd(ctx))
cmd.AddCommand(newGetTrafficPermissionsCmd(ctx))
cmd.AddCommand(newGetTrafficLoggingCmd(ctx))
cmd.AddCommand(newGetTrafficLoggingsCmd(ctx))
return cmd
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ import (
"github.com/spf13/cobra"
)

func newGetTrafficLoggingCmd(pctx *getContext) *cobra.Command {
func newGetTrafficLoggingsCmd(pctx *getContext) *cobra.Command {
cmd := &cobra.Command{
Use: "traffic-logging",
Short: "Show TrafficLogging",
Use: "traffic-loggings",
Short: "Show TrafficLoggings",
Long: `Show TrafficLogging entities.`,
RunE: func(cmd *cobra.Command, _ []string) error {
rs, err := pctx.CurrentResourceStore()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"github.com/spf13/cobra"
)

var _ = Describe("kumactl get traffic-logging", func() {
var _ = Describe("kumactl get traffic-loggings", func() {

trafficLoggingResources := []*mesh.TrafficLoggingResource{
{
Expand Down Expand Up @@ -129,12 +129,12 @@ var _ = Describe("kumactl get traffic-logging", func() {
matcher func(interface{}) gomega_types.GomegaMatcher
}

DescribeTable("kumactl get traffic-logging -o table|json|yaml",
DescribeTable("kumactl get traffic-loggings -o table|json|yaml",
func(given testCase) {
// given
rootCmd.SetArgs(append([]string{
"--config-file", filepath.Join("..", "testdata", "sample-kumactl.config.yaml"),
"get", "traffic-logging"}, given.outputFormat))
"get", "traffic-loggings"}, given.outputFormat))

// when
err := rootCmd.Execute()
Expand All @@ -150,26 +150,26 @@ var _ = Describe("kumactl get traffic-logging", func() {
},
Entry("should support Table output by default", testCase{
outputFormat: "",
goldenFile: "get-traffic-logging.golden.txt",
goldenFile: "get-traffic-loggings.golden.txt",
matcher: func(expected interface{}) gomega_types.GomegaMatcher {
return WithTransform(strings.TrimSpace, Equal(strings.TrimSpace(string(expected.([]byte)))))
},
}),
Entry("should support Table output explicitly", testCase{
outputFormat: "-otable",
goldenFile: "get-traffic-logging.golden.txt",
goldenFile: "get-traffic-loggings.golden.txt",
matcher: func(expected interface{}) gomega_types.GomegaMatcher {
return WithTransform(strings.TrimSpace, Equal(strings.TrimSpace(string(expected.([]byte)))))
},
}),
Entry("should support JSON output", testCase{
outputFormat: "-ojson",
goldenFile: "get-traffic-logging.golden.json",
goldenFile: "get-traffic-loggings.golden.json",
matcher: MatchJSON,
}),
Entry("should support YAML output", testCase{
outputFormat: "-oyaml",
goldenFile: "get-traffic-logging.golden.yaml",
goldenFile: "get-traffic-loggings.golden.yaml",
matcher: MatchYAML,
}),
)
Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions app/kumactl/data/install/k8s/control-plane/kuma-cp/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ rules:
- get
- list
- watch
- apiGroups:
- kuma.io
resources:
- trafficloggings
verbs:
- get
- list
- watch
# validate k8s token before issueing mTLS cert
- apiGroups:
- authentication.k8s.io
Expand Down
40 changes: 24 additions & 16 deletions app/kumactl/pkg/install/k8s/control-plane/templates_vfsdata.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/cmd/kumactl/HELP.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,7 @@ Available Commands:
dataplanes Show Dataplanes
meshes Show Meshes
proxytemplates Show ProxyTemplates
traffic-loggings Show TrafficLoggings
traffic-permissions Show TrafficPermissions
Flags:
Expand Down
2 changes: 2 additions & 0 deletions examples/minikube/kumactl_workflow.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ run kumactl get proxytemplates

run kumactl get traffic-permissions

run kumactl get traffic-loggings

run kumactl inspect dataplanes

run kumactl inspect dataplanes -otable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ import (
// TrafficLoggingSpec defines the desired state of TrafficLogging
type TrafficLoggingSpec = map[string]interface{}

// +kubebuilder:object:root=true

// TrafficLogging is the Schema for the trafficloggings API
type TrafficLogging struct {
metav1.TypeMeta `json:",inline"`
Expand All @@ -37,8 +35,6 @@ type TrafficLogging struct {
Spec TrafficLoggingSpec `json:"spec,omitempty"`
}

// +kubebuilder:object:root=true

// TrafficLoggingList contains a list of TrafficLogging
type TrafficLoggingList struct {
metav1.TypeMeta `json:",inline"`
Expand Down
1 change: 0 additions & 1 deletion pkg/plugins/resources/k8s/native/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ var (

func init() {

meshv1alpha1.AddToScheme(scheme)
_ = meshv1alpha1.AddToScheme(scheme)
// +kubebuilder:scaffold:scheme
}
Expand Down

0 comments on commit e70be1f

Please sign in to comment.