Skip to content
This repository was archived by the owner on Jul 28, 2020. It is now read-only.

Commit 9498f3c

Browse files
Anthony Emengojoaopapereira
authored andcommitted
Support comma separated list of services
[#161730948] Signed-off-by: Joao Pereira <[email protected]>
1 parent 8ff7edc commit 9498f3c

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

provision/services.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ func (c *Controller) WhiteListServices(whiteList string, services []Service) ([]
5353
}
5454

5555
for _, service := range services {
56-
if (strings.ToLower(whiteList) == strings.ToLower(service.Flagname)) || (strings.ToLower(service.Flagname) == "always-include") {
56+
if strings.Contains(strings.ToLower(whiteList), strings.ToLower(service.Flagname)) || (strings.ToLower(service.Flagname) == "always-include") {
5757
whiteListed = append(whiteListed, service)
5858
}
5959
}

provision/services_test.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ var _ = Describe("When progress whitelist is called with", func() {
5555
Context("an empty string", func() {
5656
It("returns all and only the DefaultDeploy services", func() {
5757
output, err := c.WhiteListServices("", services)
58-
5958
Expect(err).ToNot(HaveOccurred())
59+
6060
Expect(len(output)).To(Equal(3))
6161
Expect(output[0].Name).To(Equal("service-one"))
6262
Expect(output[1].Name).To(Equal("service-three"))
@@ -67,23 +67,35 @@ var _ = Describe("When progress whitelist is called with", func() {
6767
Context("all", func() {
6868
It("returns all services", func() {
6969
output, err := c.WhiteListServices("all", services)
70-
7170
Expect(err).ToNot(HaveOccurred())
71+
7272
Expect(len(output)).To(Equal(4))
7373
})
7474
})
7575

7676
Context("service-three", func() {
7777
It("returns service-three and the always-include service", func() {
7878
output, err := c.WhiteListServices("service-three-flagname", services)
79-
8079
Expect(err).ToNot(HaveOccurred())
80+
8181
Expect(len(output)).To(Equal(2))
8282
Expect(output[0].Name).To(Equal("service-three"))
8383
Expect(output[1].Name).To(Equal("service-four"))
8484
})
8585
})
8686

87+
Context("multiple services", func() {
88+
It("returns all the requested services", func() {
89+
output, err := c.WhiteListServices("service-two-flagname,service-three-flagname", services)
90+
Expect(err).ToNot(HaveOccurred())
91+
92+
Expect(len(output)).To(Equal(3))
93+
Expect(output[0].Name).To(Equal("service-two"))
94+
Expect(output[1].Name).To(Equal("service-three"))
95+
Expect(output[2].Name).To(Equal("service-four"))
96+
})
97+
})
98+
8799
Context("none", func() {
88100
It("returns only the always-include service", func() {
89101
output, err := c.WhiteListServices("none", services)
@@ -97,7 +109,6 @@ var _ = Describe("When progress whitelist is called with", func() {
97109
Context("nil services", func() {
98110
It("returns an error", func() {
99111
_, err := c.WhiteListServices("service-one", nil)
100-
101112
Expect(err).To(HaveOccurred())
102113
})
103114
})

0 commit comments

Comments
 (0)