mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-12 19:32:48 -06:00
84b23ccedd
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>
53 lines
1.6 KiB
Go
53 lines
1.6 KiB
Go
// Copyright 2016 The OPA Authors. All rights reserved.
|
|
// Use of this source code is governed by an Apache2
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
|
|
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.
|
|
// NOTE(sr): Caution: Please consider this experimental, I have the hunch
|
|
// that we'll find a better way to make this adjustment in the future.
|
|
func UserAgent(agent string) {
|
|
iversion.UserAgent = agent
|
|
}
|
|
|
|
func Command(rootCommand *cobra.Command, brand string) *cobra.Command {
|
|
// rootCommand is the base CLI command that all subcommands are added to.
|
|
if rootCommand == nil {
|
|
rootCommand = &cobra.Command{
|
|
Use: "opa",
|
|
Short: "Open Policy Agent (OPA)",
|
|
Long: "An open source project to policy-enable your service.",
|
|
}
|
|
}
|
|
|
|
initBench(rootCommand, brand)
|
|
initBuild(rootCommand, brand)
|
|
initCapabilities(rootCommand, brand)
|
|
initCheck(rootCommand, brand)
|
|
initDeps(rootCommand, brand)
|
|
initEval(rootCommand, brand)
|
|
initExec(rootCommand, brand)
|
|
initFmt(rootCommand, brand)
|
|
initInspect(rootCommand, brand)
|
|
initOracle(rootCommand, brand)
|
|
initParse(rootCommand, brand)
|
|
initRefactor(rootCommand, brand)
|
|
initRun(rootCommand, brand)
|
|
initSign(rootCommand, brand)
|
|
initTest(rootCommand, brand)
|
|
initVersion(rootCommand, brand)
|
|
return rootCommand
|
|
}
|