How to use the js-yaml.loadAll function in js-yaml

To help you get started, we’ve selected a few js-yaml examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github KubeOperator / kubeapps-plus / src / components / applications / apps.vue View on Github external
this.catalog.description = res.data.data.chart.metadata.description;
        this.catalog.icon = res.data.data.chart.metadata.icon;
        this.catalog.appv = res.data.data.chart.metadata.appVersion;
        this.catalog.releaseName = res.data.data.chart.metadata.name;
        this.catalog.chartv = res.data.data.chart.metadata.version;
        this.note = res.data.data.info.status.notes;
        this.aceEditor = ace.edit(this.$refs.ace, {
          maxLines: 30, // 最大行数,超过会自动出现滚动条
          minLines: 10, // 最小行数,还未到最大行数时,编辑器会自动伸缩大小
          fontSize: 14, // 编辑器内字体大小
          theme: this.themePath, // 默认设置的主题
          mode: this.modePath, // 默认设置的语言模式
          value: this.valuesYaml ? this.valuesYaml : "",
          tabSize: 4 // 制表符设置为 4 个空格大小
        });
        jsyaml.loadAll(res.data.data.manifest, function(doc) {
          try {
            if (doc.kind == "Secret") {
              _this.secrets.push({
                name: doc.metadata.name,
                type: doc.type
                // key: Base64.decode(doc.data["tls.crt"]),
                // crt: Base64.decode(doc.data["tls.key"])
              });
            } else if (doc.kind != "Deployment") {
              _this.resources.push({ name: doc.metadata.name, kind: doc.kind });
            } else if (doc.kind == "Deployment") {
              _this.services.push({ name: doc.metadata.name, kind: doc.kind });
            }
          } catch (error) {
            // console.log(error)
          }
github awwright / magnode / t / runner.js View on Github external
function runFile(filename, callback){
	console.log('Run file: '+filename);
	// 1. Arrange
	// Connect to a database
	var dbName = 'magnode-test-' + new Date().valueOf();
	var requests = [];
	var requestNames = {};
	var defaultRequest = {};
	var fileFailures = 0;
	yaml.loadAll(fs.readFileSync(filename, 'utf-8').replace(/\t/g, '    '), function(v){ requests.push(v); });
	var db, child;
	var running = true;
	mongodb.connect('mongodb://localhost/'+dbName, function(err, _db){
		if(err) throw err;
		db = _db;
		runFileDb();
	});

	function runFileDb(){
		// Verify the database does not exist (is not populated with any data)
		db.collections(function(err, names){
			if(err) throw err;
			if(names.length) throw new Error('Database already exists!');
			//var data = fs.readFileSync(__dirname+'/../setup/mongodb/schema/Schema.json'), 'utf-8');
			var importList = [
				{file:__dirname+'/../setup/mongodb/schema/Schema.json', collection:'schema'}
github spinnaker / deck / app / scripts / modules / core / src / yamlEditor / yamlEditorUtils.ts View on Github external
export function yamlStringToDocuments(yamlString: string): any[] {
  try {
    const yamlDocuments = loadAll(yamlString, null);
    if (Array.isArray(head(yamlDocuments))) {
      // Multi-doc entered as list of maps
      return head(yamlDocuments);
    }
    return yamlDocuments;
  } catch (e) {
    return null;
  }
}
github kubeapps / kubeapps / dashboard / src / components / AppView / AppView.tsx View on Github external
public componentDidUpdate(prevProps: IAppViewProps) {
    const { releaseName, getAppWithUpdateInfo, namespace, error, app } = this.props;
    if (prevProps.namespace !== namespace) {
      getAppWithUpdateInfo(releaseName, namespace);
      return;
    }
    if (error || !app) {
      return;
    }

    // TODO(prydonius): Okay to use non-safe load here since we assume the
    // manifest is pre-parsed by Helm and Kubernetes. Look into switching back
    // to safeLoadAll once https://github.com/nodeca/js-yaml/issues/456 is
    // resolved.
    let manifest: IResource[] = yaml.loadAll(app.manifest, undefined, { json: true });
    // Filter out elements in the manifest that does not comply
    // with { kind: foo }
    manifest = manifest.filter(r => r && r.kind);
    if (!isEqual(manifest, this.state.manifest)) {
      this.setState({ manifest });
    } else {
      return;
    }

    // Iterate over the current manifest to populate the initial state
    this.setState(this.parseResources(manifest, app.namespace));
  }
github spinnaker / deck / app / scripts / modules / core / src / yamlEditor / YamlEditor.tsx View on Github external
public calculateErrors = (value: string): Annotation[] => {
    try {
      loadAll(value, null);
    } catch (e) {
      if (e instanceof YAMLException) {
        const mark = (e as any).mark as IMark;
        // Ace Editor doesn't render errors for YAML, so
        // we have to do it ourselves.
        return [
          {
            column: mark.column,
            row: mark.line,
            type: 'error',
            text: e.message,
          },
        ];
      }
    }
    return [];
github elastic / elasticsearch-js / scripts / generate / yaml_tests.js View on Github external
fs.readdirSync(dir).forEach(function (filename) {
        var filePath = path.join(dir, filename);
        var stat = fs.statSync(filePath);
        if (stat.isDirectory()) {
          readDirectories(filePath);
        } else if (filename.match(/\.yaml$/)) {
          var file = tests[path.relative(testDir, filePath)] = [];
          jsYaml.loadAll(fs.readFileSync(filePath, 'utf8'), function (doc) {
            file.push(doc);
          });
        }
      });
    }
github elastic / elasticsearch-js / scripts / generate / yaml_tests / index.js View on Github external
.on('entry', function (entry) {
      var filename = path.relative('test', entry.path);
      var file = tests[filename] = [];
      jsYaml.loadAll(entry.data, function (doc) {
        file.push(doc);
      });
    })
    .on('end', function () {