Minor refactor: use anyChanged() to detect changed flags

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2018-05-24 01:13:35 +02:00
parent df43eb931e
commit df9a0c7797
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
1 changed files with 3 additions and 2 deletions

View File

@ -313,12 +313,13 @@ func updateService(ctx context.Context, apiClient client.NetworkAPIClient, flags
return err return err
} }
if flags.Changed(flagLimitCPU) || flags.Changed(flagLimitMemory) { if anyChanged(flags, flagLimitCPU, flagLimitMemory) {
taskResources().Limits = spec.TaskTemplate.Resources.Limits taskResources().Limits = spec.TaskTemplate.Resources.Limits
updateInt64Value(flagLimitCPU, &task.Resources.Limits.NanoCPUs) updateInt64Value(flagLimitCPU, &task.Resources.Limits.NanoCPUs)
updateInt64Value(flagLimitMemory, &task.Resources.Limits.MemoryBytes) updateInt64Value(flagLimitMemory, &task.Resources.Limits.MemoryBytes)
} }
if flags.Changed(flagReserveCPU) || flags.Changed(flagReserveMemory) {
if anyChanged(flags, flagReserveCPU, flagReserveMemory) {
taskResources().Reservations = spec.TaskTemplate.Resources.Reservations taskResources().Reservations = spec.TaskTemplate.Resources.Reservations
updateInt64Value(flagReserveCPU, &task.Resources.Reservations.NanoCPUs) updateInt64Value(flagReserveCPU, &task.Resources.Reservations.NanoCPUs)
updateInt64Value(flagReserveMemory, &task.Resources.Reservations.MemoryBytes) updateInt64Value(flagReserveMemory, &task.Resources.Reservations.MemoryBytes)