Merge pull request #509 from xificurC/fix-secrets-and-configs-idempotence

sort secrets and configs to ensure idempotence
This commit is contained in:
Vincent Demeester 2017-09-15 15:43:59 +02:00 committed by GitHub
commit a09a2c6d15
1 changed files with 14 additions and 2 deletions

View File

@ -295,7 +295,13 @@ func convertServiceSecrets(
})
}
return servicecli.ParseSecrets(client, refs)
secrs, err := servicecli.ParseSecrets(client, refs)
if err != nil {
return nil, err
}
// sort to ensure idempotence (don't restart services just because the entries are in different order)
sort.SliceStable(secrs, func(i, j int) bool { return secrs[i].SecretName < secrs[j].SecretName })
return secrs, err
}
// TODO: fix configs API so that ConfigsAPIClient is not required here
@ -346,7 +352,13 @@ func convertServiceConfigObjs(
})
}
return servicecli.ParseConfigs(client, refs)
confs, err := servicecli.ParseConfigs(client, refs)
if err != nil {
return nil, err
}
// sort to ensure idempotence (don't restart services just because the entries are in different order)
sort.SliceStable(confs, func(i, j int) bool { return confs[i].ConfigName < confs[j].ConfigName })
return confs, err
}
func uint32Ptr(value uint32) *uint32 {