Skip to content

Conversation

@patverb
Copy link

@patverb patverb commented Oct 7, 2025

Add zod schema to types returned by the ContainerClient.

@patverb patverb requested a review from a team as a code owner October 7, 2025 16:44
Copy link
Collaborator

@bwateratmsft bwateratmsft left a comment

Choose a reason for hiding this comment

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

One thing we could do is change all of our .optional() and .optional().nullable() to .nullish(), which basically means | undefined | null. Interested in @danegsta's thoughts on that too. It's slightly more correct since the CLI often returns JSON that parses to null for things instead of undefined.

};
export const InfoItemSchema = z.object({
operatingSystem: z.string().optional().describe('The operating system for the container runtime (e.g. Docker Desktop)'),
osType: z.string().optional().describe('The OS type for the container runtime'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should reference the enum, it would look something along these lines (kinda pseudocode):

Suggested change
osType: z.string().optional().describe('The OS type for the container runtime'),
osType: ContainerOSSchema.describe('The OS type for the container runtime'),

environmentVariables: z.record(z.string(), z.string()).describe('Any environment variables associated with the image'),
ports: z.array(PortBindingSchema).describe('Any default ports exposed by the image'),
volumes: z.array(z.string()).describe('Any volumes defined by the image'),
labels: z.record(z.string(), z.string()).describe('Any labels assigned to the image'),
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should make a common one for labels and env vars. e.g. const LabelsSchema = z.record(z.string(), z.string()); and same for env vars, then reference it in these bodies.

time?: number;
};

export const StopedContainersIdsSchema = z.array(z.string());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: spelling


export const StopedContainersIdsSchema = z.array(z.string());

export type StopContainersIds = z.infer<typeof StopedContainersIdsSchema>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export type StopContainersIds = z.infer<typeof StopedContainersIdsSchema>;
export type StoppedContainersIds = z.infer<typeof StopedContainersIdsSchema>;


export const StartContainersResultSchema = z.array(z.string());

export type StartContainersResult = z.infer<typeof StartContainersResultSchema>;
Copy link
Collaborator

@bwateratmsft bwateratmsft Oct 8, 2025

Choose a reason for hiding this comment

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

Suggested change
export type StartContainersResult = z.infer<typeof StartContainersResultSchema>;
export type StartedContainersIds = z.infer<typeof StartContainersResultSchema>;


export const RestartContainersIdsSchema = z.array(z.string());

export type RestartContainersIds = z.infer<typeof RestartContainersIdsSchema>;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export type RestartContainersIds = z.infer<typeof RestartContainersIdsSchema>;
export type RestartedContainersIds = z.infer<typeof RestartContainersIdsSchema>;

uid: z.number().optional().describe('The (container) uid of the user the file belongs to'),
gid: z.number().optional().describe('The (container) gid of the user the file belongs to'),
mtime: z.number().optional().describe('The modification time of the file/directory, in milliseconds since Unix epoch'),
ctime: z.number().optional().describe('The creation time of the file/directory, in milliseconds since Unix epoch'),
Copy link
Collaborator

@bwateratmsft bwateratmsft Oct 8, 2025

Choose a reason for hiding this comment

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

I found out recently that ctime is not actually creation time, it's "changed" time. ctime marks when file metadata was changed (such as permissions etc.) OR the file content was changed, whereas mtime marks only when file content was changed.

We should update the description.

Copy link
Collaborator

Choose a reason for hiding this comment

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

"Born" time, when a file was created, is sometimes called btime or crtime, but is not supported across all OSs. Seems silly to me but whatever.

Copy link
Collaborator

@bwateratmsft bwateratmsft left a comment

Choose a reason for hiding this comment

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

(changes requested above)

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.

3 participants