Skip to content

Commit

Permalink
lxd-migrate: Switch to ValueInSlice
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Parrott <[email protected]>
  • Loading branch information
tomponline committed Jan 30, 2024
1 parent 1424538 commit dc3e2e0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lxd-migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -313,9 +313,9 @@ func askBool(question string, default_ string) bool {
if input == "" {
input = default_
}
if shared.StringInSlice(strings.ToLower(input), []string{"yes", "y"}) {
if shared.ValueInSlice(strings.ToLower(input), []string{"yes", "y"}) {
return true
} else if shared.StringInSlice(strings.ToLower(input), []string{"no", "n"}) {
} else if shared.ValueInSlice(strings.ToLower(input), []string{"no", "n"}) {
return false
}

Expand Down
4 changes: 2 additions & 2 deletions lxd-migrate/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func packagesRemovable(names []string) error {
}

pkg := strings.TrimSpace(line)
if !shared.StringInSlice(pkg, rdepends) && !shared.StringInSlice(pkg, names) {
if !shared.ValueInSlice(pkg, rdepends) && !shared.ValueInSlice(pkg, names) {
rdepends = append(rdepends, pkg)
}
}
Expand All @@ -166,7 +166,7 @@ func packagesRemovable(names []string) error {
for _, pkg := range rdepends {
output, err := shared.RunCommand("dpkg-query", "-W", "-f=${Status}", pkg)
if err == nil && strings.HasSuffix(output, " installed") {
if shared.StringInSlice(pkg, []string{"adapt", "autopkgtest", "lxc2", "nova-compute-lxd", "snapcraft", "ubuntu-server"}) {
if shared.ValueInSlice(pkg, []string{"adapt", "autopkgtest", "lxc2", "nova-compute-lxd", "snapcraft", "ubuntu-server"}) {
continue
}

Expand Down

0 comments on commit dc3e2e0

Please sign in to comment.