Skip to content

Commit e629248

Browse files
mitc-gjugeclaude
andcommitted
feat: add OVHcloud DNS provider support
Adds OVHcloud alongside Cloudflare, AWS Route53 and Porkbun, following the existing DnsClient interface in packages/server/src/utils/dns/. - ovh.ts implements listZones, listRecords, upsertRecord, updateRecord, deleteRecord and testConnection against the /domain/zone endpoints of the OVHcloud API, on any of its seven regional endpoints (ovh-eu/ca/us, kimsufi and soyoustart). - A new `ovh` value was added to the DnsProviderType enum along with an ovhDnsConfigSchema (endpoint, applicationKey, applicationSecret, consumerKey) in the discriminated union, plus the Drizzle migration for the enum change. - The application secret and the consumer key are masked/merged like the other providers' secrets in services/dns-provider.ts. - UI: OVHcloud icon, an endpoint selector and the three credential fields in the DNS provider dialog, plus registration in the provider selector. Three OVH-specific behaviours are handled explicitly: - Requests are signed with `$1$` + sha1(applicationSecret+consumerKey+method+ url+body+timestamp). The timestamp comes from the API's own clock via an unauthenticated GET /auth/time, since a host clock a few seconds off would get every call rejected; the measured drift is cached per endpoint for an hour. - OVH only applies zone changes once the zone is explicitly refreshed, so every successful create, update and delete is followed by POST /domain/zone/{zone} /refresh. - The record update payload carries no fieldType, so changing a record's type replaces the record (DELETE then POST) and returns the new id. The record listing endpoint returns ids only, so each record is fetched individually with the fan-out capped at 8 concurrent requests. Also fills in the missing Porkbun label in show-dns-providers.tsx, which fell back to displaying the raw enum value. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
1 parent c225188 commit e629248

11 files changed

Lines changed: 10005 additions & 1 deletion

File tree

‎apps/dokploy/__test__/dns/ovh.test.ts‎

Lines changed: 410 additions & 0 deletions
Large diffs are not rendered by default.

‎apps/dokploy/components/dashboard/settings/dns/handle-dns-provider.tsx‎

Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,17 @@ const providerLabels = {
4444
cloudflare: "Cloudflare",
4545
route53: "AWS Route53",
4646
porkbun: "Porkbun",
47+
ovh: "OVHcloud",
48+
} as const;
49+
50+
const ovhEndpointLabels = {
51+
"ovh-eu": "OVHcloud Europe",
52+
"ovh-ca": "OVHcloud Canada",
53+
"ovh-us": "OVHcloud US",
54+
"kimsufi-eu": "Kimsufi Europe",
55+
"kimsufi-ca": "Kimsufi Canada",
56+
"soyoustart-eu": "So you Start Europe",
57+
"soyoustart-ca": "So you Start Canada",
4758
} as const;
4859

4960
type ProviderType = keyof typeof providerLabels;
@@ -55,12 +66,21 @@ const DnsProviderSchema = z.object({
5566
.regex(/^[a-zA-Z0-9_-]+$/, {
5667
message: "Only letters, numbers, dashes and underscores",
5768
}),
58-
providerType: z.enum(["cloudflare", "route53", "porkbun"]),
69+
providerType: z.enum(["cloudflare", "route53", "porkbun", "ovh"]),
5970
apiToken: z.string(),
6071
accessKeyId: z.string(),
6172
secretAccessKey: z.string(),
6273
apiKey: z.string(),
6374
secretApiKey: z.string(),
75+
endpoint: z.enum(
76+
Object.keys(ovhEndpointLabels) as [
77+
keyof typeof ovhEndpointLabels,
78+
...(keyof typeof ovhEndpointLabels)[],
79+
],
80+
),
81+
applicationKey: z.string(),
82+
applicationSecret: z.string(),
83+
consumerKey: z.string(),
6484
});
6585

6686
type DnsProviderForm = z.infer<typeof DnsProviderSchema>;
@@ -73,6 +93,10 @@ const defaultValues: DnsProviderForm = {
7393
secretAccessKey: "",
7494
apiKey: "",
7595
secretApiKey: "",
96+
endpoint: "ovh-eu",
97+
applicationKey: "",
98+
applicationSecret: "",
99+
consumerKey: "",
76100
};
77101

78102
const buildConfig = (data: DnsProviderForm) => {
@@ -94,6 +118,14 @@ const buildConfig = (data: DnsProviderForm) => {
94118
apiKey: data.apiKey,
95119
secretApiKey: data.secretApiKey,
96120
};
121+
case "ovh":
122+
return {
123+
providerType: "ovh" as const,
124+
endpoint: data.endpoint,
125+
applicationKey: data.applicationKey,
126+
applicationSecret: data.applicationSecret,
127+
consumerKey: data.consumerKey,
128+
};
97129
}
98130
};
99131

