-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api/types/filters: Add GetBoolOrDefault
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
- Loading branch information
Showing
3 changed files
with
187 additions
and
11 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,37 @@ | ||
package filters | ||
|
||
import "fmt" | ||
|
||
// invalidFilter indicates that the provided filter or its value is invalid | ||
type invalidFilter struct { | ||
Filter string | ||
Value []string | ||
} | ||
|
||
func (e invalidFilter) Error() string { | ||
msg := "invalid filter" | ||
if e.Filter != "" { | ||
msg += " '" + e.Filter | ||
if e.Value != nil { | ||
msg = fmt.Sprintf("%s=%s", msg, e.Value) | ||
} | ||
msg += "'" | ||
} | ||
return msg | ||
} | ||
|
||
// InvalidParameter marks this error as ErrInvalidParameter | ||
func (e invalidFilter) InvalidParameter() {} | ||
|
||
// unreachableCode is an error indicating that the code path was not expected to be reached. | ||
type unreachableCode struct { | ||
Filter string | ||
Value []string | ||
} | ||
|
||
// System marks this error as ErrSystem | ||
func (e unreachableCode) System() {} | ||
|
||
func (e unreachableCode) Error() string { | ||
return fmt.Sprintf("unreachable code reached for filter: %q with values: %s", e.Filter, e.Value) | ||
} |
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