Documentation
¶
Index ¶
- func CloneProtoMessage(t *testing.T, src proto.Message) proto.Message
- func LoadConfigFromFile(t *testing.T, path string, target any) (runtimeconfig.KConfig, error)
- func LoadConfigFromFileWithViper(t *testing.T, path string, msg proto.Message)
- func SaveConfigToFileWithViper(t *testing.T, msg proto.Message, path string, formatName string)
- func WithMockDataJSON(data map[string]interface{}) options.Option
- func WithMockDataString(data map[string]string, format string) options.Option
- func WithMockDataYAML(data map[string]interface{}) options.Option
- type MockConsulSource
- func (m *MockConsulSource) Load() ([]*runtimeconfig.KKeyValue, error)
- func (m *MockConsulSource) NewSource(config *sourcev1.SourceConfig, opts ...options.Option) (kratosconfig.Source, error)
- func (m *MockConsulSource) String() string
- func (m *MockConsulSource) Watch() (runtimeconfig.KWatcher, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloneProtoMessage ¶
CloneProtoMessage creates a deep copy of a protobuf message.
func LoadConfigFromFile ¶
LoadConfigFromFile loads configuration from a file and scans into target.
func LoadConfigFromFileWithViper ¶
LoadConfigFromFileWithViper loads a config file into a protobuf message.
func SaveConfigToFileWithViper ¶
SaveConfigToFileWithViper saves a protobuf message to a file in the specified format.
func WithMockDataJSON ¶
WithMockDataJSON provides mock data for MockConsulSource, marshaling values to JSON.
func WithMockDataString ¶
WithMockDataString provides mock data for MockConsulSource, allowing specification of the format for string values.
func WithMockDataYAML ¶
WithMockDataYAML provides mock data for MockConsulSource, marshaling values to YAML.
Types ¶
type MockConsulSource ¶
type MockConsulSource struct {
// contains filtered or unexported fields
}
MockConsulSource is a mock implementation of a config source for testing purposes.
func (*MockConsulSource) Load ¶
func (m *MockConsulSource) Load() ([]*runtimeconfig.KKeyValue, error)
Load returns the mock data as KeyValue pairs.
func (*MockConsulSource) NewSource ¶
func (m *MockConsulSource) NewSource(config *sourcev1.SourceConfig, opts ...options.Option) (kratosconfig.Source, error)
NewSource creates a new instance of MockConsulSource.
func (*MockConsulSource) String ¶
func (m *MockConsulSource) String() string
String returns the name of the mock source.
func (*MockConsulSource) Watch ¶
func (m *MockConsulSource) Watch() (runtimeconfig.KWatcher, error)
Watch is not implemented for the mock source.