feat: self-update of master and agents (#15) (#32)

This commit was merged in pull request #32.
This commit is contained in:
2026-10-13 10:17:52 +00:00
parent ec28d1e027
commit 850a670446
39 changed files with 1421 additions and 130 deletions
+18 -3
View File
@@ -177,20 +177,35 @@ var errNoRoots = errors.New("refused: no stack directory is mounted into the age
// path inside the container. Compose labels hold host paths, so only those
// mounts make a label path usable as is.
func MountRoots(ctx context.Context, cli SelfInspector, selfID string) ([]string, error) {
insp, err := inspectSelf(ctx, cli, selfID)
if err != nil {
return nil, err
}
return rootsOf(insp), nil
}
// inspectSelf inspects the agent's own container.
func inspectSelf(ctx context.Context, cli SelfInspector, selfID string) (container.InspectResponse, error) {
if selfID == "" {
return nil, errNoRoots
return container.InspectResponse{}, errNoRoots
}
insp, err := cli.ContainerInspect(ctx, selfID)
if err != nil {
return nil, fmt.Errorf("inspect own container %s: %w", selfID, err)
return container.InspectResponse{}, fmt.Errorf("inspect own container %s: %w", selfID, err)
}
return insp, nil
}
// rootsOf returns the directories MountRoots describes, from an inspected
// container.
func rootsOf(insp container.InspectResponse) []string {
var roots []string
for _, m := range insp.Mounts {
if m.Type == mount.TypeBind && m.RW && filepath.Clean(m.Source) == filepath.Clean(m.Destination) {
roots = append(roots, filepath.Clean(m.Destination))
}
}
return roots, nil
return roots
}
// composeFiles returns the -f arguments for a job: the stack's config files