forked from oauth2-proxy/oauth2-proxy
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
introduce mapstructure decoder for yaml parsing
remove color output in tests for better readability in github actions bugfix: remove google as default provider for alpha options fix conversion flow for toml to yaml revert ginkgo color deactivation revert claim- and secret source back to pointers regenerate alpha config
- Loading branch information
Showing
29 changed files
with
268 additions
and
229 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
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
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
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 was deleted.
Oops, something went wrong.
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,43 @@ | ||
package options | ||
|
||
import ( | ||
"reflect" | ||
"time" | ||
|
||
"github.com/mitchellh/mapstructure" | ||
) | ||
|
||
// Duration is an alias for time.Duration so that we can ensure the marshalling | ||
// and unmarshalling of string durations is done as users expect. | ||
// Intentional blank line below to keep this first part of the comment out of | ||
// any generated references. | ||
|
||
// Duration is as string representation of a period of time. | ||
// A duration string is a is a possibly signed sequence of decimal numbers, | ||
// each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". | ||
// Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". | ||
|
||
// Conversion from string or floating point to golang duration type | ||
// This way floating points will be converted to seconds and strings | ||
// of type 3s or 5m will be parsed with time.ParseDuration | ||
func toDurationHookFunc() mapstructure.DecodeHookFunc { | ||
return func( | ||
f reflect.Type, | ||
t reflect.Type, | ||
data interface{}) (interface{}, error) { | ||
if t != reflect.TypeOf(time.Duration(0)) { | ||
return data, nil | ||
} | ||
|
||
switch f.Kind() { | ||
case reflect.String: | ||
return time.ParseDuration(data.(string)) | ||
case reflect.Float64: | ||
return time.Duration(data.(float64) * float64(time.Second)), nil | ||
case reflect.Int64: | ||
return time.Duration(data.(int64)), nil | ||
default: | ||
return data, nil | ||
} | ||
} | ||
} |
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
Oops, something went wrong.