Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
172c40a9
Commit
172c40a9
authored
7 years ago
by
Michael Schurter
Browse files
Options
Download
Email Patches
Plain Diff
Put header diff in its own function
parent
42041e56
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
nomad/structs/diff.go
+22
-13
nomad/structs/diff.go
with
22 additions
and
13 deletions
+22
-13
nomad/structs/diff.go
+
22
-
13
View file @
172c40a9
...
...
@@ -594,21 +594,30 @@ func serviceCheckDiff(old, new *ServiceCheck, contextual bool) *ObjectDiff {
diff
.
Fields
=
fieldDiffs
(
oldPrimitiveFlat
,
newPrimitiveFlat
,
contextual
)
// Diff Header
headerDiff
:=
&
ObjectDiff
{
Type
:
DiffTypeNone
,
Name
:
"Header"
}
if
reflect
.
DeepEqual
(
old
.
Header
,
new
.
Header
)
{
return
diff
}
else
if
len
(
old
.
Header
)
==
0
{
headerDiff
.
Type
=
DiffTypeAdded
}
else
if
len
(
new
.
Header
)
==
0
{
headerDiff
.
Type
=
DiffTypeDeleted
}
else
{
headerDiff
.
Type
=
DiffTypeEdited
if
headerDiff
:=
checkHeaderDiff
(
old
.
Header
,
new
.
Header
,
contextual
);
headerDiff
!=
nil
{
diff
.
Objects
=
append
(
diff
.
Objects
,
headerDiff
)
}
diff
.
Objects
=
append
(
diff
.
Objects
,
headerDiff
)
oldHeaderFlat
:=
flatmap
.
Flatten
(
old
.
Header
,
nil
,
false
)
newHeaderFlat
:=
flatmap
.
Flatten
(
new
.
Header
,
nil
,
false
)
headerDiff
.
Fields
=
fieldDiffs
(
oldHeaderFlat
,
newHeaderFlat
,
contextual
)
return
diff
}
// checkHeaderDiff returns the diff of two service check header objects. If
// contextual diff is enabled, all fields will be returned, even if no diff
// occurred.
func
checkHeaderDiff
(
old
,
new
map
[
string
][]
string
,
contextual
bool
)
*
ObjectDiff
{
diff
:=
&
ObjectDiff
{
Type
:
DiffTypeNone
,
Name
:
"Header"
}
if
reflect
.
DeepEqual
(
old
,
new
)
{
return
nil
}
else
if
len
(
old
)
==
0
{
diff
.
Type
=
DiffTypeAdded
}
else
if
len
(
new
)
==
0
{
diff
.
Type
=
DiffTypeDeleted
}
else
{
diff
.
Type
=
DiffTypeEdited
}
oldFlat
:=
flatmap
.
Flatten
(
old
,
nil
,
false
)
newFlat
:=
flatmap
.
Flatten
(
new
,
nil
,
false
)
diff
.
Fields
=
fieldDiffs
(
oldFlat
,
newFlat
,
contextual
)
return
diff
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help