Documentation
¶
Index ¶
- func CloneProtoMessage(t *testing.T, src proto.Message) proto.Message
- func LoadConfigFromFile(t *testing.T, configPath string, v proto.Message)
- func LoadConfigFromFileWithViper(t *testing.T, path string, msg proto.Message)
- func LoadMiddleware(t *testing.T, configPath string) (*middlewarev1.Middlewares, error)
- func LoadYAMLConfig(filename string) ([]byte, error)
- func SaveConfigToFileWithViper(t *testing.T, msg proto.Message, path string, formatName string)
- func SetupIntegrationTest(t *testing.T) func()
- func WithMockData(data map[string]string) func(*MockConsulSource)
- func WithMockDataJSON(data map[string]interface{}) options.Option
- func WithMockDataString(data map[string]string, format string) func(*MockConsulSource)
- 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 a configuration from the specified file path into a proto.Message using the framework's config package.
func LoadConfigFromFileWithViper ¶ added in v0.2.7
LoadConfigFromFileWithViper loads a config file into a protobuf message.
func LoadMiddleware ¶ added in v0.2.7
func LoadMiddleware(t *testing.T, configPath string) (*middlewarev1.Middlewares, error)
LoadMiddleware loads and parses a middleware configuration file using the framework's config.
func LoadYAMLConfig ¶
LoadYAMLConfig loads a YAML configuration file and converts it to a JSON format byte array.
func SaveConfigToFileWithViper ¶ added in v0.2.7
SaveConfigToFileWithViper saves a protobuf message to a file in the specified format.
func SetupIntegrationTest ¶ added in v0.2.7
SetupIntegrationTest sets up the environment for integration tests. It changes the working directory to the runtime module's root, allowing tests to use consistent relative paths for configuration files. It returns a cleanup function that restores the original working directory.
func WithMockData ¶ added in v0.2.7
func WithMockData(data map[string]string) func(*MockConsulSource)
WithMockData provides mock data for MockConsulSource. It expects string values, which will be treated as YAML content. This function maintains backward compatibility with the original signature.
func WithMockDataJSON ¶ added in v0.2.7
WithMockDataJSON provides mock data for MockConsulSource, marshaling values to JSON.
func WithMockDataString ¶ added in v0.2.7
func WithMockDataString(data map[string]string, format string) func(*MockConsulSource)
WithMockDataString provides mock data for MockConsulSource, allowing specification of the format for string values.
func WithMockDataYAML ¶ added in v0.2.7
WithMockDataYAML provides mock data for MockConsulSource, marshaling values to YAML.
Types ¶
type MockConsulSource ¶ added in v0.2.7
type MockConsulSource struct {
// contains filtered or unexported fields
}
MockConsulSource is a mock implementation of runtimeconfig.Source for Consul.
func (*MockConsulSource) Load ¶ added in v0.2.7
func (m *MockConsulSource) Load() ([]*runtimeconfig.KKeyValue, error)
Load returns the mock data as KeyValue pairs.
func (*MockConsulSource) NewSource ¶ added in v0.2.7
func (m *MockConsulSource) NewSource(config *sourcev1.SourceConfig, opts ...options.Option) (kratosconfig.Source, error)
NewSource creates a new instance of MockConsulSource.
func (*MockConsulSource) String ¶ added in v0.2.7
func (m *MockConsulSource) String() string
String returns the name of the mock source.
func (*MockConsulSource) Watch ¶ added in v0.2.7
func (m *MockConsulSource) Watch() (runtimeconfig.KWatcher, error)
Watch is not implemented for the mock source.