@@ -155,6 +187,12 @@ export const HandleDnsProvider = ({ dnsProviderId }: Props) => {
155187
apiKey: provider.config.apiKey,
156188
secretApiKey: provider.config.secretApiKey,
157189
}),
190+
...(provider.config.providerType === "ovh" && {
191+
endpoint: provider.config.endpoint,
192+
applicationKey: provider.config.applicationKey,
193+
applicationSecret: provider.config.applicationSecret,
194+
consumerKey: provider.config.consumerKey,
195+
}),
158196
});
159197
} else if (!dnsProviderId) {
160198
form.reset(defaultValues);
@@ -383,6 +421,85 @@ export const HandleDnsProvider = ({ dnsProviderId }: Props) => {
383421
</>
384422
)}
385423

424+
{providerType === "ovh" && (
425+
<>
426+
<FormField
427+
control={form.control}
428+
name="endpoint"
429+
render={({ field }) => (
430+
<FormItem>
431+
<FormLabel>API Endpoint</FormLabel>
432+
<Select
433+
onValueChange={field.onChange}
434+
value={field.value}
435+
>
436+
<FormControl>
437+
<SelectTrigger>
438+
<SelectValue placeholder="Select an endpoint" />
439+
</SelectTrigger>
440+
</FormControl>
441+
<SelectContent>
442+
{Object.entries(ovhEndpointLabels).map(
443+
([value, label]) => (
444+
<SelectItem key={value} value={value}>
445+
{label}
446+
</SelectItem>
447+
),
448+
)}
449+
</SelectContent>
450+
</Select>
451+
<FormMessage />
452+
</FormItem>
453+
)}
454+
/>
455+
<FormField
456+
control={form.control}
457+
name="applicationKey"
458+
render={({ field }) => (
459+
<FormItem>
460+
<FormLabel>Application Key</FormLabel>
461+
<FormControl>
462+
<Input {...field} />
463+
</FormControl>
464+
<FormMessage />
465+
</FormItem>
466+
)}
467+
/>
468+
<FormField
469+
control={form.control}
470+
name="applicationSecret"
471+
render={({ field }) => (
472+
<FormItem>
473+
<FormLabel>Application Secret</FormLabel>
474+
<FormControl>
475+
<Input type="password" {...field} />
476+
</FormControl>
477+
<FormMessage />
478+
</FormItem>
479+
)}
480+
/>
481+
<FormField
482+
control={form.control}
483+
name="consumerKey"
484+
render={({ field }) => (
485+
<FormItem>
486+
<FormLabel>Consumer Key</FormLabel>
487+
<FormControl>
488+
<Input type="password" {...field} />
489+
</FormControl>
490+
<FormDescription>
491+
Create the three keys at once on api.ovh.com/createToken
492+
with the <code>GET</code>, <code>POST</code>,{" "}
493+
<code>PUT</code> and <code>DELETE</code> rights on{" "}
494+
<code>/domain/zone/*</code>.
495+
</FormDescription>
496+
<FormMessage />
497+
</FormItem>
498+
)}
499+
/>
500+
</>
501+
)}
502+
386503
<DialogFooter className="flex w-full flex-row justify-between gap-2 sm:justify-between">
387504
<Button
388505
type="button"

‎apps/dokploy/components/dashboard/settings/dns/show-dns-providers.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ import { HandleDnsProvider } from "./handle-dns-provider";
2323
const providerLabels: Record<string, string> = {
2424
cloudflare: "Cloudflare",
2525
route53: "AWS Route53",
26+
porkbun: "Porkbun",
27+
ovh: "OVHcloud",
2628
};
2729

2830
export const ShowDnsProviders = () => {

‎apps/dokploy/components/icons/dns-provider-icons.tsx‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,20 @@ export const PorkbunIcon = ({ className }: Props) => (
9191
</svg>
9292
);
9393

94+
export const OvhIcon = ({ className }: Props) => (
95+
<svg
96+
viewBox="0 0 24 24"
97+
fill="currentColor"
98+
xmlns="http://www.w3.org/2000/svg"
99+
className={className}
100+
>
101+
<path d="M19.881 10.095l2.563-4.45C23.434 7.389 24 9.404 24 11.555c0 2.88-1.017 5.523-2.71 7.594h-6.62l2.04-3.541h-2.696l3.176-5.513h2.691zm-2.32-5.243L9.333 19.14l.003.009H2.709C1.014 17.077 0 14.435 0 11.555c0-2.152.57-4.17 1.561-5.918L5.855 13.1 10.6 4.852h6.961z" />
102+
</svg>
103+
);
104+
94105
export const dnsProviderIcons = {
95106
cloudflare: CloudflareIcon,
96107
route53: Route53Icon,
97108
porkbun: PorkbunIcon,
109+
ovh: OvhIcon,
98110
} as const;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TYPE "public"."DnsProviderType" ADD VALUE 'ovh';

0 commit comments

Comments
 (0)