1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
package api
import (
"strings"
"github.com/crc-org/crc/v2/pkg/crc/config"
"github.com/crc-org/crc/v2/pkg/crc/preflight"
)
func setupNewInMemoryConfig() *config.Config {
storage := config.NewEmptyInMemoryStorage()
cfg := config.New(&skipPreflights{
storage: storage,
}, config.NewEmptyInMemorySecretStorage())
cfg.AddSetting("a&a", "foo", nil, nil, "test special string")
cfg.AddSetting("b&&&b", "bar", nil, nil, "test special string")
config.RegisterSettings(cfg)
preflight.RegisterSettings(cfg)
return cfg
}
type skipPreflights struct {
storage config.RawStorage
}
func (s *skipPreflights) Get(key string) interface{} {
if strings.HasPrefix(key, "skip-") {
return "true"
}
return s.storage.Get(key)
}
func (s *skipPreflights) Set(key string, value interface{}) error {
return s.storage.Set(key, value)
}
func (s *skipPreflights) Unset(key string) error {
return s.storage.Unset(key)
}
type mockLogger struct {
}
func (*mockLogger) Messages() []string {
return []string{"message 1", "message 2", "message 3"}
}
type mockTelemetry struct {
actions []string
}
func (m *mockTelemetry) UploadAction(action, _, _ string) error {
m.actions = append(m.actions, action)
return nil
}
|