feat(config): Add optional Docker extraHosts (part 1)#832
feat(config): Add optional Docker extraHosts (part 1)#832peterpeterparker merged 3 commits intojunobuild:mainfrom
Conversation
|
There is likely a related test suite, if you could add a snippet to it that would be great as well. |
|
You're definetly right, it is very broad. There are a few options here according to the docs
So my best attempts can think of are to use either
If we go with tuple, it will need to have logic in part 2 to re-assemble it. I'm not the greatest at regex but something like this could work; const ExtraHostEntrySchema = z
.string()
.regex(
/^[^=:]+[=:](\d{1,3}(\.\d{1,3}){3}|[0-9a-fA-F:]+|\[[0-9a-fA-F:]+\]|host-gateway)$/,
'Must be in the format "hostname=ip", "hostname=host-gateway", or "hostname:ip"'
);
extraHosts: z.array(ExtraHostEntrySchema).optional()I like the tuple idea it makes it much cleaner on this side, and we get to use those cool zod builtins const HostNameSchema = z.string().min(1);
const ExtraHostEntrySchema = z.tuple([
HostNameSchema,
z.union([z.ipv4(), z.ipv6(), z.literal('host-gateway'), HostNameSchema])
]);
extraHosts: z.array(ExtraHostEntrySchema).optional()On the CLI side, we would then need to join: Are you leaning a certain way, regex always feels brittle to me but if done right could work. |
- use the cleaner tuple method - add test suite
peterpeterparker
left a comment
There was a problem hiding this comment.
LGTM, thanks a lot!
| expect(result.success).toBe(true); | ||
| }); | ||
|
|
||
| it('accepts an empty array', () => { |
There was a problem hiding this comment.
I'll maybe add a rule to prevent empty.
Overview
This is part 1/2.
This PR adds an additional configuration item to the Docker options called
extraHostsFurther detail about it's intended use case is documented in part 2.
Related
Part 2