more checking
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-25 20:59:06 +10:00
parent fd64990e8e
commit 8e399de31e

View File

@@ -24,7 +24,7 @@ func (h *Handler) VmModify(w http.ResponseWriter, r *http.Request) {
params := queries.CreateUpdateParams{}
var unixTimestamp int64
//re := regexp.MustCompile(`/([^/]+)/[^/]+\.vmdk$`)
re := regexp.MustCompile(`/([^/]+)/[^/]+\.vmdk$`)
reqBody, err := io.ReadAll(r.Body)
if err != nil {
@@ -102,6 +102,21 @@ func (h *Handler) VmModify(w http.ResponseWriter, r *http.Request) {
for i := range testConfig.DeviceChange {
if testConfig.DeviceChange[i].Device.Backing != nil {
h.Logger.Debug("Found backing in configspec", "backing", testConfig.DeviceChange[i].Device.Backing)
// Find the match
backingFile := testConfig.DeviceChange[i].Device.Backing.FileName
matches := re.FindStringSubmatch(backingFile)
if len(matches) < 2 {
h.Logger.Warn("unable to match regex", "backing_filename", backingFile, "match_count", len(matches))
} else {
h.Logger.Debug("Matched regex", "disk_owner", matches[1])
if strings.ToLower(matches[1]) == strings.ToLower(event.CloudEvent.Data.VM.Name) {
h.Logger.Debug("This disk belongs to this VM")
} else {
h.Logger.Debug("This disk belongs to a different VM, don't record this config change")
}
}
}
}
}