You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

cf-compose-model

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cf-compose-model

[![Codefresh build status]( https://g.codefresh.io/api/badges/build?repoOwner=codefresh-io&repoName=cf-compose-model&branch=master&pipelineName=cf-compose-model&accountName=codefresh-inc&type=cf-2)]( https://g.codefresh.io/repositories/codefresh-io/cf-com


Version published
Weekly downloads
171
decreased by-18.18%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Codefresh Compose Model

Codefresh build status

Codefresh introducing CF-Compose-Model, our model for all compositions. Using our compose model you can:

  • Verify that your composition is valid on Codefresh.io

  • Convert Composition from one type to another

Example

More examples can be found here:

  • node example.js to run the basic examples we provided

'use strict';

const Promise      = require('bluebird');
const path         = require('path');
const CM           = require('cf-compose-model');
const ComposeModel = CM.ComposeModel;

    const path = './lib/model/tests/ComposeV1/ex1.yaml';

    console.log(`\n#############################\nExample load yaml from location ${locapathtion}\n#############################`);

    let location = path.resolve(__dirname, path);
    return ComposeModel.load(location)
        .then(compose => {
            return compose.getWarnings();
        })
        .then((warnings) => {
            console.log('\n===\nWarnings\n===');
            return Promise.map(warnings, (warning) => {
                console.log(warning.format());
            });

        })
        .then(() => {
            return cm.translate().toYaml();
        })
        .then((translated) => {
            console.log('\n===\nOutput\n===');
            console.log(translated);
        });

Installation

  • run npm install cf-compose-mode --save OR
  • clone this repo and npm isntall, yarn also supported

Api reference

Test

  • npm run unit_test
  • npm run e2e_test using the flow.yaml

Road-map:

  • Support Compose V1
  • Support Compose V2
  • Support Compose V3
  • CLI tool - started!
  • ES5 module

Documantation

Become familiar with ComposeModel structure

ComposeModel holds inside 3 basic objects - each one of the objects holds in instances of CFNode class:

  • services
  • networks
  • volumes

More objects that ComposeModel holds:

  • originalYaml - the yaml file ComposeModel parsed. Optional
  • parser - the original parser class that used to parse the yaml. Optional
  • defaultTranslator - the translator that will be used if no other translator will be passed in translate method. The defaultTranslator exist only if the ComposeModel parsed some yaml and a translator exist for it.
  • policy - set of instructions that tell ComposeModel what are to possible warnings may each CFNode and CFLeaf have. The default value is the policy of the shared plan.

Methods of ComposeModel:

  • static:
    • parse(yaml) - Parse an yaml, search for a parser for the yaml file, parse it and return ComposeModel instance. Throw an error `parser not found' if there is no parser.
    • load(path) - Loads the yaml and parse it the same way the parse does.
  • public:
    • getAllServices() - return an object with all the services
    • getAllNetworks() - return an object with all the networks
    • getAllVolumes() - return an object with all the volumes
    • setPolicy(policy) - set the policy. Policies can be found in lib/model/policies.
    • addService(service) - add new service to the model
    • addNetwork(network) - add new network to the model
    • addVolume(volume) - add new volume to the model
    • translate(translator) - translate the model to yaml file, if translator not supplied the model will try to use the default translator if exist.
    • getWarnings() - return an array with all the warnings related to the model and the policy
    • fixWarnings(onlyAutoFix) - fix all the warnings on the model related to the policy. If onlyAutoFix flag is set then only warnings with this flag will be fixed.

FAQs

Package last updated on 29 Aug 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc