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) #7701

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
105 changes: 105 additions & 0 deletions app/kumactl/cmd/completion/testdata/bash.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3646,6 +3646,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 @@ -3748,6 +3751,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 @@ -3778,6 +3784,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 @@ -3808,6 +3817,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 @@ -3838,6 +3850,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 @@ -3898,6 +3913,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 @@ -3958,6 +3976,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 @@ -3988,6 +4009,9 @@ _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=")
Expand Down Expand Up @@ -4018,6 +4042,9 @@ _kumactl_inspect_meshloadbalancingstrategy()
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 @@ -4048,6 +4075,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 @@ -4078,6 +4108,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 @@ -4108,6 +4141,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 @@ -4124,6 +4195,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 @@ -4138,6 +4210,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 @@ -4168,6 +4243,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 @@ -4198,6 +4276,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 @@ -4228,6 +4309,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 @@ -4258,6 +4342,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 @@ -4288,6 +4375,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 @@ -4351,6 +4441,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 @@ -4381,6 +4474,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 @@ -4411,6 +4507,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 @@ -4441,6 +4540,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 @@ -4471,6 +4573,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 @@ -34,6 +38,7 @@ var _ = Describe("kumactl inspect POLICY", func() {
type testCase struct {
goldenFile string
serverResponseFile string
mesh string
cmdArgs []string
}
DescribeTable("kumactl inspect dataplane",
Expand All @@ -48,7 +53,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 @@ -69,6 +75,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 @@ -91,5 +98,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
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"total": 1,
"items": [
{
"kind": "SidecarDataplane",
"dataplane": {
"mesh": "other-mesh",
"name": "backend-1"
},
"attachments": [
{
"type": "dataplane",
"name": "",
"service": ""
}
]
},
{
"kind": "SidecarDataplane",
"dataplane": {
"mesh": "other-mesh",
"name": "web-1"
},
"attachments": [
{
"type": "dataplane",
"name": "",
"service": ""
}
]
},
{
"kind": "SidecarDataplane",
"dataplane": {
"mesh": "other-mesh",
"name": "redis-1"
},
"attachments": [
{
"type": "dataplane",
"name": "",
"service": ""
}
]
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ kumactl inspect circuit-breaker NAME [flags]
### Options

```
-h, --help help for circuit-breaker
-h, --help help for circuit-breaker
-m, --mesh string mesh to use (default "default")
```

### Options inherited from parent commands
Expand Down
Loading