-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ui): Enable workflowtemplate submit button
Signed-off-by: instauro <instauro@proton.me>
- Loading branch information
instauro
committed
Nov 17, 2024
1 parent
6da0ff8
commit 1884c81
Showing
2 changed files
with
14 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
import YAML from 'yaml'; | ||
|
||
// Default is YAML 1.2, but Kubernetes uses YAML 1.1, which leads to subtle bugs. | ||
// See https://github.com/argoproj/argo-workflows/issues/12205#issuecomment-2111572189 | ||
const yamlVersion = '1.1'; | ||
|
||
export function parse<T>(value: string): T { | ||
if (value.startsWith('{')) { | ||
return JSON.parse(value); | ||
} | ||
return YAML.parse(value, { | ||
// Default is YAML 1.2, but Kubernetes uses YAML 1.1, which leads to subtle bugs. | ||
// See https://github.com/argoproj/argo-workflows/issues/12205#issuecomment-2111572189 | ||
version: '1.1', | ||
strict: false | ||
}) as T; | ||
return YAML.parse(value, {version: yamlVersion, strict: false}) as T; | ||
} | ||
|
||
export function stringify<T>(value: T, type: string) { | ||
return type === 'yaml' ? YAML.stringify(value, {aliasDuplicateObjects: false}) : JSON.stringify(value, null, ' '); | ||
return type === 'yaml' ? YAML.stringify(value, {aliasDuplicateObjects: false, version: yamlVersion, strict: false}) : JSON.stringify(value, null, ' '); | ||
} |