vmware-tanzu / tanzu-cli

The Tanzu Core CLI project provides the core functionality of the Tanzu CLI. The CLI is based on a plugin architecture where CLI command functionality can be delivered through independently developed plugin binaries
Apache License 2.0
33 stars 21 forks source link

Fix setting of invocation context env vars on mapped targeted commands #748

Closed vuil closed 4 months ago

vuil commented 4 months ago

Ensure the correct destination command path is associated with the targeted mapped command so the env vars set on invocation is correct.

What this PR does / why we need it

Which issue(s) this PR fixes

Fixes #

Describe testing done for PR

See unit tests update.

manually: (requires https://github.com/vmware-tanzu/tanzu-plugin-runtime/pull/180)

> ./artifacts/plugins/darwin/arm64/kubernetes/sample/v1.3.0-dev/tanzu-sample-darwin_arm64 info | jq .
{
  "name": "sample",
  "description": "sample plugin to test command mapping",
  "target": "kubernetes",
  "version": "v1.3.0-dev",
  "buildSHA": "44f2a55d-dirty",
  "digest": "",
  "group": "Manage",
  "docURL": "",
  "completionType": 0,
  "commandMap": [
    {
      "srcPath": "",
      "dstPath": "samp",
      "overrides": "",
      "description": ""
    },
    {
      "srcPath": "deeper",
      "dstPath": "dpr",
      "overrides": "",
      "description": "deeper commands",
      "aliases": [
        "deep"
      ]
    },
...

> tz kubernetes dpr dshout foo
 foo!!
Invocation Context:
&plugin.InvocationContext{invokedGroup:"kubernetes", invokedCommand:"dpr", sourceCommandPath:"deeper"}
Invocation String:
kubernetes dpr
Invocation String For Cmd:
kubernetes dpr dshout

> tz dpr dshout foo
 foo!!
Invocation Context:
&plugin.InvocationContext{invokedGroup:"", invokedCommand:"dpr", sourceCommandPath:"deeper"}
Invocation String:
dpr
Invocation String For Cmd:
dpr dshout

Release note

Additional information

Special notes for your reviewer