Skip to content

Commit b82c5fe

Browse files
committed
Merge pull request #3730 from mboersma/stricter-deisctl-list
fix(deisctl): hide random "deis-" services from "deisctl list"
2 parents a8e4fe5 + 0be2f5c commit b82c5fe

5 files changed

Lines changed: 35 additions & 27 deletions

File tree

deisctl/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ include ../includes.mk
44
repo_path = github.com/deis/deis/deisctl
55

66
GO_FILES = deisctl.go deisctl_test.go
7-
GO_PACKAGES = backend client cmd config utils
7+
GO_PACKAGES = backend client cmd config units utils
88
GO_PACKAGES_REPO_PATH = $(addprefix $(repo_path)/,$(GO_PACKAGES))
99

1010
COMPONENT = $(notdir $(repo_path))

deisctl/backend/fleet/list_units.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/coreos/fleet/machine"
1010
"github.com/coreos/fleet/schema"
11+
"github.com/deis/deis/deisctl/units"
1112
)
1213

1314
// initialize tabwriter on stdout
@@ -82,8 +83,11 @@ func (c *FleetClient) ListUnits() (err error) {
8283
}
8384

8485
for _, us := range unitStates {
85-
if strings.HasPrefix(us.Name, "deis-") {
86-
states = append(states, us)
86+
for _, prefix := range units.Names {
87+
if strings.HasPrefix(us.Name, prefix) {
88+
states = append(states, us)
89+
break
90+
}
8791
}
8892
}
8993
printUnits(states)

deisctl/backend/fleet/utils_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ func TestSplitTarget(t *testing.T) {
9898
type stubFleetClient struct{}
9999

100100
var (
101-
units []*schema.Unit
101+
testUnits []*schema.Unit
102102
)
103103

104104
func (c stubFleetClient) Machines() ([]machine.MachineState, error) {
@@ -108,7 +108,7 @@ func (c stubFleetClient) Unit(string) (*schema.Unit, error) {
108108
return nil, nil
109109
}
110110
func (c stubFleetClient) Units() ([]*schema.Unit, error) {
111-
return units, nil
111+
return testUnits, nil
112112
}
113113
func (c stubFleetClient) UnitStates() ([]*schema.UnitState, error) {
114114
return []*schema.UnitState{}, nil
@@ -126,7 +126,7 @@ func (c stubFleetClient) DestroyUnit(string) error {
126126
var fc stubFleetClient
127127

128128
func TestExpandTargets(t *testing.T) {
129-
units = []*schema.Unit{
129+
testUnits = []*schema.Unit{
130130
&schema.Unit{
131131
Name: "deis-router@1.service",
132132
},

deisctl/cmd/cmd.go

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515

1616
"github.com/deis/deis/deisctl/backend"
1717
"github.com/deis/deis/deisctl/config"
18+
"github.com/deis/deis/deisctl/units"
1819
"github.com/deis/deis/deisctl/utils"
1920

2021
docopt "github.com/docopt/docopt-go"
@@ -564,27 +565,8 @@ Options:
564565
// download and save the unit files to the specified path
565566
rootURL := "https://raw.githubusercontent.com/deis/deis/"
566567
tag := args["--tag"].(string)
567-
units := []string{
568-
"deis-builder.service",
569-
"deis-cache.service",
570-
"deis-controller.service",
571-
"deis-database.service",
572-
"deis-logger.service",
573-
"deis-logspout.service",
574-
"deis-publisher.service",
575-
"deis-registry.service",
576-
"deis-router.service",
577-
"deis-store-admin.service",
578-
"deis-store-daemon.service",
579-
"deis-store-gateway.service",
580-
"deis-store-metadata.service",
581-
"deis-store-monitor.service",
582-
"deis-store-volume.service",
583-
"deis-swarm-manager.service",
584-
"deis-swarm-node.service",
585-
}
586-
for _, unit := range units {
587-
src := rootURL + tag + "/deisctl/units/" + unit
568+
for _, unit := range units.Names {
569+
src := rootURL + tag + "/deisctl/units/" + unit + ".service"
588570
dest := filepath.Join(dir, unit)
589571
res, err := http.Get(src)
590572
if err != nil {

deisctl/units/units.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package units
2+
3+
// Names are the base names of Deis units. Update this list when adding a new Deis unit file.
4+
var Names = []string{
5+
"deis-builder",
6+
"deis-cache",
7+
"deis-controller",
8+
"deis-database",
9+
"deis-logger",
10+
"deis-logspout",
11+
"deis-publisher",
12+
"deis-registry",
13+
"deis-router",
14+
"deis-store-admin",
15+
"deis-store-daemon",
16+
"deis-store-gateway",
17+
"deis-store-metadata",
18+
"deis-store-monitor",
19+
"deis-store-volume",
20+
"deis-swarm-manager",
21+
"deis-swarm-node",
22+
}

0 commit comments

Comments
 (0)