Skip to content

Allow admins to create and reassign containers for other users#410

Merged
runleveldev merged 5 commits into
mainfrom
copilot/mieweb-409-admins-create-containers
Jul 16, 2026
Merged

Allow admins to create and reassign containers for other users#410
runleveldev merged 5 commits into
mainfrom
copilot/mieweb-409-admins-create-containers

Conversation

Copilot AI commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Admins can now create containers attributed to other users (or reassign ownership of existing containers) by passing username in the request body. API-only — no UI changes.

Changes

  • POST /sites/:siteId/containers — admins may pass username to set the container owner to a different user (validated against the Users table; 404 if not found). Non-admins continue to own their own containers.
  • PUT /sites/:siteId/containers/:id — admins may pass username to reassign container ownership. Only updates if the username differs from the current owner.
  • User model imported in containers.js for pre-insert existence checks.
  • OpenAPI spec updated with username field on both endpoints, marked admin-only.

Example

POST /api/v1/sites/1/containers
Authorization: ******

{
  "hostname": "my-container",
  "template": "ubuntu:22.04",
  "username": "alice"
}
PUT /api/v1/sites/1/containers/42
Authorization: ******

{
  "username": "bob"
}

Copilot AI linked an issue Jul 15, 2026 that may be closed by this pull request
…me param

- POST /containers: admin can pass `username` body field to create container
  attributed to another user; validates user exists (404 if not found)
- PUT /containers/:id: admin can pass `username` body field to reassign
  container ownership to another user; validates user exists (404 if not found)
- Import User model in containers.js for existence validation
- Document both fields in openapi.v1.yaml with admin-only descriptions
Copilot AI changed the title [WIP] Add functionality for admins to create containers for users Allow admins to create and reassign containers for other users Jul 15, 2026
Copilot AI requested a review from runleveldev July 15, 2026 15:33

@runleveldev runleveldev left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread create-a-container/routers/api/v1/containers.js Outdated
Comment thread create-a-container/routers/api/v1/containers.js Outdated
Copilot AI requested a review from runleveldev July 15, 2026 17:17
@runleveldev
runleveldev requested a review from Copilot July 15, 2026 17:18

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the containers API to let admins (only) set or change a container’s owner by passing a username in the request body, and documents the new field in the OpenAPI spec.

Changes:

  • Added username request-body support to POST /sites/:siteId/containers to create containers on behalf of another user.
  • Added username request-body support to PUT /sites/:siteId/containers/:id to reassign container ownership (only when changed).
  • Updated openapi.v1.yaml to document the new username field and related 403 behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
create-a-container/routers/api/v1/containers.js Adds request parsing and ownership assignment/reassignment via optional username.
create-a-container/openapi.v1.yaml Documents username on create/update container endpoints and updates 403 responses accordingly.

Comment thread create-a-container/routers/api/v1/containers.js
Comment thread create-a-container/routers/api/v1/containers.js
Comment thread create-a-container/openapi.v1.yaml
Comment thread create-a-container/openapi.v1.yaml
…tibility

Podman builds default to the OCI image format, which silently drops the
HEALTHCHECK from images/proxmox-ve/Dockerfile. Without it the proxmox
service never reports healthy and bootstrap-manager's service_healthy
condition can never be met. Declaring the same healthcheck at the
compose level applies it at container create time, independent of the
image format.

@cmyers-mieweb cmyers-mieweb left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still leave tags depending on the owner of the container, if we want to still be consistent we will need to make a call to the Proxmox API to update the tag to the new container owner.

Image

@runleveldev

Copy link
Copy Markdown
Collaborator

We still leave tags depending on the owner of the container, if we want to still be consistent we will need to make a call to the Proxmox API to update the tag to the new container owner.
Image

@copilot

Copilot AI commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

We still leave tags depending on the owner of the container, if we want to still be consistent we will need to make a call to the Proxmox API to update the tag to the new container owner.
<img al...

The PUT handler now pushes the new owner as the Proxmox tag (updateLxcConfig with tags: newOwnerUsername) whenever ownership is reassigned and the container has a VMID. It's best-effort like the delete path — a node-API failure is logged rather than failing the request. Commit: 2767949

@runleveldev
runleveldev merged commit 9f9da6f into main Jul 16, 2026
8 checks passed
@runleveldev
runleveldev deleted the copilot/mieweb-409-admins-create-containers branch July 16, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Admins create containers for users

4 participants