Examples of PuppetDistribution


Examples of com.puppetlabs.geppetto.pp.pptp.PuppetDistribution

    private ImmutableMap<String, String> factmapArgumented;

    @Override
    public TargetEntry asPPTP() {
      // -- TODO: should really be called something different than "Puppet Distribution"
      PuppetDistribution facter = PPTPFactory.eINSTANCE.createPuppetDistribution();
      facter.setDescription("Facter Variables");

      facter.setLabel("Facter");
      facter.setVersion(getVersionString());

      for(Entry<String, String> entry : getRegularFactMap().entrySet()) {
        TPVariable var = PPTPFactory.eINSTANCE.createTPVariable();
        var.setName(entry.getKey());
        var.setAssignable(true);
        var.setDeprecated(false);
        var.setDocumentation(entry.getValue());
        facter.getContents().add(var);
      }
      for(Entry<String, String> entry : getArgumentedFactMap().entrySet()) {
        TPVariable var = PPTPFactory.eINSTANCE.createTPVariable();
        var.setName(entry.getKey());
        var.setAssignable(true);
        var.setDeprecated(false);
        var.setDocumentation(entry.getValue());
        var.setPattern(patternForVariable(entry.getKey()));
        facter.getContents().add(var);
      }
      return facter;
    }
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.pptp.PuppetDistribution

    if(file == null)
      throw new IllegalArgumentException("File can not be null");

    // Create a puppet distro target and parse info from the file path
    //
    PuppetDistribution puppetDistro = PPTPFactory.eINSTANCE.createPuppetDistribution();
    puppetDistro.setDescription("Puppet Distribution");
    IPath path = Path.fromOSString(file.getAbsolutePath());

    // NOTE: This is wrong, will always result in a version == "" as the version is
    // part of the "puppet" directory, not the directory puppet-x.x.x/lib/puppet that is given to
    // this function.
    //
    // String versionString = "";
    // boolean nextIsVersion = false;
    String[] segments = path.segments();
    int sc = segments.length;
    if(segments.length < 3 || !"puppet".equals(segments[sc - 1]) || !"lib".equals(segments[sc - 2]))
      throw new IllegalArgumentException("path to .../puppet/lib is not correct");
    final String distroName = segments[sc - 3];
    if(!distroName.startsWith("puppet-"))
      throw new IllegalArgumentException(
        "The ../../ of the given directory must be named on the form: 'puppet-<version>'");

    puppetDistro.setLabel("puppet");
    // 7 is the first char after 'puppet-'
    puppetDistro.setVersion(distroName.substring(7));

    // Load functions
    File parserDir = new File(file, "parser");
    File functionsDir = new File(parserDir, "functions");
    loadFunctions(puppetDistro, functionsDir);

    // Load logger functions
    for(Function f : loadLoggerFunctions(new File(file, "util/log.rb")))
      puppetDistro.getFunctions().add(f);

    // Load types
    try {
      File typesDir = new File(file, "type");
      loadTypes(puppetDistro, typesDir);
View Full Code Here

Examples of com.puppetlabs.geppetto.pp.pptp.PuppetDistribution

    if(pluginsRoot == null || !pluginsRoot.isDirectory())
      return result; // do nothing (an empty list)

    for(File pluginRoot : pluginsRoot.listFiles()) {
      String[] nameParts = extractVersionFromName(pluginRoot.getName());
      PuppetDistribution plugin = PPTPFactory.eINSTANCE.createPuppetDistribution();
      plugin.setDescription("Puppet Plugin");
      plugin.setLabel(nameParts[0]);
      plugin.setVersion(nameParts[1]);

      // load functions (lib/puppet/parser/functions/*), and types (lib/puppet/type/*)
      File lib = new File(pluginRoot, "lib/puppet");
      if(!lib.exists())
        continue; // has no content that can be handled

      // Load Functions
      File functionsDir = new File(new File(lib, "parser"), "functions");
      loadFunctions(plugin, functionsDir);

      // Load Types
      try {
        File typesDir = new File(lib, "type");
        loadTypes(plugin, typesDir);

        // load additional properties into types
        // (currently only known such construct is for 'file' type
        // this implementation does however search all subdirectories
        // for such additions
        //
        if(typesDir != null && typesDir.isDirectory())
          for(File subDir : typesDir.listFiles(dirFilter))
            loadTypeFragments(plugin, subDir);

        if(plugin.getFunctions().size() > 0 || plugin.getTypes().size() > 0)
          result.add(plugin);
      }
      catch(FileNotFoundException e) {
        // ignore, just skipping functions, types etc if not present in plugin
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.