mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: resolveContainerSpecImage, resolvePluginSpecRemote: early returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -95,35 +95,33 @@ func (cli *Client) ServiceCreate(ctx context.Context, options ServiceCreateOptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resolveContainerSpecImage(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
func resolveContainerSpecImage(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
||||||
var warning string
|
img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.ContainerSpec.Image, encodedAuth)
|
||||||
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.ContainerSpec.Image, encodedAuth); err != nil {
|
if err != nil {
|
||||||
warning = digestWarning(taskSpec.ContainerSpec.Image)
|
return digestWarning(taskSpec.ContainerSpec.Image)
|
||||||
} else {
|
|
||||||
taskSpec.ContainerSpec.Image = img
|
|
||||||
if len(imgPlatforms) > 0 {
|
|
||||||
if taskSpec.Placement == nil {
|
|
||||||
taskSpec.Placement = &swarm.Placement{}
|
|
||||||
}
|
|
||||||
taskSpec.Placement.Platforms = imgPlatforms
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return warning
|
taskSpec.ContainerSpec.Image = img
|
||||||
|
if len(imgPlatforms) > 0 {
|
||||||
|
if taskSpec.Placement == nil {
|
||||||
|
taskSpec.Placement = &swarm.Placement{}
|
||||||
|
}
|
||||||
|
taskSpec.Placement.Platforms = imgPlatforms
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
||||||
var warning string
|
img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.PluginSpec.Remote, encodedAuth)
|
||||||
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.PluginSpec.Remote, encodedAuth); err != nil {
|
if err != nil {
|
||||||
warning = digestWarning(taskSpec.PluginSpec.Remote)
|
return digestWarning(taskSpec.PluginSpec.Remote)
|
||||||
} else {
|
|
||||||
taskSpec.PluginSpec.Remote = img
|
|
||||||
if len(imgPlatforms) > 0 {
|
|
||||||
if taskSpec.Placement == nil {
|
|
||||||
taskSpec.Placement = &swarm.Placement{}
|
|
||||||
}
|
|
||||||
taskSpec.Placement.Platforms = imgPlatforms
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return warning
|
taskSpec.PluginSpec.Remote = img
|
||||||
|
if len(imgPlatforms) > 0 {
|
||||||
|
if taskSpec.Placement == nil {
|
||||||
|
taskSpec.Placement = &swarm.Placement{}
|
||||||
|
}
|
||||||
|
taskSpec.Placement.Platforms = imgPlatforms
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
||||||
|
|||||||
46
vendor/github.com/moby/moby/client/service_create.go
generated
vendored
46
vendor/github.com/moby/moby/client/service_create.go
generated
vendored
@@ -95,35 +95,33 @@ func (cli *Client) ServiceCreate(ctx context.Context, options ServiceCreateOptio
|
|||||||
}
|
}
|
||||||
|
|
||||||
func resolveContainerSpecImage(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
func resolveContainerSpecImage(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
||||||
var warning string
|
img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.ContainerSpec.Image, encodedAuth)
|
||||||
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.ContainerSpec.Image, encodedAuth); err != nil {
|
if err != nil {
|
||||||
warning = digestWarning(taskSpec.ContainerSpec.Image)
|
return digestWarning(taskSpec.ContainerSpec.Image)
|
||||||
} else {
|
|
||||||
taskSpec.ContainerSpec.Image = img
|
|
||||||
if len(imgPlatforms) > 0 {
|
|
||||||
if taskSpec.Placement == nil {
|
|
||||||
taskSpec.Placement = &swarm.Placement{}
|
|
||||||
}
|
|
||||||
taskSpec.Placement.Platforms = imgPlatforms
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return warning
|
taskSpec.ContainerSpec.Image = img
|
||||||
|
if len(imgPlatforms) > 0 {
|
||||||
|
if taskSpec.Placement == nil {
|
||||||
|
taskSpec.Placement = &swarm.Placement{}
|
||||||
|
}
|
||||||
|
taskSpec.Placement.Platforms = imgPlatforms
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
func resolvePluginSpecRemote(ctx context.Context, cli DistributionAPIClient, taskSpec *swarm.TaskSpec, encodedAuth string) string {
|
||||||
var warning string
|
img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.PluginSpec.Remote, encodedAuth)
|
||||||
if img, imgPlatforms, err := imageDigestAndPlatforms(ctx, cli, taskSpec.PluginSpec.Remote, encodedAuth); err != nil {
|
if err != nil {
|
||||||
warning = digestWarning(taskSpec.PluginSpec.Remote)
|
return digestWarning(taskSpec.PluginSpec.Remote)
|
||||||
} else {
|
|
||||||
taskSpec.PluginSpec.Remote = img
|
|
||||||
if len(imgPlatforms) > 0 {
|
|
||||||
if taskSpec.Placement == nil {
|
|
||||||
taskSpec.Placement = &swarm.Placement{}
|
|
||||||
}
|
|
||||||
taskSpec.Placement.Platforms = imgPlatforms
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return warning
|
taskSpec.PluginSpec.Remote = img
|
||||||
|
if len(imgPlatforms) > 0 {
|
||||||
|
if taskSpec.Placement == nil {
|
||||||
|
taskSpec.Placement = &swarm.Placement{}
|
||||||
|
}
|
||||||
|
taskSpec.Placement.Platforms = imgPlatforms
|
||||||
|
}
|
||||||
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
func imageDigestAndPlatforms(ctx context.Context, cli DistributionAPIClient, image, encodedAuth string) (string, []swarm.Platform, error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user