-
Notifications
You must be signed in to change notification settings - Fork 9.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: don't check any parts of a computed set in InstanceDiff.Same #7205
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -443,35 +443,30 @@ func (d *InstanceDiff) Same(d2 *InstanceDiff) (bool, string) { | |
// values. So check if there is an approximate hash in the key | ||
// and if so, try to match the key. | ||
if strings.Contains(k, "~") { | ||
// TODO (SvH): There should be a better way to do this... | ||
parts := strings.Split(k, ".") | ||
parts2 := strings.Split(k, ".") | ||
parts2 := append([]string(nil), parts...) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yup! equivalent to |
||
|
||
re := regexp.MustCompile(`^~\d+$`) | ||
for i, part := range parts { | ||
if re.MatchString(part) { | ||
// we're going to consider this the base of a | ||
// computed hash, and remove all longer matching fields | ||
ok = true | ||
|
||
parts2[i] = `\d+` | ||
parts2 = parts2[:i+1] | ||
break | ||
} | ||
} | ||
re, err := regexp.Compile("^" + strings.Join(parts2, `\.`) + "$") | ||
|
||
re, err := regexp.Compile("^" + strings.Join(parts2, `\.`)) | ||
if err != nil { | ||
return false, fmt.Sprintf("regexp failed to compile; err: %#v", err) | ||
} | ||
|
||
for k2, _ := range checkNew { | ||
if re.MatchString(k2) { | ||
delete(checkNew, k2) | ||
|
||
if diffOld.NewComputed && strings.HasSuffix(k, ".#") { | ||
// This is a computed list or set, so remove any keys with this | ||
// prefix from the check list. | ||
prefix := k2[:len(k2)-1] | ||
for k2, _ := range checkNew { | ||
if strings.HasPrefix(k2, prefix) { | ||
delete(checkNew, k2) | ||
} | ||
} | ||
} | ||
ok = true | ||
break | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
haha -> @jbardin responds... "there is"!