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

Sanity check if the image name has a colon #922

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

hoyhbx
Copy link

@hoyhbx hoyhbx commented Jun 22, 2022

fix #918

We fixed the issue by adding sanity check to examine whether a colon is contained in the image name in IsLoggingAPIEnabled function. If there is no colon in image name, we will not retrieve index 1 and will directly return false.

Checklist

  • I have added these changes to the changelog (or it's not applicable).

Copy link
Contributor

@pseudomuto pseudomuto left a comment

Choose a reason for hiding this comment

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

Overall this LGTM, thanks for addressing this 👍

Would you mind adding a test for IsLoggingEnabled here to avoid any regressions in the future?

if len(split_result) > 1 {
version = split_result[1]
} else {
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a log line here or something? I'm just thinking that if this condition is hit (no semi-colon in the image name), how would the end user know?

Copy link
Author

Choose a reason for hiding this comment

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

We have tried to add the log line before, but it seems that a parameter that defines the logger needs to be passed to this function. However, this parameter is currently not available in this function.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be sufficient to add an else branch here that lets the user know that logging is not enabled.

Copy link
Author

Choose a reason for hiding this comment

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

Okay, I have added it in the latest commit.

@hoyhbx
Copy link
Author

hoyhbx commented Jul 15, 2022

Thanks for your response. We have added a unit test in our latest commit.

Copy link
Contributor

@pseudomuto pseudomuto left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. Just a few comments below. This is looking good.

name: "verify image name without colon",
cluster: clusterBuilder.WithImage(customImageName).Cluster(),
imageName: customImageName,
},
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we're missing the case where logging is enabled here.

Copy link
Author

Choose a reason for hiding this comment

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

Yep, I have added it.

if len(split_result) > 1 {
version = split_result[1]
} else {
return false
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it would be sufficient to add an else branch here that lets the user know that logging is not enabled.

@hoyhbx
Copy link
Author

hoyhbx commented Apr 2, 2023

@pseudomuto Could you review this so that it can be merged? I think this is a pretty straight-forward fix

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.

[BUG] The program crashes if the image name does not contain colon
2 participants