diff --git a/app/kubernetes/views/deploy/deploy.html b/app/kubernetes/views/deploy/deploy.html index 85a8eb8409..b5b057c415 100644 --- a/app/kubernetes/views/deploy/deploy.html +++ b/app/kubernetes/views/deploy/deploy.html @@ -85,6 +85,7 @@ is-force-pull-visible="false" is-additional-files-field-visible="true" is-auth-explanation-visible="true" + is-source-selection-visible="true" deploy-method="{{ ctrl.state.DeployType === ctrl.ManifestDeployTypes.COMPOSE ? 'compose' : 'manifest' }}" base-webhook-url="{{ ctrl.state.baseWebhookUrl }}" webhook-id="{{ ctrl.state.webhookId }}" diff --git a/app/kubernetes/views/deploy/deployController.js b/app/kubernetes/views/deploy/deployController.js index 4b1745a62e..96d989984c 100644 --- a/app/kubernetes/views/deploy/deployController.js +++ b/app/kubernetes/views/deploy/deployController.js @@ -68,6 +68,7 @@ class KubernetesDeployController { this.formValues = { StackName: '', + SourceId: undefined, RepositoryURL: '', RepositoryReferenceName: '', RepositoryAuthentication: false, @@ -308,13 +309,17 @@ class KubernetesDeployController { }; if (method === KubernetesDeployRequestMethods.REPOSITORY) { - payload.TLSSkipVerify = this.formValues.TLSSkipVerify; - payload.RepositoryURL = this.formValues.RepositoryURL; payload.RepositoryReferenceName = this.formValues.RepositoryReferenceName; - payload.RepositoryAuthentication = this.formValues.RepositoryAuthentication ? true : false; - if (payload.RepositoryAuthentication) { - payload.RepositoryUsername = this.formValues.RepositoryUsername; - payload.RepositoryPassword = this.formValues.RepositoryPassword; + if (this.formValues.SourceId) { + payload.SourceId = this.formValues.SourceId; + } else { + payload.TLSSkipVerify = this.formValues.TLSSkipVerify; + payload.RepositoryURL = this.formValues.RepositoryURL; + payload.RepositoryAuthentication = this.formValues.RepositoryAuthentication ? true : false; + if (payload.RepositoryAuthentication) { + payload.RepositoryUsername = this.formValues.RepositoryUsername; + payload.RepositoryPassword = this.formValues.RepositoryPassword; + } } payload.ManifestFile = this.formValues.ComposeFilePathInRepository; payload.AdditionalFiles = this.formValues.AdditionalFiles; diff --git a/app/portainer/components/forms/git-form/git-form.controller.ts b/app/portainer/components/forms/git-form/git-form.controller.ts index 195a6cbc0b..789f82207d 100644 --- a/app/portainer/components/forms/git-form/git-form.controller.ts +++ b/app/portainer/components/forms/git-form/git-form.controller.ts @@ -19,6 +19,8 @@ export default class GitFormController { deployMethod?: DeployMethod; + isSourceSelectionVisible?: boolean; + /* @ngInject */ constructor($async: (fn: () => Promise) => Promise) { this.$async = $async; @@ -56,7 +58,8 @@ export default class GitFormController { this.errors = await validateGitForm( value, isCreatedFromCustomTemplate, - this.deployMethod + this.deployMethod, + this.isSourceSelectionVisible ); if (this.errors && Object.keys(this.errors).length > 0) { this.gitForm?.$setValidity('gitForm', false, this.gitForm); diff --git a/app/portainer/components/forms/git-form/git-form.ts b/app/portainer/components/forms/git-form/git-form.ts index 699d204cee..90247f2940 100644 --- a/app/portainer/components/forms/git-form/git-form.ts +++ b/app/portainer/components/forms/git-form/git-form.ts @@ -5,7 +5,7 @@ import controller from './git-form.controller'; export const gitForm: IComponentOptions = { template: ` - `, @@ -34,6 +35,7 @@ export const gitForm: IComponentOptions = { webhookId: '@', webhooksDocs: '@', createdFromCustomTemplateId: '<', + isSourceSelectionVisible: '<', }, controller, }; diff --git a/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationDetailsWidget.tsx b/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationDetailsWidget.tsx index 50a11ffdf4..19fb38a291 100644 --- a/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationDetailsWidget.tsx +++ b/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ApplicationDetailsWidget.tsx @@ -76,6 +76,7 @@ export function ApplicationDetailsWidget() { gitConfig={stack.GitConfig} currentDeploymentInfo={stack.CurrentDeploymentInfo} stackType="kubernetes" + sourceId={stack.GitSourceId} /> )} diff --git a/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ButtonsLine.tsx b/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ButtonsLine.tsx index 086f6a10ba..fd16877f1e 100644 --- a/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ButtonsLine.tsx +++ b/app/react/kubernetes/applications/DetailsView/ApplicationDetailsWidget/ButtonsLine.tsx @@ -41,7 +41,7 @@ export function ButtonsLine({ }, { enabled: - stack && + !!stack && (!stack.GitConfig || !isGitConfigDiverged(stack.GitConfig, stack.CurrentDeploymentInfo)), } diff --git a/app/react/portainer/gitops/GitForm.tsx b/app/react/portainer/gitops/GitForm.tsx index 67157cabae..8f4f14ac04 100644 --- a/app/react/portainer/gitops/GitForm.tsx +++ b/app/react/portainer/gitops/GitForm.tsx @@ -175,10 +175,17 @@ export function GitForm({ export async function validateGitForm( formValues: GitFormModel, isCreatedFromCustomTemplate: boolean, - deployMethod: DeployMethod = 'compose' + deployMethod: DeployMethod = 'compose', + isSourceSelection = false ) { return validateForm( - () => buildGitValidationSchema(isCreatedFromCustomTemplate, deployMethod), + () => + buildGitValidationSchema( + isCreatedFromCustomTemplate, + deployMethod, + false, + isSourceSelection + ), formValues ); }