Improve error message if inventory does not exist in kpt live status.#4660
Improve error message if inventory does not exist in kpt live status.#4660OisinJohnston2005 wants to merge 1 commit into
Conversation
…status Signed-off-by: Oisin Johnston <oisin.johnston@ericsson.com>
✅ Deploy Preview for kptdocs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
| "sigs.k8s.io/cli-utils/pkg/apply/poller" | ||
| "sigs.k8s.io/cli-utils/pkg/inventory" | ||
|
|
||
| apierrors "k8s.io/apimachinery/pkg/api/errors" |
There was a problem hiding this comment.
I think we're trying to remove dependencies with apimachinery.
| return invInfo, nil | ||
| } | ||
|
|
||
| func verifyInventoryExists(ctx context.Context, f util.Factory, invInfo inventory.Info) error { |
There was a problem hiding this comment.
In this function it would be better to wrap the original error in a more helpful error that you create and that gives context.
the pkgerrors package is useful for this, see:
pkgerrors "github.com/pkg/errors"
see for example:
https://github.com/Nordix/porch/blob/af771881508cea65f4d7c8247c639ff9f424fe6b/pkg/apiserver/apiserver.go#L410
There was a problem hiding this comment.
the original error in the upstream dependency is dumped directly to stdout here so I don't think this solution is viable, this is me implementing Aravindhan's comment on the original issue.



This PR is to fix #2124.
The error message referred to is propagated from cli-utils where they directly print the message to stdout and don't provide any mechanism to catch it.
I added an api call to verify the inventory's existence in kpt live status allowing me to fix the misleading error message, this adds a redundant API call which may not be worth the cleaner output, but the answer to that question is above my paygrade.