Skip to content

Changed the version variable to be var#1686

Merged
liranmauda merged 1 commit intonoobaa:masterfrom
liranmauda:liran-change-version-variable-type
Aug 31, 2025
Merged

Changed the version variable to be var#1686
liranmauda merged 1 commit intonoobaa:masterfrom
liranmauda:liran-change-version-variable-type

Conversation

@liranmauda
Copy link
Contributor

@liranmauda liranmauda commented Aug 25, 2025

Explain the changes

  • Changed the version variable to be var

We are doing that, so in the downstream build, we will be able to edit it at build time

Summary by CodeRabbit

  • Refactor
    • Internal version representation changed to allow runtime updates while keeping the reported version unchanged (5.20.0).
    • No changes to commands, APIs, UI behavior, or performance.
    • External tools and scripts that read the version will continue to see the same value.
    • Stability and compatibility remain unaffected.

@coderabbitai
Copy link

coderabbitai bot commented Aug 25, 2025

Walkthrough

Changed exported Version in version/version.go from a constant to a variable, keeping the initializer value "5.20.0". Declaration block switched from const (...) to var (...); comment unchanged.

Changes

Cohort / File(s) Summary
Version identifier change
version/version.go
Converted exported Version from const to var; maintained value "5.20.0"; declaration block updated from const (...) to var (...).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 9d8724e and 4dd4d3a.

📒 Files selected for processing (1)
  • version/version.go (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • version/version.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: run-admission-test
  • GitHub Check: run-kms-key-rotate-test
  • GitHub Check: run-cli-tests
  • GitHub Check: run-kms-tls-sa-test
  • GitHub Check: cnpg-deployment-test
  • GitHub Check: run-core-config-map-tests
  • GitHub Check: run-operator-tests
  • GitHub Check: run-hac-test
  • GitHub Check: run-kms-kmip-test
  • GitHub Check: golangci-lint
  • GitHub Check: run-kms-dev-test
  • GitHub Check: run-kms-tls-token-test
  • GitHub Check: run-azure-vault-test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
version/version.go (1)

3-6: Add explicit type, usage doc, and a nolint for globals

Minor polish to make intent explicit and avoid common lint noise (e.g., gochecknoglobals). Also document the expected ldflags usage and discourage runtime mutation.

Apply this diff:

 var (
-	// Version is the noobaa-operator version (semver)
-	Version = "5.20.0"
+	// Version is the noobaa-operator version (semver).
+	// It is intended to be overridden at build time via -ldflags -X.
+	// Example (module path auto-detected in release tooling):
+	//   go build -ldflags "-X 'MODULE_PATH/version.Version=5.20.1+downstream'"
+	// Do not mutate at runtime.
+	//nolint:gochecknoglobals // Global to enable ldflags -X injection by downstream builds.
+	Version string = "5.20.0"
 )
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 2f4a6b4 and 9d8724e.

📒 Files selected for processing (1)
  • version/version.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (13)
  • GitHub Check: run-admission-test
  • GitHub Check: run-kms-tls-sa-test
  • GitHub Check: run-kms-dev-test
  • GitHub Check: run-kms-kmip-test
  • GitHub Check: run-cli-tests
  • GitHub Check: run-core-config-map-tests
  • GitHub Check: run-hac-test
  • GitHub Check: run-azure-vault-test
  • GitHub Check: run-kms-tls-token-test
  • GitHub Check: run-operator-tests
  • GitHub Check: golangci-lint
  • GitHub Check: run-kms-key-rotate-test
  • GitHub Check: cnpg-deployment-test
🔇 Additional comments (2)
version/version.go (2)

3-6: LDFlags -X friendly: switching Version from const to var is correct

This achieves the PR objective: Go’s -ldflags "-X pkg.var=value" works only with package-level string variables (not constants). Keeping the same initializer preserves current behavior while allowing downstreams to inject a version at build time.


3-6: Audit complete: no breaking constant references or unintended writes detected

I ran the suggested audit script against the repo and confirmed:

  • No const … = version.Version declarations (single-line or grouped) were found
  • No case version.Version labels in any switch statements
  • No runtime assignments to version.Version outside of its own declaration

Module path and ldflags example were also verified:

  • Module path: github.com/noobaa/noobaa-operator/v5
  • Example override:
    go build -ldflags "-X 'github.com/noobaa/noobaa-operator/v5/version.Version=5.20.1+downstream'" ./...

Since there are no compile-time uses of version.Version and no unintended writes, no further changes are required.

- Changed the version variable to be var

We are doing that, so in the downstream build, we will be able to edit it at build time

Signed-off-by: liranmauda <liran.mauda@gmail.com>
@liranmauda liranmauda force-pushed the liran-change-version-variable-type branch from 9d8724e to 4dd4d3a Compare August 31, 2025 09:05
@liranmauda liranmauda merged commit f43cb97 into noobaa:master Aug 31, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants