@@ -29,7 +29,7 @@ import (
2929
3030type backupOptions interface {
3131 validate ([]string ) error
32- getBlacklistFlags () ([]string , []string )
32+ getDenyListFlags () ([]string , []string )
3333}
3434
3535// ValidateBackupOpts validates the backup/restore options that can be provided to the various backup
@@ -98,9 +98,8 @@ func convertBackupOptsToStruct(backupOpts string, request interface{}) (backupOp
9898
9999 err = commandLine .Parse (parsedBackupOpts )
100100 if err != nil {
101- err = handleCustomParseErrors (err , usage , optsStruct )
102- if err != nil {
103- return nil , nil , err
101+ if customErr := handleCustomParseErrors (err , usage , optsStruct ); customErr != nil {
102+ return nil , nil , customErr
104103 }
105104 }
106105
@@ -186,28 +185,28 @@ func isValidValue(vals []string, val string) bool {
186185 return isValid
187186}
188187
189- // this function checks unknown options from the backup-opts flag to validate that they are not blacklisted
190- // if the option is in the blacklist and error is returned, otherwise the flag is unkown to the operator
188+ // this function checks unknown options from the backup-opts flag to validate that they are not denied
189+ // if the option is in the deny list and error is returned, otherwise the flag is unkown to the operator
191190// and can be passed to pgBackRest for validation.
192191func handleCustomParseErrors (err error , usage * bytes.Buffer , optsStruct backupOptions ) error {
193- blacklistFlags , blacklistFlagsShort := optsStruct .getBlacklistFlags ()
192+ denyListFlags , denyListFlagsShort := optsStruct .getDenyListFlags ()
194193 if err .Error () == "pflag: help requested" {
195194 pflag .Usage ()
196195 return errors .New (usage .String ())
197196 } else if strings .Contains (err .Error (), "unknown flag" ) {
198- for _ , blacklistFlag := range blacklistFlags {
199- flagMatch , err := regexp .MatchString ("\\ B" + blacklistFlag + "$" , err .Error ())
197+ for _ , denyListFlag := range denyListFlags {
198+ flagMatch , err := regexp .MatchString ("\\ B" + denyListFlag + "$" , err .Error ())
200199 if err != nil {
201200 return err
202201 } else if flagMatch {
203- return fmt .Errorf ("Flag %s is not supported for use with PGO" , blacklistFlag )
202+ return fmt .Errorf ("Flag %s is not supported for use with PGO" , denyListFlag )
204203 }
205204 }
206205 } else if strings .Contains (err .Error (), "unknown shorthand flag" ) {
207- for _ , blacklistFlagShort := range blacklistFlagsShort {
208- blacklistFlagQuotes := "'" + strings .TrimPrefix (blacklistFlagShort , "-" ) + "'"
209- if strings .Contains (err .Error (), blacklistFlagQuotes ) {
210- return fmt .Errorf ("Shorthand flag %s is not supported for use with PGO" , blacklistFlagShort )
206+ for _ , denyListFlagShort := range denyListFlagsShort {
207+ denyListFlagQuotes := "'" + strings .TrimPrefix (denyListFlagShort , "-" ) + "'"
208+ if strings .Contains (err .Error (), denyListFlagQuotes ) {
209+ return fmt .Errorf ("Shorthand flag %s is not supported for use with PGO" , denyListFlagShort )
211210 }
212211 }
213212 }
0 commit comments