improve regex
Some checks are pending
CI / Lint (push) Waiting to run
CI / Test (push) Waiting to run
CI / End-to-End (push) Waiting to run
CI / Publish Docker (push) Blocked by required conditions
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-09-16 14:24:37 +10:00
parent 6d86a93539
commit c0e6eec89d

View File

@@ -145,7 +145,11 @@ func (h *Handler) processConfigChanges(configChanges string) []map[string]string
changes := regexp.MustCompile(`\n+`).Split(configChanges, -1) changes := regexp.MustCompile(`\n+`).Split(configChanges, -1)
// Regular expression to match config type and the new value after '->' or '<-' // Regular expression to match config type and the new value after '->' or '<-'
re := regexp.MustCompile(`(?P<type>[^\s]+): [^\s]+ -[><] (?P<newValue>[^;]+);`) // examples:
// "config.memoryHotAddEnabled: true -\u003e false; \n\nconfig.cpuHotAddEnabled: true -\u003e false; \n\n"
// "config.hardware.device(1000).device: (2000, 2001, 2002) -> (2000, 2001, 2002, 2003);"
// "config.hardware.numCPU: 2 -\u003e 1; \n\nconfig.hardware.memoryMB: 4096 -\u003e 3072;"
re := regexp.MustCompile(`(?P<type>[^\s]+): [^-]+-[><] (?P<newValue>[^;]+);`)
// Result will hold a list of changes with type and new value // Result will hold a list of changes with type and new value
var result []map[string]string var result []map[string]string