Skip to content

Commit

Permalink
Update docs for the function
Browse files Browse the repository at this point in the history
Signed-off-by: dttung2905 <[email protected]>
  • Loading branch information
dttung2905 committed Feb 5, 2024
1 parent f9ac381 commit 08c472c
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion pkg/scalers/scaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,31 @@ func WithDefaultVal(defaultVal interface{}) Option {
}
}

// getParameterFromConfigV2 returns the value of the parameter from the config
// getParameterFromConfigV2 retrieves a parameter value from the provided ScalerConfig object based on the specified parameter name, target type, and optional configuration options.
//
// This method searches for the parameter value in different places within the ScalerConfig object, such as authentication parameters, trigger metadata, and resolved environment variables, based on the provided options.
// It then attempts to convert the found value to the specified target type and returns it.
//
// Parameters:
//
// config: A pointer to a ScalerConfig object from which to retrieve the parameter value.
// parameter: A string representing the name of the parameter to retrieve.
// targetType: A reflect.Type representing the target type to which the parameter value should be converted.
// options: An optional variadic parameter that allows configuring the behavior of the method through Option functions.
//
// Returns:
// - An interface{} representing the retrieved parameter value, converted to the specified target type.
// - An error, if any occurred during the retrieval or conversion process.
//
// Example Usage:
//
// To retrieve a parameter value from a ScalerConfig object, you can call this function with the necessary parameters and options
//
// ```
// val, err := getParameterFromConfigV2(scalerConfig, "parameterName", reflect.TypeOf(int64(0)), UseMetadata(true), UseAuthentication(true))
// if err != nil {
// // Handle error
// }
func getParameterFromConfigV2(config *scalersconfig.ScalerConfig, parameter string, targetType reflect.Type, options ...Option) (interface{}, error) {
opt := &configOptions{defaultVal: ""}
for _, option := range options {
Expand Down

0 comments on commit 08c472c

Please sign in to comment.