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:
parent
974378c9b5
commit
2a18c9f215
16 changed files with 201 additions and 116 deletions
35
app/react/edge/templates/custom-templates/common/git.ts
Normal file
35
app/react/edge/templates/custom-templates/common/git.ts
Normal 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,
|
||||
}
|
||||
: {};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue