-
Notifications
You must be signed in to change notification settings - Fork 8
Add zod schema to returned types #305
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: main
Are you sure you want to change the base?
Conversation
bwateratmsft
left a comment
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.
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'), |
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.
This should reference the enum, it would look something along these lines (kinda pseudocode):
| 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'), |
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.
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()); |
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.
Nit: spelling
|
|
||
| export const StopedContainersIdsSchema = z.array(z.string()); | ||
|
|
||
| export type StopContainersIds = z.infer<typeof StopedContainersIdsSchema>; |
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.
| 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>; |
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.
| 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>; |
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.
| 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'), |
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.
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.
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.
"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.
bwateratmsft
left a comment
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.
(changes requested above)
Add zod schema to types returned by the ContainerClient.