mirror of
https://github.com/open-policy-agent/opa.git
synced 2026-08-26 18:25:06 -06:00
94a953150a
This change allows users that build their own executable or "spin" of OPA to give it a name, and have it reference itself properly in help texts. It's a vanity thing, but I think some people would appreciate it, hat tip to the international association of pedants. Signed-off-by: Stephan Renatus <stephan@styra.com> Co-authored-by: kevinstyra <83973046+kevinstyra@users.noreply.github.com>
36 lines
833 B
Go
36 lines
833 B
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 main
|
|
|
|
import (
|
|
"errors"
|
|
"os"
|
|
|
|
"github.com/open-policy-agent/opa/cmd"
|
|
)
|
|
|
|
func main() {
|
|
var exit int
|
|
defer func() {
|
|
if exit != 0 {
|
|
os.Exit(exit)
|
|
}
|
|
}() // orderly shutdown, run all defer routines
|
|
|
|
root := cmd.Command(nil, "OPA")
|
|
if err := root.Execute(); err != nil {
|
|
var e *cmd.ExitError
|
|
if errors.As(err, &e) {
|
|
exit = e.Exit
|
|
} else {
|
|
exit = 1
|
|
}
|
|
}
|
|
}
|
|
|
|
//go:generate build/gen-run-go.sh internal/cmd/genopacapabilities/main.go capabilities.json
|
|
//go:generate build/gen-run-go.sh internal/cmd/genbuiltinmetadata/main.go builtin_metadata.json
|
|
//go:generate build/gen-run-go.sh internal/cmd/genversionindex/main.go v1/ast/version_index.json
|