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

Fix for Empty Build Number in cmd Version #1481

Merged
merged 1 commit into from Nov 21, 2023

Conversation

mohaidoss
Copy link
Contributor

@mohaidoss mohaidoss commented Nov 21, 2023

PR Type:

Bug fix


PR Description:

This PR includes two main changes:

  • A bug fix for the 'cmd version' command which was not showing any output when the build number was empty. Now, it will display 'unknown' when the build number is not available.

PR Main Files Walkthrough:

files:
  • cmd/version/version.go: Modified the 'RunE' function in the 'GetVersionCmd' command. Instead of directly using 'cautils.BuildNumber', a 'versionCheckRequest' object is created and used. This ensures that even if the 'BuildNumber' is empty, 'unknown' will be displayed as the version.

@mohaidoss mohaidoss changed the title Add test suite for core/pkg/score Bugfix: cmd version shows nothing when the buildnumber is empty Nov 21, 2023
@mohaidoss
Copy link
Contributor Author

/describe

@github-actions github-actions bot changed the title Bugfix: cmd version shows nothing when the buildnumber is empty Fix for Empty Build Number in cmd Version and Addition of New Adopter Nov 21, 2023
@mohaidoss
Copy link
Contributor Author

Not sure why I have an unrelated commit on my fork lol 😅

@mohaidoss mohaidoss changed the title Fix for Empty Build Number in cmd Version and Addition of New Adopter Fix for Empty Build Number in cmd Version Nov 21, 2023
@matthyx
Copy link
Contributor

matthyx commented Nov 21, 2023

Not sure why I have an unrelated commit on my fork lol 😅

it probably depends on how you have updated your fork... can you try:

git fetch upstream && git rebase upstream/master

@mohaidoss
Copy link
Contributor Author

Not sure why I have an unrelated commit on my fork lol 😅

it probably depends on how you have updated your fork... can you try:

git fetch upstream && git rebase upstream/master

Thank you ! It helped

@matthyx matthyx self-requested a review November 21, 2023 10:34
@matthyx
Copy link
Contributor

matthyx commented Nov 21, 2023

/review

Copy link

PR Analysis

  • 🎯 Main theme: Fixing a bug in the 'cmd version' command that was not showing any output when the build number was empty.
  • 📝 PR summary: This PR addresses a bug in the 'cmd version' command where no output was displayed if the build number was empty. The fix ensures that 'unknown' is displayed as the version when the build number is not available. The PR also includes tests for the changes made.
  • 📌 Type of PR: Bug fix
  • 🧪 Relevant tests added: Yes
  • ⏱️ Estimated effort to review [1-5]: 2, because the PR is small and the changes are straightforward, focusing on a single functionality.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • 💡 General suggestions: The PR is well-structured and the changes are clear. The addition of tests for the changes made is commendable. However, it would be beneficial to add some comments in the code to explain the changes made, especially for future reference.

  • 🤖 Code feedback:

    • relevant file: cmd/version/version.go
      suggestion: Consider handling the error returned by 'fmt.Fprintf'. Ignoring this error might lead to unexpected behaviors. [important]
      relevant line: fmt.Fprintf(cmd.OutOrStdout(),

    • relevant file: cmd/version/version_test.go
      suggestion: It would be better to use 'assert.Equal' from the 'testify' package for comparing expected and actual results. It provides better error messages and reduces the amount of code. [medium]
      relevant line: if string(out) != tt.want {

How to use

Instructions

To invoke the PR-Agent, add a comment using one of the following commands:
/review: Request a review of your Pull Request.
/describe: Update the PR title and description based on the contents of the PR.
/improve [--extended]: Suggest code improvements. Extended mode provides a higher quality feedback.
/ask <QUESTION>: Ask a question about the PR.
/update_changelog: Update the changelog based on the PR's contents.
/add_docs: Generate docstring for new components introduced in the PR.
/generate_labels: Generate labels for the PR based on the PR's contents.
see the tools guide for more details.

To edit any configuration parameter from the configuration.toml, add --config_path=new_value.
For example: /review --pr_reviewer.extra_instructions="focus on the file: ..."
To list the possible configuration parameters, add a /config comment.

Copy link
Contributor

@matthyx matthyx left a comment

Choose a reason for hiding this comment

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

few nits, also please squash your commits

cmd/version/version_test.go Outdated Show resolved Hide resolved
cmd/version/version_test.go Outdated Show resolved Hide resolved
cmd/version/version_test.go Outdated Show resolved Hide resolved
Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>

Use cobra's OutOrStdout instead of os.Stdout

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>

Test cmd version output

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>

Apply recommanded changes

Signed-off-by: Mehdi Moussaif <m.moussaif42@gmail.com>

Unneeded if and print statement
@matthyx matthyx merged commit 5676983 into kubescape:master Nov 21, 2023
10 of 11 checks passed
@matthyx
Copy link
Contributor

matthyx commented Nov 21, 2023

well done @mohaidoss !

@mohaidoss mohaidoss deleted the unknown-version-fix branch November 21, 2023 14:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants