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

Improved manifest extraction errors #827

Merged
merged 4 commits into from
Mar 27, 2023

Conversation

julienduchesne
Copy link
Member

@julienduchesne julienduchesne commented Mar 23, 2023

Closes #817

This is something that comes up quite often in our internal environments
When a data structure is not a Kubernetes manifest, the error makes it hard to find out why

This adds a reason, and context for why the object we found isn't a Kubernetes object

In the issue linked above, the error was:

>> tk show environments/default
Error: got an error while extracting env `environments/default`: recursion did not resolve in a valid Kubernetes object.  In path `.grafana.deployment` found key `apiVersion` of type `string` instead.

It is now:

>> tk show environments/default
Error: got an error while extracting env `environments/default`: found invalid Kubernetes object (at .grafana.deployment): attribute "kind" is not a string, it is a float64

apiVersion: apps/v1
kind: 3000
metadata:
    name: grafana
spec:
    selector:
        matchLabels:
            name: grafana
    template:
        metadata:
            labels:
                name: grafana
        spec:
            containers:
                - image: grafana/grafana
                  name: grafana
                  ports:
                    - containerPort: 3000
                      name: ui

More verbose, but it actually helps the user find the error

Closes #817

This is something that comes up quite often in our internal environments
When a data structure is not a Kubernetes manifest, the error makes it hard to find out why

This adds a reason, and context for why the object we found isn't a Kubernetes object
In the issue being closed, the error was:

```
>> tk show environments/default
Error: got an error while extracting env `environments/default`: recursion did not resolve in a valid Kubernetes object.  In path `.grafana.deployment` found key `apiVersion` of type `string` instead.
```

It is now:
```
>> tk show environments/default
Error: got an error while extracting env `environments/default`: recursion ended on key "apiVersion" of type string which does not belong to a valid Kubernetes object
instead, it an attribute of the following object:

apiVersion: apps/v1
kind: 3000
metadata:
    name: grafana
spec:
    selector:
        matchLabels:
            name: grafana
    template:
        metadata:
            labels:
                name: grafana
        spec:
            containers:
                - image: grafana/grafana
                  name: grafana
                  ports:
                    - containerPort: 3000
                      name: ui

this object is not a valid Kubernetes object because: attribute "kind" is not a string, it is a float64
```

More verbose, but it actually helps the user find the error
@julienduchesne julienduchesne requested review from sh0rez and a team March 23, 2023 16:26
@github-actions
Copy link

github-actions bot commented Mar 23, 2023

PR Preview Action v1.3.0
Preview removed because the pull request was closed.
2023-03-27 01:28 UTC

Copy link
Member

@iainlane iainlane left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks better, nice one.

I definitely don't fully understand how validation works, but I left a comment about the message there, I feel it could be a bit clearer. Feel free to disregard if it doesn't make sense. & re-request if you make changes and want 👀 again.

pkg/process/extract.go Outdated Show resolved Hide resolved
pkg/process/extract.go Outdated Show resolved Hide resolved
@julienduchesne julienduchesne merged commit e3899fb into main Mar 27, 2023
@julienduchesne julienduchesne deleted the julienduchesne/improved-extract-err branch March 27, 2023 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing error message
2 participants