Skip to content

Commit

Permalink
remove support for excluding apps via "not:"
Browse files Browse the repository at this point in the history
remove support for specifying apps that should be excluded by prefixing
them with "not:".
We don't use that feature anymore.
  • Loading branch information
fho committed Nov 29, 2023
1 parent a2d04b6 commit 285da92
Showing 2 changed files with 0 additions and 66 deletions.
36 changes: 0 additions & 36 deletions internal/deps/composition.go
Original file line number Diff line number Diff line change
@@ -156,49 +156,13 @@ func (comp Composition) Deps(s string) (services []string) {
return services
}

func trimSpaces(sl []string) []string {
result := make([]string, len(sl))
for i, s := range sl {
result[i] = strings.TrimSpace(s)
}
return result
}

// error if removed service is a dependencies of another service which should not be removed
func removeNotWanted(comp Composition, s string) (todo map[string]bool, err error) {
todo = make(map[string]bool)
notwanted := trimSpaces(strings.Split(s, ","))

for serviceName := range comp.Services {
if stringsliceContain(notwanted, serviceName) {
continue
}
for depService := range comp.Services[serviceName].DependsOn {
if stringsliceContain(notwanted, depService) {
return todo, fmt.Errorf("%s is dependent on %s but not in 'not:' filter list", serviceName, depService)
}
}
todo[serviceName] = true
}
return todo, err
}

// RecursiveDepsOf returns Composition with services and dependencies of given servicename
// servicename can be a comma separated list of servicenames
func (comp Composition) RecursiveDepsOf(s string) (newcomp *Composition, err error) {
var added []string
todo := make(map[string]bool)

for _, n := range strings.Split(s, ",") {
if strings.HasPrefix(n, "not:") {
todo, err = removeNotWanted(comp, s[4:])
if err != nil {
return newcomp, err
}
added = append(added, strings.Split(s[4:], ",")...)
break
}

todo[strings.TrimSpace(n)] = true
}

30 changes: 0 additions & 30 deletions internal/deps/composition_test.go
Original file line number Diff line number Diff line change
@@ -88,22 +88,6 @@ func TestRecursiveDepsOfWithListOfServices(t *testing.T) {
if !ok {
t.Error("expected to have 'fifth-service' in composition")
}

// second-service is dependent on first-service but not in 'not:' filter list
_, err := comp.RecursiveDepsOf("not:first-service")
if err == nil {
t.Error("expected error with 'not:first-service' ")
}
}

func TestRecursiveDepsOfWithNot(t *testing.T) {
comp := newTestComp()
notGot, _ := comp.RecursiveDepsOf("not:first-service,second-service")

_, ok := notGot.Services["first-service"]
if ok {
t.Error("expected not to have 'first-service' in composition")
}
}

func TestRecursiveDepsOfWithListOfServicesAndBlank(t *testing.T) {
@@ -126,20 +110,6 @@ func TestDeployOrder(t *testing.T) {
}
}

func TestRemoveNotWanted(t *testing.T) {
comp := newTestComp()
var list []string //nolint:prealloc

mapList, _ := removeNotWanted(comp, "first-service,third")
for k := range mapList {
list = append(list, k)
}

if stringsliceContain(list, "first-service") {
t.Errorf("expected list to not contain 'first-service'. list: %v", list)
}
}

func TestSanitize(t *testing.T) {
s := "mystring"
got := sanitize(s)

0 comments on commit 285da92

Please # to comment.