-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathmain.go
More file actions
48 lines (39 loc) · 973 Bytes
/
main.go
File metadata and controls
48 lines (39 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// Copyright 2025 The OPA Authors
// SPDX-License-Identifier: Apache-2.0
package main
import (
"errors"
"fmt"
"os"
"github.com/open-policy-agent/opa/cmd"
_ "github.com/open-policy-agent/eopa/capabilities"
eopaCmd "github.com/open-policy-agent/eopa/cmd"
"github.com/open-policy-agent/eopa/pkg/library"
_ "github.com/open-policy-agent/eopa/pkg/rego_vm"
)
func main() {
// run all deferred functions before os.Exit
var exit int
defer func() {
if exit != 0 {
os.Exit(exit)
}
}() // orderly shutdown, run all defer routines
root := eopaCmd.EOPACommand()
// setup default modules
if err := library.Init(); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
exit = 2
}
if err := root.Execute(); err != nil {
var e *cmd.ExitError
if errors.As(err, &e) {
exit = e.Exit
} else {
exit = 1
}
return
}
}
// Capabilities + built-in metadata file generation:
//go:generate go run internal/cmd/gencapabilities/main.go capabilities.json