File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -1006,6 +1006,8 @@ func toExitError(err error) error {
10061006 return cliErr
10071007 } else if execErr , ok := err .(* osExec.ExitError ); ok && execErr != nil {
10081008 return cli .NewExitError (err , execErr .ExitCode ())
1009+ } else if sopsErr , ok := err .(* sops.SopsError ); ok && sopsErr != nil {
1010+ return cli .NewExitError (err , sopsErr .ExitCode ())
10091011 } else if err != nil {
10101012 return cli .NewExitError (err , codes .ErrorGeneric )
10111013 }
Original file line number Diff line number Diff line change @@ -58,17 +58,24 @@ import (
5858// DefaultUnencryptedSuffix is the default suffix a TreeItem key has to end with for sops to leave its Value unencrypted
5959const DefaultUnencryptedSuffix = "_unencrypted"
6060
61- type sopsError string
61+ type SopsError struct {
62+ exitCode int
63+ message string
64+ }
65+
66+ func (e SopsError ) ExitCode () int {
67+ return e .exitCode
68+ }
6269
63- func (e sopsError ) Error () string {
64- return string ( e )
70+ func (e SopsError ) Error () string {
71+ return e . message
6572}
6673
6774// MacMismatch occurs when the computed MAC does not match the expected ones
68- const MacMismatch = sopsError ( "MAC mismatch" )
75+ var MacMismatch = & SopsError { 10 , "MAC mismatch" }
6976
7077// MetadataNotFound occurs when the input file is malformed and doesn't have sops metadata in it
71- const MetadataNotFound = sopsError ( "sops metadata not found" )
78+ var MetadataNotFound = & SopsError { 11 , "sops metadata not found" }
7279
7380var log * logrus.Logger
7481
You can’t perform that action at this time.
0 commit comments