1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 07:49:41 +02:00

fix(edge/templates): fix issues with git templates [EE-6357] (#10679)

This commit is contained in:
Chaim Lev-Ari 2023-12-04 08:46:44 +02:00 committed by GitHub
parent 974378c9b5
commit 2a18c9f215
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 201 additions and 116 deletions

View file

@ -0,0 +1,35 @@
import { transformGitAuthenticationViewModel } from '@/react/portainer/gitops/AuthFieldset/utils';
import { GitFormModel } from '@/react/portainer/gitops/types';
export function toGitRequest(
gitConfig: GitFormModel,
credentialId: number | undefined
): GitFormModel {
return {
...gitConfig,
...getGitAuthValues(gitConfig, credentialId),
};
}
function getGitAuthValues(
gitConfig: GitFormModel | undefined,
credentialId: number | undefined
) {
if (!credentialId) {
return gitConfig;
}
const authModel = transformGitAuthenticationViewModel({
...gitConfig,
RepositoryGitCredentialID: credentialId,
});
return authModel
? {
RepositoryAuthentication: true,
RepositoryGitCredentialID: authModel.GitCredentialID,
RepositoryPassword: authModel.Password,
RepositoryUsername: authModel.Username,
}
: {};
}