This pull request includes several changes focused on improving the helper functions and context management within the codebase. The most important changes include the removal of the ObjectType field from the RequestContextValue struct, the addition of new configuration helper functions, and the introduction of unit tests for these new functions.
Context Management Improvements:
Removed the ObjectType field from the RequestContextValue struct and updated related functions to reflect this change. (internal/helpers/contexts.go, internal/helpers/contexts.goL34)
Simplified the EnterRequestContext and EnterProviderContext functions by using generics and removing the getRequestType function. (internal/helpers/contexts.go, internal/helpers/contexts.goL50-R113)
Configuration Helper Functions:
Added new helper functions GetConfigString, GetConfigMultiString, and GetConfigBool to retrieve configuration values with fallback to environment variables or default values. (internal/helpers/config.go, internal/helpers/config.goR1-R58)
Unit Tests:
Introduced unit tests for the new configuration helper functions to ensure they return the correct values based on different scenarios. (internal/helpers/config_test.go, internal/helpers/config_test.goR1-R335)
Added a new function DiffArrays to compare two string arrays and return the added and removed items. (internal/helpers/array.go, internal/helpers/array.goR6-R7)
Added comments and documentation to various helper functions for better clarity. (internal/helpers/typeinfo.go, internal/helpers/typeinfo.goR10-R17)
These changes enhance the maintainability and functionality of the codebase by improving context management, adding useful configuration utilities, and ensuring these utilities are thoroughly tested.This pull request introduces new utility functions for configuration management and updates the corresponding tests to ensure their correctness. The most important changes include the addition of GetConfigString and GetConfigBool functions in the helpers package and a comprehensive unit test for GetConfigString.
Configuration Management Enhancements:
internal/powerplatform/helpers/config.go: Added GetConfigString and GetConfigBool functions to retrieve configuration values with fallback to environment variables and default values.
Testing Enhancements:
internal/powerplatform/helpers/config_test.go: Added a unit test for GetConfigString using a matrix of test cases to validate different scenarios.This commit adds two helper functions, GetConfigString and GetConfigBool, to the helpers package. These functions are used to retrieve configuration values from either a provided value, an environment variable, or a default value. The GetConfigString function returns a string value, while the GetConfigBool function returns a boolean value. These helpers are useful for retrieving configuration values in a consistent and flexible manner.
This pull request includes several changes focused on improving the helper functions and context management within the codebase. The most important changes include the removal of the
ObjectType
field from theRequestContextValue
struct, the addition of new configuration helper functions, and the introduction of unit tests for these new functions.Context Management Improvements:
ObjectType
field from theRequestContextValue
struct and updated related functions to reflect this change. (internal/helpers/contexts.go
, internal/helpers/contexts.goL34)EnterRequestContext
andEnterProviderContext
functions by using generics and removing thegetRequestType
function. (internal/helpers/contexts.go
, internal/helpers/contexts.goL50-R113)Configuration Helper Functions:
GetConfigString
,GetConfigMultiString
, andGetConfigBool
to retrieve configuration values with fallback to environment variables or default values. (internal/helpers/config.go
, internal/helpers/config.goR1-R58)Unit Tests:
internal/helpers/config_test.go
, internal/helpers/config_test.goR1-R335)EnterRequestContext
function to verify its behavior. (internal/helpers/contexts_test.go
, internal/helpers/contexts_test.goR1-R38)Minor Changes:
DiffArrays
to compare two string arrays and return the added and removed items. (internal/helpers/array.go
, internal/helpers/array.goR6-R7)internal/helpers/typeinfo.go
, internal/helpers/typeinfo.goR10-R17)These changes enhance the maintainability and functionality of the codebase by improving context management, adding useful configuration utilities, and ensuring these utilities are thoroughly tested.This pull request introduces new utility functions for configuration management and updates the corresponding tests to ensure their correctness. The most important changes include the addition of
GetConfigString
andGetConfigBool
functions in thehelpers
package and a comprehensive unit test forGetConfigString
.Configuration Management Enhancements:
internal/powerplatform/helpers/config.go
: AddedGetConfigString
andGetConfigBool
functions to retrieve configuration values with fallback to environment variables and default values.Testing Enhancements:
internal/powerplatform/helpers/config_test.go
: Added a unit test forGetConfigString
using a matrix of test cases to validate different scenarios.This commit adds two helper functions, GetConfigString and GetConfigBool, to thehelpers
package. These functions are used to retrieve configuration values from either a provided value, an environment variable, or a default value. TheGetConfigString
function returns a string value, while theGetConfigBool
function returns a boolean value. These helpers are useful for retrieving configuration values in a consistent and flexible manner.Co-authored-by: [Author Name]