policy: implement policy logging via progress printer
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
This commit is contained in:
@@ -39,9 +39,10 @@ func evalCmd(dockerCli command.Cli, rootOpts RootOptions) *cobra.Command {
|
||||
var opts evalOpts
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "eval source",
|
||||
Short: "Evaluate policy for a source",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "eval [OPTIONS] source",
|
||||
Short: "Evaluate policy for a source",
|
||||
Args: cobra.ExactArgs(1),
|
||||
DisableFlagsInUseLine: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
opts.builder = rootOpts.Builder
|
||||
return runEval(cmd.Context(), dockerCli, args[0], opts)
|
||||
@@ -380,8 +381,7 @@ func evalDecisionError(decision *policysession.DecisionResponse) error {
|
||||
}
|
||||
|
||||
func parseSource(input string) (*pb.SourceOp, error) {
|
||||
if strings.HasPrefix(input, "docker-image://") {
|
||||
refstr := strings.TrimPrefix(input, "docker-image://")
|
||||
if refstr, ok := strings.CutPrefix(input, "docker-image://"); ok {
|
||||
ref, err := reference.ParseNormalizedNamed(refstr)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "failed to parse image source reference")
|
||||
|
||||
@@ -7,9 +7,10 @@ import (
|
||||
|
||||
func jsonSchemaCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "json-schema",
|
||||
Short: "Print policy JSON schema",
|
||||
Args: cobra.NoArgs,
|
||||
Use: "json-schema",
|
||||
Short: "Print policy JSON schema",
|
||||
Args: cobra.NoArgs,
|
||||
DisableFlagsInUseLine: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runJSONSchema()
|
||||
},
|
||||
|
||||
@@ -12,8 +12,9 @@ type RootOptions struct {
|
||||
// RootCmd creates the policy command tree.
|
||||
func RootCmd(rootcmd *cobra.Command, dockerCli command.Cli, rootOpts RootOptions) *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "policy",
|
||||
Short: "Commands for working with build policies",
|
||||
Use: "policy",
|
||||
Short: "Commands for working with build policies",
|
||||
DisableFlagsInUseLine: true,
|
||||
}
|
||||
|
||||
cmd.AddCommand(
|
||||
|
||||
@@ -7,9 +7,10 @@ import (
|
||||
|
||||
func testCmd() *cobra.Command {
|
||||
cmd := &cobra.Command{
|
||||
Use: "test <path>",
|
||||
Short: "Run policy tests",
|
||||
Args: cobra.ExactArgs(1),
|
||||
Use: "test <path>",
|
||||
Short: "Run policy tests",
|
||||
Args: cobra.ExactArgs(1),
|
||||
DisableFlagsInUseLine: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
return runTest(args[0])
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user