mirror of
https://github.com/portainer/portainer.git
synced 2025-08-02 20:35:25 +02:00
feat(k8s): add the ability to deploy from a manifest URL (#5550)
This commit is contained in:
parent
1220ae7571
commit
70602cf7c8
5 changed files with 122 additions and 8 deletions
|
@ -111,6 +111,33 @@
|
|||
</web-editor-form>
|
||||
|
||||
<!-- !editor -->
|
||||
|
||||
<!-- url -->
|
||||
<div ng-show="ctrl.state.BuildMethod === ctrl.BuildMethods.URL">
|
||||
<div class="col-sm-12 form-section-title">
|
||||
URL
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<span class="col-sm-12 text-muted small">
|
||||
Indicate the URL to the manifest.
|
||||
</span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="manifest_url" class="col-sm-1 control-label text-left">URL</label>
|
||||
<div class="col-sm-11">
|
||||
<input
|
||||
type="text"
|
||||
class="form-control"
|
||||
ng-model="ctrl.formValues.ManifestURL"
|
||||
id="manifest_url"
|
||||
placeholder="https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/controllers/nginx-deployment.yaml"
|
||||
data-cy="k8sAppDeploy-urlFileUrl"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- !url -->
|
||||
|
||||
<!-- actions -->
|
||||
<div class="col-sm-12 form-section-title">
|
||||
Actions
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import angular from 'angular';
|
||||
import _ from 'lodash-es';
|
||||
import stripAnsi from 'strip-ansi';
|
||||
import PortainerError from 'Portainer/error';
|
||||
|
||||
import { KubernetesDeployManifestTypes, KubernetesDeployBuildMethods, KubernetesDeployRequestMethods } from 'Kubernetes/models/deploy';
|
||||
import { buildOption } from '@/portainer/components/box-selector';
|
||||
|
@ -25,6 +26,7 @@ class KubernetesDeployController {
|
|||
this.methodOptions = [
|
||||
buildOption('method_repo', 'fab fa-github', 'Git Repository', 'Use a git repository', KubernetesDeployBuildMethods.GIT),
|
||||
buildOption('method_editor', 'fa fa-edit', 'Web editor', 'Use our Web editor', KubernetesDeployBuildMethods.WEB_EDITOR),
|
||||
buildOption('method_url', 'fa fa-globe', 'URL', 'Specify a URL to a file', KubernetesDeployBuildMethods.URL),
|
||||
buildOption('method_template', 'fa fa-rocket', 'Custom Template', 'Use a custom template', KubernetesDeployBuildMethods.CUSTOM_TEMPLATE),
|
||||
];
|
||||
|
||||
|
@ -57,10 +59,11 @@ class KubernetesDeployController {
|
|||
this.state.BuildMethod === KubernetesDeployBuildMethods.GIT &&
|
||||
(!this.formValues.RepositoryURL ||
|
||||
!this.formValues.FilePathInRepository ||
|
||||
(this.formValues.RepositoryAuthentication && (!this.formValues.RepositoryUsername || !this.formValues.RepositoryPassword)));
|
||||
const isWebEditorInvalid = this.state.BuildMethod === KubernetesDeployBuildMethods.WEB_EDITOR && _.isEmpty(this.formValues.EditorContent);
|
||||
(this.formValues.RepositoryAuthentication && (!this.formValues.RepositoryUsername || !this.formValues.RepositoryPassword))) && _.isEmpty(this.formValues.Namespace);
|
||||
const isWebEditorInvalid = this.state.BuildMethod === KubernetesDeployBuildMethods.WEB_EDITOR && _.isEmpty(this.formValues.EditorContent) && _.isEmpty(this.formValues.Namespace);
|
||||
const isURLFormInvalid = this.state.BuildMethod == KubernetesDeployBuildMethods.WEB_EDITOR.URL && _.isEmpty(this.formValues.ManifestURL);
|
||||
|
||||
return isGitFormInvalid || isWebEditorInvalid || _.isEmpty(this.formValues.Namespace) || this.state.actionInProgress;
|
||||
return isGitFormInvalid || isWebEditorInvalid || isURLFormInvalid || this.state.actionInProgress;
|
||||
}
|
||||
|
||||
onChangeFormValues(values) {
|
||||
|
@ -111,16 +114,25 @@ class KubernetesDeployController {
|
|||
this.state.actionInProgress = true;
|
||||
|
||||
try {
|
||||
let method = KubernetesDeployRequestMethods.STRING;
|
||||
let method;
|
||||
let composeFormat = this.state.DeployType === this.ManifestDeployTypes.COMPOSE;
|
||||
|
||||
switch (this.state.BuildMethod) {
|
||||
case KubernetesDeployBuildMethods.GIT:
|
||||
case this.BuildMethods.GIT:
|
||||
method = KubernetesDeployRequestMethods.REPOSITORY;
|
||||
break;
|
||||
case KubernetesDeployBuildMethods.CUSTOM_TEMPLATE:
|
||||
composeFormat = false;
|
||||
case this.BuildMethods.WEB_EDITOR:
|
||||
method = KubernetesDeployRequestMethods.STRING;
|
||||
break;
|
||||
case KubernetesDeployBuildMethods.CUSTOM_TEMPLATE:
|
||||
method = KubernetesDeployRequestMethods.STRING;
|
||||
composeFormat = false;
|
||||
break;
|
||||
case this.BuildMethods.URL:
|
||||
method = KubernetesDeployRequestMethods.URL;
|
||||
break;
|
||||
default:
|
||||
throw new PortainerError('Unable to determine build method');
|
||||
}
|
||||
|
||||
const payload = {
|
||||
|
@ -137,8 +149,10 @@ class KubernetesDeployController {
|
|||
payload.RepositoryPassword = this.formValues.RepositoryPassword;
|
||||
}
|
||||
payload.FilePathInRepository = this.formValues.FilePathInRepository;
|
||||
} else {
|
||||
} else if (method === KubernetesDeployRequestMethods.STRING) {
|
||||
payload.StackFileContent = this.formValues.EditorContent;
|
||||
} else {
|
||||
payload.ManifestURL = this.formValues.ManifestURL;
|
||||
}
|
||||
|
||||
await this.StackService.kubernetesDeploy(this.endpointId, method, payload);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue