private void RunScript(Stream scriptSource)
        {
            var script = _scriptDeserializer.GetDeserializedScript(scriptSource);

            var scriptContext = new ScriptContext(script);

            foreach (var update in script.Update)
            {
                var updateContext = new UpdateContext(update, scriptContext);

                foreach (var step in update.UpdateStep)
                {
                    var stepContext = new UpdateStepContext(step, updateContext);

                    var preconditions = ResolvePreconditions(stepContext, step, script);
                    var context       = new UpdateStepContextWithPreconditions(stepContext, preconditions);
                    if (!_preconditionService.IsMet(context))
                    {
                        _logger.LogInformation($"{context} precondition resulted in skipping the step");
                        continue;
                    }


                    _updateStepService.Execute(context);
                }
            }
        }
        private IEnumerable <PreconditionType> ResolvePreconditions(UpdateStepContext stepContext, UpdateStepBaseType step,
                                                                    Updates script)
        {
            var preconditions = step.Preconditions;

            if (preconditions == null || preconditions.Length == 0)
            {
                _logger.LogInformation("{0} doesn't have precondition - using script defaults", stepContext);
                preconditions = script.DefaultPreconditions;
            }

            if (preconditions == null)
            {
                throw new InvalidOperationException($"Update script for {stepContext} doesn't have default preconditions specified");
            }

            return(preconditions);
        }