Skip to content

Commit 5af79c7

Browse files
authored
fix: the service status output is missing (#58)
1 parent e27be10 commit 5af79c7

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ bin/
22
.idea/
33
coverage.out
44
dist/
5+
.vscode/launch.json

cmd/service.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func (o *serviceOption) runE(c *cobra.Command, args []string) (err error) {
4646
var output string
4747
switch o.action {
4848
case "install", "i":
49-
err = os.WriteFile(o.scriptPath, []byte(script), os.ModeAppend)
49+
if err = os.WriteFile(o.scriptPath, []byte(script), os.ModeAppend); err == nil {
50+
output, err = o.Execer.RunCommandAndReturn("systemctl", "", "enable", "atest")
51+
}
5052
case "start":
5153
output, err = o.Execer.RunCommandAndReturn("systemctl", "", "start", "atest")
5254
case "stop":

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/golang/protobuf v1.5.2
1111
github.com/h2non/gock v1.2.0
1212
github.com/invopop/jsonschema v0.7.0
13-
github.com/linuxsuren/go-fake-runtime v0.0.0-20230413085645-15e77ab55dbd
13+
github.com/linuxsuren/go-fake-runtime v0.0.0-20230426144714-1a7a0d160d3f
1414
github.com/linuxsuren/unstructured v0.0.1
1515
github.com/spf13/cobra v1.6.1
1616
github.com/stretchr/testify v1.8.2

go.sum

+4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
4343
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
4444
github.com/linuxsuren/go-fake-runtime v0.0.0-20230413085645-15e77ab55dbd h1:2Avir30WOgcDqG3sA4hlW4bC4c/tgseAUntPhf5JQ6E=
4545
github.com/linuxsuren/go-fake-runtime v0.0.0-20230413085645-15e77ab55dbd/go.mod h1:zmh6J78hSnWZo68faMA2eKOdaEp8eFbERHi3ZB9xHCQ=
46+
github.com/linuxsuren/go-fake-runtime v0.0.0-20230426143116-85f55baf088f h1:QvE5qCxn6uNxIpF4dnX8O172J12+iOFBcmQ52rvhFFU=
47+
github.com/linuxsuren/go-fake-runtime v0.0.0-20230426143116-85f55baf088f/go.mod h1:zmh6J78hSnWZo68faMA2eKOdaEp8eFbERHi3ZB9xHCQ=
48+
github.com/linuxsuren/go-fake-runtime v0.0.0-20230426144714-1a7a0d160d3f h1:TfAzkLxq/agwMBbccTx/f/dlmFWIBLWRGCWjI4IOlK8=
49+
github.com/linuxsuren/go-fake-runtime v0.0.0-20230426144714-1a7a0d160d3f/go.mod h1:zmh6J78hSnWZo68faMA2eKOdaEp8eFbERHi3ZB9xHCQ=
4650
github.com/linuxsuren/unstructured v0.0.1 h1:ilUA8MUYbR6l9ebo/YPV2bKqlf62bzQursDSE+j00iU=
4751
github.com/linuxsuren/unstructured v0.0.1/go.mod h1:KH6aTj+FegzGBzc1vS6mzZx3/duhTUTEVyW5sO7p4as=
4852
github.com/mitchellh/copystructure v1.0.0 h1:Laisrj+bAB6b/yJwB5Bt3ITZhGJdqmxquMKeZ+mmkFQ=

0 commit comments

Comments
 (0)