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

feat: get-resource returns {} if json key not found #68

Merged
merged 1 commit into from
Oct 17, 2023

Conversation

johnbieren
Copy link
Collaborator

This commit changes the behavior of the get-resource util to return {} instead of the empty string if a jsonpath is passed and the key is not found.

This commit changes the behavior of the get-resource util to return {}
instead of the empty string if a jsonpath is passed and the key is not
found.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
@johnbieren johnbieren merged commit f772bc4 into konflux-ci:main Oct 17, 2023
@johnbieren johnbieren deleted the emptyjson branch October 17, 2023 11:49
johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
@mmalina
Copy link
Contributor

mmalina commented Oct 17, 2023

Sorry to be late here. I can imagine situations where this wouldn't make sense, e.g. if you're looking for a string field and it's not there - then being given {} seems wrong. But since this is only used in the collect-data task, I guess it's ok.

What's not ideal is that it will now return {} and not fail even if the resource doesn't exist at all or if kubectl can't even access the cluster.

Also, I would have liked to have this behavior documented in the description.

johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
@johnbieren
Copy link
Collaborator Author

Sorry to be late here. I can imagine situations where this wouldn't make sense, e.g. if you're looking for a string field and it's not there - then being given {} seems wrong. But since this is only used in the collect-data task, I guess it's ok.

What's not ideal is that it will now return {} and not fail even if the resource doesn't exist at all or if kubectl can't even access the cluster.

Also, I would have liked to have this behavior documented in the description.

I can open another PR to improve the documentation. I do agree about the second point, I planned to bring it up on the PR updating collect-data

@mmalina
Copy link
Contributor

mmalina commented Oct 17, 2023

I can open another PR to improve the documentation. I do agree about the second point, I planned to bring it up on the PR updating collect-data

Probably not necessary to open a separate PR for the documentation. But if you're gonna address the second point, you can change it then. Also, I can do it :) Let me know.

@johnbieren
Copy link
Collaborator Author

I can open another PR to improve the documentation. I do agree about the second point, I planned to bring it up on the PR updating collect-data

Probably not necessary to open a separate PR for the documentation. But if you're gonna address the second point, you can change it then. Also, I can do it :) Let me know.

I opened a thread on the other PR and we can talk about what we want to do there

johnbieren added a commit to johnbieren/release-service-catalog that referenced this pull request Oct 17, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
johnbieren added a commit to konflux-ci/release-service-catalog that referenced this pull request Oct 18, 2023
Bump the image used in the collect-data task to get a bug fix in the
merge-json script
(konflux-ci/release-service-utils#67) and
a change to get-resource util to return {} instead of the empty string
if the json key doesn't exist
(konflux-ci/release-service-utils#68).
Also removes all references to extraData in the task
and replaces it with data to align with recent API changes.

Signed-off-by: Johnny Bieren <jbieren@redhat.com>
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.

4 participants