@@ -7,6 +7,7 @@ import { z } from "zod";
77import { AlertBlock } from "@/components/shared/alert-block" ;
88import { CodeEditor } from "@/components/shared/code-editor" ;
99import { Button } from "@/components/ui/button" ;
10+ import { Checkbox } from "@/components/ui/checkbox" ;
1011import {
1112 Form ,
1213 FormControl ,
@@ -16,6 +17,7 @@ import {
1617 FormLabel ,
1718 FormMessage ,
1819} from "@/components/ui/form" ;
20+ import { Label } from "@/components/ui/label" ;
1921import { api } from "@/utils/api" ;
2022import { validateAndFormatYAML } from "../application/advanced/traefik/update-traefik-config" ;
2123
@@ -47,6 +49,7 @@ export const ShowTraefikFile = ({ path, serverId }: Props) => {
4749 } ,
4850 ) ;
4951 const [ canEdit , setCanEdit ] = useState ( true ) ;
52+ const [ skipYamlValidation , setSkipYamlValidation ] = useState ( false ) ;
5053
5154 const { mutateAsync, isLoading, error, isError } =
5255 api . settings . updateTraefikFile . useMutation ( ) ;
@@ -66,13 +69,15 @@ export const ShowTraefikFile = ({ path, serverId }: Props) => {
6669 } , [ form , form . reset , data ] ) ;
6770
6871 const onSubmit = async ( data : UpdateServerMiddlewareConfig ) => {
69- const { valid, error } = validateAndFormatYAML ( data . traefikConfig ) ;
70- if ( ! valid ) {
71- form . setError ( "traefikConfig" , {
72- type : "manual" ,
73- message : error || "Invalid YAML" ,
74- } ) ;
75- return ;
72+ if ( ! skipYamlValidation ) {
73+ const { valid, error } = validateAndFormatYAML ( data . traefikConfig ) ;
74+ if ( ! valid ) {
75+ form . setError ( "traefikConfig" , {
76+ type : "manual" ,
77+ message : error || "Invalid YAML" ,
78+ } ) ;
79+ return ;
80+ }
7681 }
7782 form . clearErrors ( "traefikConfig" ) ;
7883 await mutateAsync ( {
@@ -153,14 +158,37 @@ routers:
153158 />
154159 ) }
155160 </ div >
156- < div className = "flex justify-end" >
157- < Button
158- isLoading = { isLoading }
159- disabled = { canEdit || isLoading }
160- type = "submit"
161- >
162- Update
163- </ Button >
161+ < div className = "flex flex-col gap-4" >
162+ < div className = "flex items-center space-x-2" >
163+ < Checkbox
164+ id = "skip-yaml-validation"
165+ checked = { skipYamlValidation }
166+ onCheckedChange = { ( checked ) =>
167+ setSkipYamlValidation ( checked === true )
168+ }
169+ />
170+ < Label
171+ htmlFor = "skip-yaml-validation"
172+ className = "text-sm font-normal cursor-pointer"
173+ >
174+ Skip YAML validation (for Go templating)
175+ </ Label >
176+ </ div >
177+ < p className = "text-sm text-muted-foreground -mt-2" >
178+ Traefik supports Go templating in dynamic configs (e.g.{ " " }
179+ < code className = "text-xs" > { "{{range}}" } </ code > ). Configs using
180+ templates will fail standard YAML validation. Check this to save
181+ without validation.
182+ </ p >
183+ < div className = "flex justify-end" >
184+ < Button
185+ isLoading = { isLoading }
186+ disabled = { canEdit || isLoading }
187+ type = "submit"
188+ >
189+ Update
190+ </ Button >
191+ </ div >
164192 </ div >
165193 </ form >
166194 </ Form >
0 commit comments