mirror of
https://github.com/portainer/portainer.git
synced 2025-07-23 15:29:42 +02:00
feat(kubernetes): edit yaml support EE-2855 (#8016)
This commit is contained in:
parent
7006c17ce4
commit
0f0513c684
11 changed files with 195 additions and 0 deletions
|
@ -1,4 +1,6 @@
|
|||
import angular from 'angular';
|
||||
import YAML from 'yaml';
|
||||
import { FeatureId } from '@/react/portainer/feature-flags/enums';
|
||||
|
||||
class KubernetesYamlInspectorController {
|
||||
/* @ngInject */
|
||||
|
@ -8,6 +10,23 @@ class KubernetesYamlInspectorController {
|
|||
this.expanded = false;
|
||||
}
|
||||
|
||||
cleanYamlUnwantedFields(yml) {
|
||||
try {
|
||||
const ymls = yml.split('---');
|
||||
const cleanYmls = ymls.map((yml) => {
|
||||
const y = YAML.parse(yml);
|
||||
if (y.metadata) {
|
||||
delete y.metadata.managedFields;
|
||||
delete y.metadata.resourceVersion;
|
||||
}
|
||||
return YAML.stringify(y);
|
||||
});
|
||||
return cleanYmls.join('---\n');
|
||||
} catch (e) {
|
||||
return yml;
|
||||
}
|
||||
}
|
||||
|
||||
copyYAML() {
|
||||
this.clipboard.copyText(this.data);
|
||||
$('#copyNotificationYAML').show().fadeOut(2500);
|
||||
|
@ -19,6 +38,11 @@ class KubernetesYamlInspectorController {
|
|||
$(selector).css({ height: height });
|
||||
this.expanded = !this.expanded;
|
||||
}
|
||||
|
||||
$onInit() {
|
||||
this.data = this.cleanYamlUnwantedFields(this.data);
|
||||
this.limitedFeature = FeatureId.K8S_EDIT_YAML;
|
||||
}
|
||||
}
|
||||
|
||||
export default KubernetesYamlInspectorController;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue