File tree Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Expand file tree Collapse file tree 4 files changed +19
-7
lines changed Original file line number Diff line number Diff line change 9494 "MANAGED_CONFIG" : " ${userHome}/git/governance-policy-framework/kubeconfig_managed" ,
9595 "KUBECONFIG" : " ${userHome}/git/governance-policy-framework/kubeconfig_managed" ,
9696 }
97+ },
98+ // Set inputs in the args section.
99+ {
100+ "name" : " Launch dryrun (instructions in launch.json)" ,
101+ "type" : " go" ,
102+ "request" : " launch" ,
103+ "mode" : " auto" ,
104+ "program" : " ${workspaceFolder}/cmd/dryrun/main.go" ,
105+ "console" : " integratedTerminal" ,
106+ "args" : [
107+ " -p" ,
108+ " ${workspaceFolder}/pkg/dryrun/testdata/test_basic_noncompliant/policy.yaml" ,
109+ " ${workspaceFolder}/pkg/dryrun/testdata/test_basic_noncompliant/input_1.yaml" ,
110+ ]
97111 }
98112 ]
99113}
Original file line number Diff line number Diff line change 33package main
44
55import (
6- "errors"
76 "os"
87
98 "open-cluster-management.io/config-policy-controller/pkg/dryrun"
@@ -12,10 +11,6 @@ import (
1211func main () {
1312 err := dryrun .Execute ()
1413 if err != nil {
15- if errors .Is (err , dryrun .ErrNonCompliant ) {
16- os .Exit (2 )
17- }
18-
1914 os .Exit (1 )
2015 }
2116}
Original file line number Diff line number Diff line change @@ -89,8 +89,7 @@ func (d *DryRunner) GetCmd() *cobra.Command {
8989 RunE : mappings .GenerateMappings ,
9090 })
9191
92- cmd .SetOut (os .Stdout ) // sets default output to stdout, otherwise it is stderr
93- cmd .SilenceUsage = true // otherwise all errors will be followed by the usage doc
92+ cmd .SetOut (os .Stdout ) // sets default output to stdout, otherwise it is stderr
9493
9594 return cmd
9695}
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ import (
4444)
4545
4646func (d * DryRunner ) dryRun (cmd * cobra.Command , args []string ) error {
47+ // The "usage" output will still be emitted if a required flag is missing,
48+ // or if an unknown flag was passed.
49+ cmd .SilenceUsage = true
50+
4751 cfgPolicy , err := d .readPolicy (cmd )
4852 if err != nil {
4953 return fmt .Errorf ("unable to read input policy: %w" , err )
You can’t perform that action at this time.
0 commit comments