-
-
Notifications
You must be signed in to change notification settings - Fork 57
feat: Multi Server Management #354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
cc0cc25
5d201d6
1db015e
8344708
bd0f4c3
d9991b1
44127a2
dd9cf11
888e7ab
1234e3a
c4a4984
09e0a05
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,11 +12,20 @@ import ( | |||||||||||||
| func (c *ContainerController) RemoveContainer(f fuego.ContextNoBody) (*shared_types.Response, error) { | ||||||||||||||
| containerID := f.PathParam("container_id") | ||||||||||||||
|
|
||||||||||||||
| if resp, skipped := c.isProtectedContainer(containerID, "remove"); skipped { | ||||||||||||||
| return resp, nil | ||||||||||||||
| } | ||||||||||||||
| dockerService, err := c.getDockerService(f.Context()) | ||||||||||||||
| if err != nil { | ||||||||||||||
| return nil, fuego.HTTPError{ | ||||||||||||||
| Err: err, | ||||||||||||||
| Status: http.StatusInternalServerError, | ||||||||||||||
| } | ||||||||||||||
| } | ||||||||||||||
| defer dockerService.Close() | ||||||||||||||
|
|
||||||||||||||
| if resp, skipped := c.isProtectedContainer(c.ctx, containerID, "remove"); skipped { | ||||||||||||||
| return resp, nil | ||||||||||||||
| } | ||||||||||||||
|
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use request context for protection check to keep server scoping correct. Using - if resp, skipped := c.isProtectedContainer(c.ctx, containerID, "remove"); skipped {
+ if resp, skipped := c.isProtectedContainer(f.Context(), containerID, "remove"); skipped {
return resp, nil
}📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| err := c.dockerService.RemoveContainer(containerID, container.RemoveOptions{Force: true}) | ||||||||||||||
| err = dockerService.RemoveContainer(containerID, container.RemoveOptions{Force: true}) | ||||||||||||||
| if err != nil { | ||||||||||||||
| c.logger.Log(logger.Error, err.Error(), "") | ||||||||||||||
| return nil, fuego.HTTPError{ | ||||||||||||||
|
|
||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not silently fall back to local Docker on context failure
Falling back to a local Docker client can target the wrong host, risking unintended mutations. Prefer propagating the error; callers can decide behavior.
Apply this diff:
func (c *ContainerController) getDockerService(ctx context.Context) (*docker.DockerService, error) { dockerService, err := docker.NewDockerServiceWithContext(ctx) if err != nil { - c.logger.Log(logger.Error, "Failed to create Docker service with context", err.Error()) - return docker.NewDockerService(), nil + c.logger.Log(logger.Error, "Failed to create Docker service with context", err.Error()) + return nil, err } return dockerService, nil }🤖 Prompt for AI Agents