Skip to content

Commit 40178cc

Browse files
authored
Merge pull request kubernetes#80894 from bart0sh/PR0077-kubeadm-simplified-returns
kubeadm: simplified returns
2 parents cd04b13 + 6b21af7 commit 40178cc

File tree

1 file changed

+3
-12
lines changed

1 file changed

+3
-12
lines changed

cmd/kubeadm/app/util/initsystem/initsystem_unix.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,30 +52,21 @@ func (openrc OpenRCInitSystem) ServiceRestart(service string) error {
5252
func (openrc OpenRCInitSystem) ServiceExists(service string) bool {
5353
args := []string{service, "status"}
5454
outBytes, _ := exec.Command("rc-service", args...).CombinedOutput()
55-
if strings.Contains(string(outBytes), "does not exist") {
56-
return false
57-
}
58-
return true
55+
return !strings.Contains(string(outBytes), "does not exist")
5956
}
6057

6158
// ServiceIsEnabled ensures the service is enabled to start on each boot.
6259
func (openrc OpenRCInitSystem) ServiceIsEnabled(service string) bool {
6360
args := []string{"show", "default"}
6461
outBytes, _ := exec.Command("rc-update", args...).Output()
65-
if strings.Contains(string(outBytes), service) {
66-
return true
67-
}
68-
return false
62+
return strings.Contains(string(outBytes), service)
6963
}
7064

7165
// ServiceIsActive ensures the service is running, or attempting to run. (crash looping in the case of kubelet)
7266
func (openrc OpenRCInitSystem) ServiceIsActive(service string) bool {
7367
args := []string{service, "status"}
7468
outBytes, _ := exec.Command("rc-service", args...).Output()
75-
if strings.Contains(string(outBytes), "stopped") {
76-
return false
77-
}
78-
return true
69+
return !strings.Contains(string(outBytes), "stopped")
7970
}
8071

8172
// EnableCommand return a string describing how to enable a service

0 commit comments

Comments
 (0)