1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-08-06 14:25:31 +02:00

feat(edge/templates): introduce custom templates [EE-6208] (#10561)

This commit is contained in:
Chaim Lev-Ari 2023-11-15 10:45:07 +02:00 committed by GitHub
parent a0f583a17d
commit 68950fbb24
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
81 changed files with 2047 additions and 334 deletions

View file

@ -28,9 +28,9 @@ interface Props {
isAdditionalFilesFieldVisible?: boolean;
isForcePullVisible?: boolean;
isAuthExplanationVisible?: boolean;
errors: FormikErrors<GitFormModel>;
baseWebhookUrl: string;
webhookId: string;
errors?: FormikErrors<GitFormModel>;
baseWebhookUrl?: string;
webhookId?: string;
webhooksDocs?: string;
}
@ -88,7 +88,7 @@ export function GitForm({
{isAdditionalFilesFieldVisible && (
<AdditionalFileField
value={value.AdditionalFiles}
value={value.AdditionalFiles || []}
onChange={(value) => handleChange({ AdditionalFiles: value })}
errors={errors.AdditionalFiles}
/>
@ -97,8 +97,8 @@ export function GitForm({
{value.AutoUpdate && (
<AutoUpdateFieldset
environmentType={environmentType}
webhookId={webhookId}
baseWebhookUrl={baseWebhookUrl}
webhookId={webhookId || ''}
baseWebhookUrl={baseWebhookUrl || ''}
value={value.AutoUpdate}
onChange={(value) => handleChange({ AutoUpdate: value })}
isForcePullVisible={isForcePullVisible}
@ -165,5 +165,5 @@ export function buildGitValidationSchema(
RepositoryURLValid: boolean().default(false),
AutoUpdate: autoUpdateValidation().nullable(),
TLSSkipVerify: boolean().default(false),
}).concat(gitAuthValidation(gitCredentials, false));
}).concat(gitAuthValidation(gitCredentials, false)) as SchemaOf<GitFormModel>;
}

View file

@ -18,7 +18,7 @@ interface Props {
onChange(value: string): void;
model: RefFieldModel;
error?: string;
isUrlValid: boolean;
isUrlValid?: boolean;
stackId?: StackId;
}

View file

@ -18,7 +18,7 @@ export function RefSelector({
value: string;
stackId?: StackId;
onChange: (value: string) => void;
isUrlValid: boolean;
isUrlValid?: boolean;
}) {
const creds = getAuthentication(model);
const payload = {

View file

@ -1,5 +1,4 @@
export type AutoUpdateMechanism = 'Webhook' | 'Interval';
export interface AutoUpdateResponse {
/* Auto update interval */
Interval: string;
@ -26,6 +25,7 @@ export interface RepoConfigResponse {
ConfigFilePath: string;
Authentication?: GitAuthenticationResponse;
ConfigHash: string;
TLSSkipVerify: boolean;
}
export type AutoUpdateModel = {
@ -52,11 +52,11 @@ export type GitAuthModel = GitCredentialsModel & GitNewCredentialModel;
export interface GitFormModel extends GitAuthModel {
RepositoryURL: string;
RepositoryURLValid: boolean;
RepositoryURLValid?: boolean;
ComposeFilePathInRepository: string;
RepositoryAuthentication: boolean;
RepositoryReferenceName?: string;
AdditionalFiles: string[];
AdditionalFiles?: string[];
SaveCredential?: boolean;
NewCredentialName?: string;
@ -78,3 +78,31 @@ export interface RelativePathModel {
PerDeviceConfigsMatchType?: string;
PerDeviceConfigsGroupMatchType?: string;
}
export function toGitFormModel(response?: RepoConfigResponse): GitFormModel {
if (!response) {
return {
RepositoryURL: '',
ComposeFilePathInRepository: '',
RepositoryAuthentication: false,
TLSSkipVerify: false,
};
}
const { URL, ReferenceName, ConfigFilePath, Authentication, TLSSkipVerify } =
response;
return {
RepositoryURL: URL,
ComposeFilePathInRepository: ConfigFilePath,
RepositoryReferenceName: ReferenceName,
RepositoryAuthentication: !!(
Authentication &&
(Authentication?.GitCredentialID || Authentication?.Username)
),
RepositoryUsername: Authentication?.Username,
RepositoryPassword: Authentication?.Password,
RepositoryGitCredentialID: Authentication?.GitCredentialID,
TLSSkipVerify,
};
}