cli: ignore VaultToken when generating job diff (#14424)

This commit is contained in:
Luiz Aoqui 2022-09-01 10:01:53 -04:00 committed by GitHub
parent 4b9bcf94da
commit 19de803503
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 2 deletions

3
.changelog/14424.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
cli: Ignore Vault token when generating job diff.
```

View File

@ -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

View File

@ -1176,7 +1176,6 @@ func TestJobDiff(t *testing.T) {
},
},
},
{
// Multiregion: region added
Old: &Job{
@ -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 {