mirror of
https://github.com/psviderski/uncloud.git
synced 2026-10-06 13:18:58 +00:00
feat(runtime-templates): add support for runtime templates in bind mounts (#412)
This commit is contained in:
1 parent
88dda435e7
commit
5c33e4be86
17 files changed
+571
-10
No files matched your search
+18
-2
@@ -38,9 +38,10 @@ func assertServiceMatchesSpec(t *testing.T, svc api.Service, spec api.ServiceSpe
|
||||
}
|
||||
|
||||
func assertContainerMatchesSpec(t *testing.T, ctr api.ServiceContainer, spec api.ServiceSpec) {
|
||||
spec = spec.SetDefaults()
|
||||
status := deploy.EvalContainerSpecChange(ctr.ServiceSpec, spec)
|
||||
desiredSpec := spec.SetDefaults()
|
||||
status := deploy.EvalContainerSpecChange(ctr.ServiceSpec, desiredSpec)
|
||||
assert.Equal(t, deploy.ContainerUpToDate, status)
|
||||
spec = renderRuntimeTemplatesForContainer(t, desiredSpec, ctr.Name)
|
||||
|
||||
// Verify labels.
|
||||
assert.True(t, api.ValidateServiceID(ctr.Config.Labels[api.LabelServiceID]))
|
||||
@@ -148,8 +149,10 @@ func assertHookContainersMatchSpec(t *testing.T, svc api.Service, spec api.Servi
|
||||
t.Helper()
|
||||
require.NotEmpty(t, svc.HookContainers, "Expected at least one hook container")
|
||||
|
||||
desiredSpec := spec
|
||||
for _, mc := range svc.HookContainers {
|
||||
ctr := mc.Container
|
||||
spec := renderRuntimeTemplatesForContainer(t, desiredSpec, ctr.Name)
|
||||
|
||||
// Verify labels.
|
||||
assert.True(t, api.ValidateServiceID(ctr.Config.Labels[api.LabelServiceID]))
|
||||
@@ -215,6 +218,19 @@ func assertHookContainersMatchSpec(t *testing.T, svc api.Service, spec api.Servi
|
||||
}
|
||||
}
|
||||
|
||||
func renderRuntimeTemplatesForContainer(
|
||||
t *testing.T, spec api.ServiceSpec, containerName string,
|
||||
) api.ServiceSpec {
|
||||
t.Helper()
|
||||
|
||||
renderedSpec, err := spec.RenderRuntimeTemplates(api.RuntimeTemplateContext{
|
||||
Container: api.RuntimeTemplateContainerContext{Name: containerName},
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
return renderedSpec
|
||||
}
|
||||
|
||||
func assertContainerMountsMatchSpec(t *testing.T, mounts []mount.Mount, spec api.ServiceSpec) {
|
||||
expectedMounts, err := machinedocker.ToDockerMounts(spec.Volumes, spec.Container.VolumeMounts)
|
||||
require.NoError(t, err)
|
||||
|
||||
Reference in new issue
Block a user