import { SetStateAction } from 'react'; import { FormikErrors } from 'formik'; import { GitForm } from '@/react/portainer/gitops/GitForm'; import { GitFormModel } from '@/react/portainer/gitops/types'; import { baseEdgeStackWebhookUrl } from '@/portainer/helpers/webhookHelper'; import { BoxSelector } from '@@/BoxSelector'; import { WebEditorForm } from '@@/WebEditorForm'; import { FileUploadForm } from '@@/form-components/FileUpload'; import { SwitchField } from '@@/form-components/SwitchField'; import { FormSection } from '@@/form-components/FormSection'; import { editor, git, upload, } from '@@/BoxSelector/common-options/build-methods'; const buildMethods = [editor, upload, git] as const; export interface KubeFormValues { method: 'editor' | 'upload' | 'repository' | 'template'; useManifestNamespaces: boolean; fileContent: string; file?: File; git: GitFormModel; } export function KubeManifestForm({ errors, values, setValues, webhookId, }: { errors?: FormikErrors; values: KubeFormValues; setValues: (values: SetStateAction) => void; webhookId: string; }) { const { method } = values; return ( <>
handleChange({ useManifestNamespaces: value, }) } data-cy="use-manifest-namespaces-switch" />
handleChange({ method: value })} value={method} radioName="method" slim /> {method === editor.value && ( handleChange({ fileContent: value })} yaml placeholder="Define or paste the content of your manifest file here" error={errors?.fileContent} data-cy="stack-creation-editor" > )} {method === upload.value && ( handleChange({ file })} required description="You can upload a Manifest file from your computer." data-cy="stack-creation-file-upload" > )} {method === git.value && ( setValues((values) => ({ ...values, git: { ...values.git, ...gitValues, }, })) } baseWebhookUrl={baseEdgeStackWebhookUrl()} webhookId={webhookId} /> )} ); function handleChange(newValues: Partial) { setValues((values) => ({ ...values, ...newValues, })); } } function KubeDeployDescription() { return ( <>
Templates allow deploying any kind of Kubernetes resource (Deployment, Secret, ConfigMap...)
You can get more information about Kubernetes file format in the official documentation .
); }