Skip to content

Commit

Permalink
cli: ignore VaultToken when generating job diff (#14424)
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Sep 1, 2022
1 parent 25e7c2f commit 774101d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .changelog/14424.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
cli: Ignore Vault token when generating job diff.
```
2 changes: 1 addition & 1 deletion nomad/structs/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ func (j *Job) Diff(other *Job, contextual bool) (*JobDiff, error) {
diff := &JobDiff{Type: DiffTypeNone}
var oldPrimitiveFlat, newPrimitiveFlat map[string]string
filter := []string{"ID", "Status", "StatusDescription", "Version", "Stable", "CreateIndex",
"ModifyIndex", "JobModifyIndex", "Update", "SubmitTime", "NomadTokenID"}
"ModifyIndex", "JobModifyIndex", "Update", "SubmitTime", "NomadTokenID", "VaultToken"}

if j == nil && other == nil {
return diff, nil
Expand Down
16 changes: 15 additions & 1 deletion nomad/structs/diff_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1176,7 +1176,6 @@ func TestJobDiff(t *testing.T) {
},
},
},

{
// Multiregion: region added
Old: &Job{
Expand Down Expand Up @@ -1321,6 +1320,21 @@ func TestJobDiff(t *testing.T) {
},
},
},
{
// VaultToken is filtered
Old: &Job{
ID: "vault-job",
VaultToken: "secret",
},
New: &Job{
ID: "vault-job",
VaultToken: "new-secret",
},
Expected: &JobDiff{
Type: DiffTypeNone,
ID: "vault-job",
},
},
}

for i, c := range cases {
Expand Down

0 comments on commit 774101d

Please sign in to comment.