MCPcopy Index your code
hub / github.com/wavetermdev/waveterm / SetBaseConfigValue

Function SetBaseConfigValue

pkg/wconfig/settingsconfig.go:845–881  ·  view source on GitHub ↗
(toMerge waveobj.MetaMapType)

Source from the content-addressed store, hash-verified

843}
844
845func SetBaseConfigValue(toMerge waveobj.MetaMapType) error {
846 m, cerrs := ReadWaveHomeConfigFile(SettingsFile)
847 if len(cerrs) > 0 {
848 return fmt.Errorf("error reading config file: %v", cerrs[0])
849 }
850 if m == nil {
851 m = make(waveobj.MetaMapType)
852 }
853 for configKey, val := range toMerge {
854 ctype := getConfigKeyType(configKey)
855 if ctype == nil {
856 return fmt.Errorf("invalid config key: %s", configKey)
857 }
858 if val == nil {
859 delete(m, configKey)
860 } else {
861 rtype := reflect.TypeOf(val)
862 if rtype == reflect.TypeOf(dummyNumber) {
863 convertedVal, err := convertJsonNumber(val.(json.Number), ctype)
864 if err != nil {
865 return fmt.Errorf("cannot convert %s: %v", configKey, err)
866 }
867 val = convertedVal
868 rtype = reflect.TypeOf(val)
869 }
870 if rtype != ctype {
871 if ctype == reflect.PointerTo(rtype) {
872 m[configKey] = &val
873 } else {
874 return fmt.Errorf("invalid value type for %s: %T", configKey, val)
875 }
876 }
877 m[configKey] = val
878 }
879 }
880 return WriteWaveHomeConfigFile(SettingsFile, m)
881}
882
883func SetConnectionsConfigValue(connName string, toMerge waveobj.MetaMapType) error {
884 m, cerrs := ReadWaveHomeConfigFile(ConnectionsFile)

Callers 5

SetConfigCommandMethod · 0.92
TelemetryUpdateMethod · 0.92

Calls 4

ReadWaveHomeConfigFileFunction · 0.85
getConfigKeyTypeFunction · 0.85
convertJsonNumberFunction · 0.85
WriteWaveHomeConfigFileFunction · 0.85

Tested by

no test coverage detected