Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sort secrets and configs to ensure idempotence #509

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cli/compose/convert/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down