Skip to content

Fix validation when templating is used on Tasks#1738

Merged
LK4D4 merged 1 commit intomoby:masterfrom
vdemeester:fix-templating-validation
Nov 9, 2016
Merged

Fix validation when templating is used on Tasks#1738
LK4D4 merged 1 commit intomoby:masterfrom
vdemeester:fix-templating-validation

Conversation

@vdemeester
Copy link
Member

This make the validation not fail when using templating when creating a Service. It populates the context with fake data and validate that the result is valid 🐯.

# before
λ ./bin/swarmctl service create --name test --hostname "{{.Service.Name}}-{{.Task.Slot}}" --image busybox --command top
Error: ContainerSpec: {{.Service.Name}}-{{.Task.Slot}} is not valid hostname
# after
λ ./bin/swarmctl service create --name test --hostname "{{.Service.Name}}-{{.Task.Slot}}" --image busybox --command top
hksc6qwxw82mgysel09wfq1w4

This is kinda required for moby/moby#28025 👼

/cc @stevvooe @aaronlehmann @aluzzardi

🐸

Signed-off-by: Vincent Demeester vincent@sbr.pm

@thaJeztah thaJeztah added this to the 1.13.0 milestone Nov 9, 2016
This make the validation not fail when using templating when creating a
Service. It populates the context with fake data and validate that the
result is valid.

Signed-off-by: Vincent Demeester <vincent@sbr.pm>
@vdemeester vdemeester force-pushed the fix-templating-validation branch from cb9aa9e to 486f113 Compare November 9, 2016 11:14
@thaJeztah
Copy link
Member

SGTM

@codecov-io
Copy link

codecov-io commented Nov 9, 2016

Current coverage is 55.31% (diff: 100%)

Merging #1738 into master will increase coverage by 0.15%

@@             master      #1738   diff @@
==========================================
  Files            97         97          
  Lines         15481      15498    +17   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits           8539       8573    +34   
+ Misses         5808       5791    -17   
  Partials       1134       1134          

Sunburst

Powered by Codecov. Last update 1a51ba2...486f113

LogDriver: taskSpec.LogDriver,
})
if err != nil {
return grpc.Errorf(codes.InvalidArgument, err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great: template errors will be propagated to the client.

@stevvooe
Copy link
Contributor

stevvooe commented Nov 9, 2016

LGTM

@vieux
Copy link
Contributor

vieux commented Nov 9, 2016

SGTM

@LK4D4
Copy link
Contributor

LK4D4 commented Nov 9, 2016

LGTM

@LK4D4 LK4D4 merged commit 0089035 into moby:master Nov 9, 2016
@vdemeester vdemeester deleted the fix-templating-validation branch November 9, 2016 21:28
@yellowmegaman
Copy link

Can someone please give a hint where i can find a list of available keys available in templating?
First guess was service inspect, but wanna have confirmation.

Thanks in advance!

@thaJeztah
Copy link
Member

@yellowmegaman see moby/moby#28486 for documentation

@yellowmegaman
Copy link

@thaJeztah Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants