Skip to content

Commit bfed861

Browse files
authored
don't ask user to reload systemd service when running in docker (#3434)
* don't ask user to reload systemd service when running in docker * refactor + give appropriate message if terminal is attached * remove explicit filetype
1 parent 763959f commit bfed861

File tree

16 files changed

+51
-25
lines changed

16 files changed

+51
-25
lines changed

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# vim: set ft=dockerfile:
21
FROM docker.io/golang:1.23-alpine3.20 AS build
32

43
ARG BUILD_VERSION

Dockerfile.debian

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# vim: set ft=dockerfile:
21
FROM docker.io/golang:1.23-bookworm AS build
32

43
ARG BUILD_VERSION

cmd/crowdsec-cli/clicapi/capi.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ func (cli *cliCapi) register(ctx context.Context, capiUserPrefix string, outputF
123123
fmt.Println(string(apiConfigDump))
124124
}
125125

126-
log.Warning(reload.Message)
126+
if msg := reload.UserMessage(); msg != "" {
127+
log.Warning(msg)
128+
}
127129

128130
return nil
129131
}

cmd/crowdsec-cli/cliconsole/console.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,9 @@ Enable given information push to the central API. Allows to empower the console`
214214
log.Infof("%v have been enabled", args)
215215
}
216216

217-
log.Info(reload.Message)
217+
if reload.UserMessage() != "" {
218+
log.Info(reload.UserMessage())
219+
}
218220

219221
return nil
220222
},
@@ -248,7 +250,9 @@ Disable given information push to the central API.`,
248250
log.Infof("%v have been disabled", args)
249251
}
250252

251-
log.Info(reload.Message)
253+
if msg := reload.UserMessage(); msg != "" {
254+
log.Info(msg)
255+
}
252256

253257
return nil
254258
},

cmd/crowdsec-cli/clihub/hub.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ func (cli *cliHub) upgrade(ctx context.Context, yes bool, dryRun bool, force boo
193193
return err
194194
}
195195

196-
if plan.ReloadNeeded {
197-
fmt.Println("\n" + reload.Message)
196+
if msg := reload.UserMessage(); msg != "" && plan.ReloadNeeded {
197+
fmt.Println("\n" + msg)
198198
}
199199

200200
return nil

cmd/crowdsec-cli/cliitem/cmdinstall.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ func (cli cliItem) install(ctx context.Context, args []string, yes bool, dryRun
8888
log.Error(err)
8989
}
9090

91-
if plan.ReloadNeeded {
92-
fmt.Println("\n" + reload.Message)
91+
if msg := reload.UserMessage(); msg != "" && plan.ReloadNeeded {
92+
fmt.Println("\n" + msg)
9393
}
9494

9595
return nil

cmd/crowdsec-cli/cliitem/cmdremove.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ func (cli cliItem) remove(ctx context.Context, args []string, yes bool, dryRun b
104104
return err
105105
}
106106

107-
if plan.ReloadNeeded {
108-
fmt.Println("\n" + reload.Message)
107+
if msg := reload.UserMessage(); msg != "" && plan.ReloadNeeded {
108+
fmt.Println("\n" + msg)
109109
}
110110

111111
return nil

cmd/crowdsec-cli/cliitem/cmdupgrade.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ func (cli cliItem) upgrade(ctx context.Context, args []string, yes bool, dryRun
6666
return err
6767
}
6868

69-
if plan.ReloadNeeded {
70-
fmt.Println("\n" + reload.Message)
69+
if msg := reload.UserMessage(); msg != "" && plan.ReloadNeeded {
70+
fmt.Println("\n" + msg)
7171
}
7272

7373
return nil

cmd/crowdsec-cli/clilapi/register.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func (cli *cliLapi) register(ctx context.Context, apiURL string, outputFile stri
8787
fmt.Printf("%s\n", string(apiConfigDump))
8888
}
8989

90-
log.Warning(reload.Message)
90+
if msg := reload.UserMessage(); msg != "" {
91+
log.Warning(msg)
92+
}
9193

9294
return nil
9395
}

cmd/crowdsec-cli/clisimulation/simulation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ cscli simulation disable crowdsecurity/ssh-bf`,
4747
return nil
4848
},
4949
PersistentPostRun: func(cmd *cobra.Command, _ []string) {
50-
if cmd.Name() != "status" {
51-
log.Info(reload.Message)
50+
if msg := reload.UserMessage(); msg != "" && cmd.Name() != "status" {
51+
log.Info(msg)
5252
}
5353
},
5454
}

0 commit comments

Comments
 (0)