-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1145 from zregvart/issue/1071
Add `ec opa` subcommand to run embedded OPA
- Loading branch information
Showing
6 changed files
with
137 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright The Enterprise Contract Contributors | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package opa | ||
|
||
import ( | ||
"github.com/open-policy-agent/opa/cmd" | ||
"github.com/spf13/cobra" | ||
|
||
_ "github.com/enterprise-contract/ec-cli/internal/evaluator" // imports EC OPA builtins | ||
) | ||
|
||
var OPACmd *cobra.Command | ||
|
||
func init() { | ||
OPACmd = cmd.RootCommand | ||
OPACmd.Use = "opa" | ||
OPACmd.Short = OPACmd.Short + " (embedded)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
|
||
[OPA sub-command is available:stdout - 1] | ||
An open source project to policy-enable your service. | ||
|
||
Usage: | ||
ec opa [command] | ||
|
||
Available Commands: | ||
bench Benchmark a Rego query | ||
build Build an OPA bundle | ||
capabilities Print the capabilities of OPA | ||
check Check Rego source files | ||
deps Analyze Rego query dependencies | ||
eval Evaluate a Rego query | ||
exec Execute against input files | ||
fmt Format Rego source files | ||
inspect Inspect OPA bundle(s) | ||
parse Parse Rego source file | ||
run Start OPA in interactive or server mode | ||
sign Generate an OPA bundle signature | ||
test Execute Rego test cases | ||
version Print the version of OPA | ||
|
||
Flags: | ||
-h, --help help for opa | ||
|
||
Global Flags: | ||
--debug same as verbose but also show function names and line numbers | ||
--kubeconfig string path to the Kubernetes config file to use | ||
--quiet less verbose output | ||
--timeout duration max overall execution duration (default 5m0s) | ||
--trace enable trace logging | ||
--verbose more verbose output | ||
|
||
Use "ec opa [command] --help" for more information about a command. | ||
|
||
--- | ||
|
||
[OPA sub-command is available:stderr - 1] | ||
|
||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Feature: embed OPA CLI | ||
The ec command line should embedd functionality of OPA CLI | ||
|
||
@focus | ||
Scenario: OPA sub-command is available | ||
When ec command is run with "opa --help" | ||
Then the exit status should be 0 | ||
Then the output should match the snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.