mirror of
https://github.com/containrrr/watchtower.git
synced 2026-02-18 05:08:07 +01:00
fix: always add missing slashes to link names
previously, this was only done when marking dependant containers for restart. but since the names should ALWAYS start with a slash, this check could be performed every time the container is iterated. the only downside to this is that it's less performant (as it needs to copy the strings instead of just having the slices point to the same source string), but it should not be noticable.
This commit is contained in:
parent
bbbe04119c
commit
533bfc0e8b
3 changed files with 17 additions and 8 deletions
|
|
@ -178,14 +178,21 @@ var _ = Describe("the container", func() {
|
|||
"com.centurylinklabs.watchtower.depends-on": "postgres",
|
||||
}))
|
||||
links := c.Links()
|
||||
Expect(links).To(SatisfyAll(ContainElement("postgres"), HaveLen(1)))
|
||||
Expect(links).To(SatisfyAll(ContainElement("/postgres"), HaveLen(1)))
|
||||
})
|
||||
It("should fetch depending containers if there are many", func() {
|
||||
c = MockContainer(WithLabels(map[string]string{
|
||||
"com.centurylinklabs.watchtower.depends-on": "postgres,redis",
|
||||
}))
|
||||
links := c.Links()
|
||||
Expect(links).To(SatisfyAll(ContainElement("postgres"), ContainElement("redis"), HaveLen(2)))
|
||||
Expect(links).To(SatisfyAll(ContainElement("/postgres"), ContainElement("/redis"), HaveLen(2)))
|
||||
})
|
||||
It("should only add slashes to names when they are missing", func() {
|
||||
c = MockContainer(WithLabels(map[string]string{
|
||||
"com.centurylinklabs.watchtower.depends-on": "/postgres,redis",
|
||||
}))
|
||||
links := c.Links()
|
||||
Expect(links).To(SatisfyAll(ContainElement("/postgres"), ContainElement("/redis")))
|
||||
})
|
||||
It("should fetch depending containers if label is blank", func() {
|
||||
c = MockContainer(WithLabels(map[string]string{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue