mirror of
https://github.com/harvester/harvester-ui-extension.git
synced 2026-02-04 23:11:44 +00:00
Fix Logging Output buffer YAML view
This commit is contained in:
parent
0fcf630daa
commit
c85a76a2d4
@ -1,6 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import CreateEditView from '@shell/mixins/create-edit-view';
|
import CreateEditView from '@shell/mixins/create-edit-view';
|
||||||
import { SECRET, LOGGING, SCHEMA } from '@shell/config/types';
|
import { LOGGING, SCHEMA } from '@shell/config/types';
|
||||||
import Tabbed from '@shell/components/Tabbed';
|
import Tabbed from '@shell/components/Tabbed';
|
||||||
import Tab from '@shell/components/Tabbed/Tab';
|
import Tab from '@shell/components/Tabbed/Tab';
|
||||||
import CruResource from '@shell/components/CruResource';
|
import CruResource from '@shell/components/CruResource';
|
||||||
@ -34,12 +34,43 @@ export default {
|
|||||||
inheritAttrs: false,
|
inheritAttrs: false,
|
||||||
|
|
||||||
async fetch() {
|
async fetch() {
|
||||||
await this.$store.dispatch('harvester/findAll', { type: SECRET });
|
const schemas = this.$store.getters['harvester/all'](SCHEMA);
|
||||||
|
|
||||||
|
const resourceSchema = this.$store.getters['harvester/byId'](SCHEMA, LOGGING.OUTPUT);
|
||||||
|
|
||||||
|
const schemaDefinition = await resourceSchema.fetchResourceFields();
|
||||||
|
|
||||||
|
let bufferYaml = '';
|
||||||
|
|
||||||
|
if ( !isEmpty(this.value.spec[this.selectedProvider]?.buffer) ) {
|
||||||
|
bufferYaml = jsyaml.dump(this.value.spec[this.selectedProvider].buffer);
|
||||||
|
} else if (schemaDefinition) {
|
||||||
|
bufferYaml = createYaml(
|
||||||
|
schemas,
|
||||||
|
`io.banzaicloud.logging.v1beta1.Output.spec.${ this.selectedProvider }.buffer`,
|
||||||
|
{},
|
||||||
|
true,
|
||||||
|
1,
|
||||||
|
'',
|
||||||
|
LOGGING.OUTPUT
|
||||||
|
);
|
||||||
|
|
||||||
|
// createYaml doesn't support passing reference types (array, map) as the first type. As such
|
||||||
|
// I'm manipulating the output since I'm not sure it's something we want to actually support
|
||||||
|
// seeing as it's really createResourceYaml and this here is a gray area between spoofed types
|
||||||
|
// and just a field within a spec.
|
||||||
|
bufferYaml = bufferYaml.substring(bufferYaml.indexOf('\n') + 1).replace(/# {2}/g, '#');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bufferYaml.length) {
|
||||||
|
this.bufferYaml = bufferYaml;
|
||||||
|
this.initialBufferYaml = bufferYaml;
|
||||||
|
|
||||||
|
this.$refs.yaml.updateValue(this.bufferYaml);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
const schemas = this.$store.getters['harvester/all'](SCHEMA);
|
|
||||||
|
|
||||||
if (this.isCreate) {
|
if (this.isCreate) {
|
||||||
this.value.metadata.namespace = 'default';
|
this.value.metadata.namespace = 'default';
|
||||||
}
|
}
|
||||||
@ -69,22 +100,9 @@ export default {
|
|||||||
|
|
||||||
const selectedProvider = selectedProviders?.[0]?.value || providers[0].value;
|
const selectedProvider = selectedProviders?.[0]?.value || providers[0].value;
|
||||||
|
|
||||||
let bufferYaml;
|
|
||||||
|
|
||||||
if ( !isEmpty(this.value.spec[selectedProvider]?.buffer) ) {
|
|
||||||
bufferYaml = jsyaml.dump(this.value.spec[selectedProvider].buffer);
|
|
||||||
} else {
|
|
||||||
bufferYaml = createYaml(schemas, `logging.banzaicloud.io.v1beta1.output.spec.${ selectedProvider }.buffer`, []);
|
|
||||||
// createYaml doesn't support passing reference types (array, map) as the first type. As such
|
|
||||||
// I'm manipulating the output since I'm not sure it's something we want to actually support
|
|
||||||
// seeing as it's really createResourceYaml and this here is a gray area between spoofed types
|
|
||||||
// and just a field within a spec.
|
|
||||||
bufferYaml = bufferYaml.substring(bufferYaml.indexOf('\n') + 1).replaceAll('# ', '#');
|
|
||||||
}
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
bufferYaml,
|
bufferYaml: '',
|
||||||
initialBufferYaml: bufferYaml,
|
initialBufferYaml: '',
|
||||||
providers,
|
providers,
|
||||||
selectedProvider,
|
selectedProvider,
|
||||||
hasMultipleProvidersSelected: selectedProviders.length > 1,
|
hasMultipleProvidersSelected: selectedProviders.length > 1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user