Merge pull request #7869 from dcantah/domainname-oci
oci: Add WithDomainname
This commit is contained in:
commit
4fe2d14e1b
@ -274,6 +274,14 @@ func WithHostname(name string) SpecOpts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithDomainname sets the container's NIS domain name
|
||||||
|
func WithDomainname(name string) SpecOpts {
|
||||||
|
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||||
|
s.Domainname = name
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// WithMounts appends mounts
|
// WithMounts appends mounts
|
||||||
func WithMounts(mounts []specs.Mount) SpecOpts {
|
func WithMounts(mounts []specs.Mount) SpecOpts {
|
||||||
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
return func(_ context.Context, _ Client, _ *containers.Container, s *Spec) error {
|
||||||
|
@ -412,11 +412,17 @@ func TestBaseRuntimeSpec(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := c.runtimeSpec("id1", "/etc/containerd/cri-base.json", oci.WithHostname("new"))
|
out, err := c.runtimeSpec(
|
||||||
|
"id1",
|
||||||
|
"/etc/containerd/cri-base.json",
|
||||||
|
oci.WithHostname("new-host"),
|
||||||
|
oci.WithDomainname("new-domain"),
|
||||||
|
)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "1.0.2", out.Version)
|
assert.Equal(t, "1.0.2", out.Version)
|
||||||
assert.Equal(t, "new", out.Hostname)
|
assert.Equal(t, "new-host", out.Hostname)
|
||||||
|
assert.Equal(t, "new-domain", out.Domainname)
|
||||||
|
|
||||||
// Make sure original base spec not changed
|
// Make sure original base spec not changed
|
||||||
assert.NotEqual(t, out, c.baseOCISpecs["/etc/containerd/cri-base.json"])
|
assert.NotEqual(t, out, c.baseOCISpecs["/etc/containerd/cri-base.json"])
|
||||||
|
@ -412,11 +412,17 @@ func TestBaseRuntimeSpec(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
out, err := c.runtimeSpec("id1", "/etc/containerd/cri-base.json", oci.WithHostname("new"))
|
out, err := c.runtimeSpec(
|
||||||
|
"id1",
|
||||||
|
"/etc/containerd/cri-base.json",
|
||||||
|
oci.WithHostname("new-host"),
|
||||||
|
oci.WithDomainname("new-domain"),
|
||||||
|
)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
||||||
assert.Equal(t, "1.0.2", out.Version)
|
assert.Equal(t, "1.0.2", out.Version)
|
||||||
assert.Equal(t, "new", out.Hostname)
|
assert.Equal(t, "new-host", out.Hostname)
|
||||||
|
assert.Equal(t, "new-domain", out.Domainname)
|
||||||
|
|
||||||
// Make sure original base spec not changed
|
// Make sure original base spec not changed
|
||||||
assert.NotEqual(t, out, c.baseOCISpecs["/etc/containerd/cri-base.json"])
|
assert.NotEqual(t, out, c.baseOCISpecs["/etc/containerd/cri-base.json"])
|
||||||
|
Loading…
Reference in New Issue
Block a user