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): add --mesh parameter to inspect <policy> (backport of #7696) #7705

Closed
wants to merge 1 commit into from
Closed
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions app/kumactl/cmd/completion/testdata/bash.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3510,6 +3510,9 @@ _kumactl_inspect_circuit-breaker()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3612,6 +3615,9 @@ _kumactl_inspect_fault-injection()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3642,6 +3648,9 @@ _kumactl_inspect_healthcheck()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3672,6 +3681,9 @@ _kumactl_inspect_meshaccesslog()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3702,6 +3714,9 @@ _kumactl_inspect_meshcircuitbreaker()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3762,6 +3777,9 @@ _kumactl_inspect_meshfaultinjection()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3822,6 +3840,9 @@ _kumactl_inspect_meshhealthcheck()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3852,6 +3873,44 @@ _kumactl_inspect_meshhttproute()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
two_word_flags+=("--config-file")
flags+=("--log-level=")
two_word_flags+=("--log-level")
flags+=("--no-config")
flags+=("--output=")
two_word_flags+=("--output")
two_word_flags+=("-o")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

<<<<<<< HEAD
=======
_kumactl_inspect_meshloadbalancingstrategy()
{
last_command="kumactl_inspect_meshloadbalancingstrategy"

command_aliases=()

commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand All @@ -3868,6 +3927,7 @@ _kumactl_inspect_meshhttproute()
noun_aliases=()
}

>>>>>>> 5141208c6 (fix(kumactl): add `--mesh` parameter to `inspect <policy>` (#7696))
_kumactl_inspect_meshproxypatch()
{
last_command="kumactl_inspect_meshproxypatch"
Expand All @@ -3882,6 +3942,9 @@ _kumactl_inspect_meshproxypatch()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3912,6 +3975,9 @@ _kumactl_inspect_meshratelimit()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -3942,6 +4008,44 @@ _kumactl_inspect_meshretry()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
two_word_flags+=("--config-file")
flags+=("--log-level=")
two_word_flags+=("--log-level")
flags+=("--no-config")
flags+=("--output=")
two_word_flags+=("--output")
two_word_flags+=("-o")

must_have_one_flag=()
must_have_one_noun=()
noun_aliases=()
}

<<<<<<< HEAD
=======
_kumactl_inspect_meshtcproute()
{
last_command="kumactl_inspect_meshtcproute"

command_aliases=()

commands=()

flags=()
two_word_flags=()
local_nonpersistent_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand All @@ -3958,6 +4062,7 @@ _kumactl_inspect_meshretry()
noun_aliases=()
}

>>>>>>> 5141208c6 (fix(kumactl): add `--mesh` parameter to `inspect <policy>` (#7696))
_kumactl_inspect_meshtimeout()
{
last_command="kumactl_inspect_meshtimeout"
Expand All @@ -3972,6 +4077,9 @@ _kumactl_inspect_meshtimeout()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4002,6 +4110,9 @@ _kumactl_inspect_meshtrace()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4032,6 +4143,9 @@ _kumactl_inspect_meshtrafficpermission()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4062,6 +4176,9 @@ _kumactl_inspect_proxytemplate()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4092,6 +4209,9 @@ _kumactl_inspect_rate-limit()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4122,6 +4242,9 @@ _kumactl_inspect_retry()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4185,6 +4308,9 @@ _kumactl_inspect_timeout()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4215,6 +4341,9 @@ _kumactl_inspect_traffic-log()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4245,6 +4374,9 @@ _kumactl_inspect_traffic-permission()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4275,6 +4407,9 @@ _kumactl_inspect_traffic-route()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down Expand Up @@ -4305,6 +4440,9 @@ _kumactl_inspect_traffic-trace()
flags_with_completion=()
flags_completion=()

flags+=("--mesh=")
two_word_flags+=("--mesh")
two_word_flags+=("-m")
flags+=("--api-timeout=")
two_word_flags+=("--api-timeout")
flags+=("--config-file=")
Expand Down
1 change: 1 addition & 0 deletions app/kumactl/cmd/inspect/inspect_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ func newInspectPolicyCmd(policyDesc core_model.ResourceTypeDescriptor, pctx *cmd
return tmpl.Execute(cmd.OutOrStdout(), entryList)
},
}
cmd.PersistentFlags().StringVarP(&pctx.Args.Mesh, "mesh", "m", "default", "mesh to use")
return cmd
}

Expand Down
17 changes: 15 additions & 2 deletions app/kumactl/cmd/inspect/inspect_policy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,14 @@ import (
)

type testPolicyInspectClient struct {
response *api_server_types.PolicyInspectEntryList
ensureMesh string
response *api_server_types.PolicyInspectEntryList
}

func (t *testPolicyInspectClient) Inspect(ctx context.Context, policyDesc model.ResourceTypeDescriptor, mesh, name string) (*api_server_types.PolicyInspectEntryList, error) {
if t.ensureMesh != "" {
Expect(mesh).To(Equal(t.ensureMesh))
}
return t.response, nil
}

Expand All @@ -35,6 +39,7 @@ var _ = Describe("kumactl inspect POLICY", func() {
type testCase struct {
goldenFile string
serverResponseFile string
mesh string
cmdArgs []string
}
DescribeTable("kumactl inspect dataplane",
Expand All @@ -49,7 +54,8 @@ var _ = Describe("kumactl inspect POLICY", func() {
rootCtx := test_kumactl.MakeMinimalRootContext()
rootCtx.Runtime.NewPolicyInspectClient = func(client util_http.Client) resources.PolicyInspectClient {
return &testPolicyInspectClient{
response: entryList,
response: entryList,
ensureMesh: given.mesh,
}
}

Expand All @@ -70,6 +76,7 @@ var _ = Describe("kumactl inspect POLICY", func() {
Entry("inbound policy", testCase{
goldenFile: "inspect-traffic-permission.golden.txt",
serverResponseFile: "inspect-traffic-permission.server-response.json",
mesh: "default",
cmdArgs: []string{"inspect", "traffic-permission", "tp1"},
}),
Entry("outbound policy", testCase{
Expand All @@ -92,5 +99,11 @@ var _ = Describe("kumactl inspect POLICY", func() {
serverResponseFile: "inspect-traffic-trace.server-response.json",
cmdArgs: []string{"inspect", "traffic-trace", "tt1"},
}),
Entry("other-mesh", testCase{
goldenFile: "inspect-traffic-trace-other-mesh.golden.txt",
serverResponseFile: "inspect-traffic-trace-other-mesh.server-response.json",
mesh: "other-mesh",
cmdArgs: []string{"inspect", "traffic-trace", "tt1", "--mesh", "other-mesh"},
}),
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Affected data plane proxies:

backend-1
web-1
redis-1
Loading
Loading