1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

imageWithDigestString: return image unmodified if there are no changes

Instead of returning an empty string, return the image unmodified

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2020-04-16 13:20:38 +02:00
parent 799bd475fb
commit 10c748cd39
No known key found for this signature in database
GPG key ID: 76698F39D527CE8C
2 changed files with 6 additions and 14 deletions

View file

@ -44,9 +44,7 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec,
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, service.TaskTemplate.ContainerSpec.Image, options.EncodedRegistryAuth); err != nil {
resolveWarning = digestWarning(service.TaskTemplate.ContainerSpec.Image)
} else {
if img != "" {
service.TaskTemplate.ContainerSpec.Image = img
}
service.TaskTemplate.ContainerSpec.Image = img
if len(imgPlatforms) > 0 {
if service.TaskTemplate.Placement == nil {
service.TaskTemplate.Placement = &swarm.Placement{}
@ -63,9 +61,7 @@ func (cli *Client) ServiceCreate(ctx context.Context, service swarm.ServiceSpec,
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, service.TaskTemplate.PluginSpec.Remote, options.EncodedRegistryAuth); err != nil {
resolveWarning = digestWarning(service.TaskTemplate.PluginSpec.Remote)
} else {
if img != "" {
service.TaskTemplate.PluginSpec.Remote = img
}
service.TaskTemplate.PluginSpec.Remote = img
if len(imgPlatforms) > 0 {
if service.TaskTemplate.Placement == nil {
service.TaskTemplate.Placement = &swarm.Placement{}
@ -123,7 +119,7 @@ func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, ima
// imageWithDigestString takes an image string and a digest, and updates
// the image string if it didn't originally contain a digest. It returns
// an empty string if there are no updates.
// image unmodified in other situations.
func imageWithDigestString(image string, dgst digest.Digest) string {
namedRef, err := reference.ParseNormalizedNamed(image)
if err == nil {
@ -135,7 +131,7 @@ func imageWithDigestString(image string, dgst digest.Digest) string {
}
}
}
return ""
return image
}
// imageWithTagString takes an image string, and returns a tagged image

View file

@ -52,9 +52,7 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, service.TaskTemplate.ContainerSpec.Image, options.EncodedRegistryAuth); err != nil {
resolveWarning = digestWarning(service.TaskTemplate.ContainerSpec.Image)
} else {
if img != "" {
service.TaskTemplate.ContainerSpec.Image = img
}
service.TaskTemplate.ContainerSpec.Image = img
if len(imgPlatforms) > 0 {
if service.TaskTemplate.Placement == nil {
service.TaskTemplate.Placement = &swarm.Placement{}
@ -71,9 +69,7 @@ func (cli *Client) ServiceUpdate(ctx context.Context, serviceID string, version
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, service.TaskTemplate.PluginSpec.Remote, options.EncodedRegistryAuth); err != nil {
resolveWarning = digestWarning(service.TaskTemplate.PluginSpec.Remote)
} else {
if img != "" {
service.TaskTemplate.PluginSpec.Remote = img
}
service.TaskTemplate.PluginSpec.Remote = img
if len(imgPlatforms) > 0 {
if service.TaskTemplate.Placement == nil {
service.TaskTemplate.Placement = &swarm.Placement{}