bugfix: Add back default cmd.RootCommand definition. (#7811)

This commit fixes an issue when upgrading codebases to OPA v1.7.0.

In PR #7797, we introduced the ability to provide "branding"
information in OPA commands and help messages, which would
allow easier customized OPA distributions in the future.

However, this changeset removed the public symbol `cmd.RootCommand`,
and required refactoring to use `cmd.Command`, which breaks automated
upgrades, such as those done by Dependabot.

This PR adds back the missing symbol, with the original/default "OPA"
branding provided. This should allow existing codebases to upgrade
without requiring any code changes.

Signed-off-by: Philip Conrad <philip@chariot-chaser.net>
This commit is contained in:
Philip Conrad
2025-07-31 12:55:34 -04:00
committed by GitHub
parent 3546780664
commit 84b23ccedd
3 changed files with 5 additions and 3 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ func main() {
log.Fatal(err)
}
cmd := cmd.Command(nil, "OPA")
cmd := cmd.RootCommand
cmd.Use = "opa [command]"
cmd.DisableAutoGenTag = true
+3
View File
@@ -10,6 +10,9 @@ import (
iversion "github.com/open-policy-agent/opa/internal/version"
)
// Backwards compatibility definition. Newer code should use Command.
var RootCommand = Command(nil, "OPA")
// UserAgent lets you override the OPA UA sent with all the HTTP requests.
// It's another vanity thing -- if you build your own version of OPA, you
// may want to adjust this.
+1 -2
View File
@@ -19,8 +19,7 @@ func main() {
}
}() // orderly shutdown, run all defer routines
root := cmd.Command(nil, "OPA")
if err := root.Execute(); err != nil {
if err := cmd.RootCommand.Execute(); err != nil {
var e *cmd.ExitError
if errors.As(err, &e) {
exit = e.Exit