public static PackerTemplate Combine(PackerTemplate current, PackerTemplate extraData)
        {
            if (extraData.Variables != null)
            {
                MergeVariables(current, extraData);
            }

            if (extraData.Builders != null)
            {
                MergeBuilders(current, extraData);
            }

            if (extraData.Provisioners != null)
            {
                MergeProvisioners(current, extraData);
            }

            if (extraData.Postprocessors != null)
            {
                MergePostprocessors(current, extraData);
            }


            return(current);
        }
Esempio n. 2
0
 public static PackerTemplate ReadFrom(string file)
 {
     var template = new PackerTemplate();
     dynamic jsonData = JObject.Parse(File.ReadAllText(file));
     template.Variables = jsonData.variables;
     template.Builders = jsonData.builders;
     template.Provisioners = jsonData.provisioners;
     return template;
 }
Esempio n. 3
0
        public static PackerTemplate ReadFrom(string file)
        {
            var     template = new PackerTemplate();
            dynamic jsonData = JObject.Parse(File.ReadAllText(file));

            template.Variables      = jsonData.variables;
            template.Builders       = jsonData.builders;
            template.Provisioners   = jsonData.provisioners;
            template.Postprocessors = jsonData.postprocessors;
            return(template);
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            var parameters = new Parameters();

            parameters.Process(args);

            var input      = parameters.InputFiles.Select(i => PackerTemplate.ReadFrom(i));
            var combinator = new PackerTemplateCombinator(input);

            combinator.Combine();
            var result = combinator.Output;

            result.SaveTo(parameters.OutputFile);
        }
 private static void MergeVariables(PackerTemplate current, PackerTemplate extraData)
 {
     if (current.Variables == null)
     {
         current.Variables = extraData.Variables.DeepClone();
     }
     else
     {
         foreach (var variable in extraData.Variables)
         {
             current.Variables.Add(variable);
         }
     }
 }
 private static void MergeProvisioners(PackerTemplate current, PackerTemplate extraData)
 {
     if (current.Provisioners == null)
     {
         current.Provisioners = extraData.Provisioners.DeepClone();
     }
     else
     {
         foreach (var provisioner in extraData.Provisioners)
         {
             current.Provisioners.Add(provisioner);
         }
     }
 }
 private static void MergeBuilders(PackerTemplate current, PackerTemplate extraData)
 {
     if (current.Builders == null)
     {
         current.Builders = extraData.Builders.DeepClone();
     }
     else
     {
         foreach (var builder in extraData.Builders)
         {
             current.Builders.Add(builder);
         }
     }
 }
 private static void MergeVariables(PackerTemplate current, PackerTemplate extraData)
 {
     if (current.Variables == null)
     {
         current.Variables = extraData.Variables.DeepClone();
     }
     else
     {
         foreach (var variable in extraData.Variables)
         {
             current.Variables.Add(variable);
         }
     }
 }
 private static void MergePostprocessors(PackerTemplate current, PackerTemplate extraData)
 {
     if (current.Postprocessors == null)
     {
         current.Postprocessors = extraData.Postprocessors.DeepClone();
     }
     else
     {
         foreach (var postProcessor in extraData.Postprocessors)
         {
             current.Provisioners.Add(postProcessor);
         }
     }
 }
        public static PackerTemplate Combine(PackerTemplate current, PackerTemplate extraData)
        {
            if (extraData.Variables != null)
            {
                MergeVariables(current, extraData);
            }

            if (extraData.Builders != null)
            {
                MergeBuilders(current, extraData);
            }

            if (extraData.Provisioners != null)
            {
                MergeProvisioners(current, extraData);
            }

            return current;
        }
        private static void MergeBuilders(PackerTemplate current, PackerTemplate extraData)
        {
            if (current.Builders == null)
            {
                current.Builders = extraData.Builders.DeepClone();
            }
            else
            {
                foreach (var builderRight in extraData.Builders)
                {
                    var type = builderRight.type;
                    foreach (var builderLeft in current.Builders)
                    {
                        var typeLeft = builderLeft.type;

                        if (type == typeLeft)
                        {
                            MergeInto(builderLeft, builderRight);
                        }
                    }
                }
            }
        }
Esempio n. 12
0
 public PackerTemplateCombinator(IEnumerable <PackerTemplate> input)
 {
     _input  = input.ToArray();
     _output = new PackerTemplate();
 }