Skip to content

Commit

Permalink
fix(kumactl): add --mesh parameter to inspect <policy>
Browse files Browse the repository at this point in the history
This was missing up until now

Signed-off-by: Charly Molter <[email protected]>
  • Loading branch information
lahabana committed Sep 7, 2023
1 parent 6afe69d commit a1e0e86
Show file tree
Hide file tree
Showing 29 changed files with 188 additions and 26 deletions.
72 changes: 72 additions & 0 deletions app/kumactl/cmd/completion/testdata/bash.golden
Original file line number Diff line number Diff line change
Expand Up @@ -3718,6 +3718,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 @@ -3820,6 +3823,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 @@ -3850,6 +3856,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 @@ -3880,6 +3889,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 @@ -3910,6 +3922,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 @@ -3970,6 +3985,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 @@ -4030,6 +4048,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 @@ -4060,6 +4081,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 @@ -4090,6 +4114,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 @@ -4120,6 +4147,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 @@ -4150,6 +4180,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 @@ -4180,6 +4213,9 @@ _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=")
Expand Down Expand Up @@ -4210,6 +4246,9 @@ _kumactl_inspect_meshtcproute()
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 @@ -4240,6 +4279,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 @@ -4270,6 +4312,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 @@ -4300,6 +4345,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 @@ -4330,6 +4378,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 @@ -4360,6 +4411,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 @@ -4390,6 +4444,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 @@ -4453,6 +4510,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 @@ -4483,6 +4543,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 @@ -4513,6 +4576,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 @@ -4543,6 +4609,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 @@ -4573,6 +4642,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
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ kumactl inspect fault-injection NAME [flags]
### Options

```
-h, --help help for fault-injection
-h, --help help for fault-injection
-m, --mesh string mesh to use (default "default")
```

### Options inherited from parent commands
Expand Down
3 changes: 2 additions & 1 deletion docs/generated/cmd/kumactl/kumactl_inspect_healthcheck.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ kumactl inspect healthcheck NAME [flags]
### Options

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

### Options inherited from parent commands
Expand Down
3 changes: 2 additions & 1 deletion docs/generated/cmd/kumactl/kumactl_inspect_meshaccesslog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ kumactl inspect meshaccesslog NAME [flags]
### Options

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

### Options inherited from parent commands
Expand Down
Loading

0 comments on commit a1e0e86

Please sign in to comment.