コード例 #1
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            context.ResourceGroupDeprecationCheck(this.ResourceGroup);
            if (string.IsNullOrEmpty(Instance) &&
                string.IsNullOrEmpty(Project))
            {
                context.Logger.WriteError("Specify at least one filtering parameter.");
                return(ExitCodes.InvalidArguments);
            }
            var instance = string.IsNullOrEmpty(Instance) ? null : context.Naming.Instance(Instance, ResourceGroup);
            // HACK we pass null as the next calls do not use the Azure connection
            var  mappings = new AggregatorMappings(context.Devops, null, context.Logger, context.Naming);
            bool any      = false;

            cancellationToken.ThrowIfCancellationRequested();
            foreach (var item in await mappings.ListAsync(instance, Project))
            {
                context.Logger.WriteOutput(item);
                any = true;
            }
            if (!any)
            {
                context.Logger.WriteInfo("No rule mappings found.");
                return(ExitCodes.NotFound);
            }
            else
            {
                return(ExitCodes.Success);
            }
        }
コード例 #2
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            bool ok = DevOpsEvents.IsValidEvent(Event) || Event == "*";

            if (!ok)
            {
                context.Logger.WriteError($"Invalid event type.");
                return(ExitCodes.InvalidArguments);
            }
            var instance = context.Naming.Instance(Instance, ResourceGroup);
            var mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);
            var outcome  = await mappings.RemoveRuleEventAsync(Event, instance, Project, Rule);

            switch (outcome)
            {
            case RemoveOutcome.Succeeded:
                return(ExitCodes.Success);

            case RemoveOutcome.NotFound:
                context.Logger.WriteWarning($"No mapping(s) found for rule(s) {instance.PlainName}/{Rule}");
                return(ExitCodes.NotFound);

            case RemoveOutcome.Failed:
                return(ExitCodes.Failure);

            default:
                return(ExitCodes.Unexpected);
            }
        }
コード例 #3
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            var  mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger);
            bool ok       = DevOpsEvents.IsValidEvent(Event);

            if (!ok)
            {
                context.Logger.WriteError($"Invalid event type.");
                return(2);
            }

            var filters = new AggregatorMappings.EventFilters
            {
                AreaPath = FilterAreaPath,
                Type     = FilterType,
                Tag      = FilterTag,
                Fields   = FilterFields
            };

            var instance = new InstanceName(Instance, ResourceGroup);
            var id       = await mappings.AddAsync(Project, Event, filters, instance, Rule, cancellationToken);

            return(id.Equals(Guid.Empty) ? 1 : 0);
        }
コード例 #4
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            context.ResourceGroupDeprecationCheck(this.ResourceGroup);
            var  mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);
            bool ok       = DevOpsEvents.IsValidEvent(Event);

            if (!ok)
            {
                context.Logger.WriteError($"Invalid event type.");
                return(ExitCodes.InvalidArguments);
            }

            var filters = new EventFilters
            {
                AreaPath  = FilterAreaPath,
                Type      = FilterType,
                Tag       = FilterTag,
                Fields    = FilterFields,
                OnlyLinks = FilterOnlyLinks,
            };

            var instance = context.Naming.Instance(Instance, ResourceGroup);
            var id       = await mappings.AddAsync(Project, Event, filters, instance, Rule, ImpersonateExecution, cancellationToken);

            return(id.Equals(Guid.Empty) ? ExitCodes.Failure : ExitCodes.Success);
        }
コード例 #5
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            var  mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);
            bool ok       = DevOpsEvents.IsValidEvent(Event);

            if (!ok)
            {
                context.Logger.WriteError($"Invalid event type.");
                return(ExitCodes.InvalidArguments);
            }

            var filters = new EventFilters
            {
                AreaPath = FilterAreaPath,
                Type     = FilterType,
                Tag      = FilterTag,
                Fields   = FilterFields
            };

            var targetUrl = new Uri(TargetUrl);
            var id        = await mappings.AddFromUrlAsync(Project, Event, filters, targetUrl, Rule, ImpersonateExecution, cancellationToken);

            return(id.Equals(Guid.Empty) ? ExitCodes.Failure : ExitCodes.Success);
        }
コード例 #6
0
        internal override async Task <int> RunAsync()
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .Build();

            var  instance = new InstanceName(Instance, ResourceGroup);
            var  mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger);
            bool ok       = await mappings.RemoveRuleEventAsync(Event, instance, Project, Rule);

            return(ok ? 0 : 1);
        }
コード例 #7
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            var  instance = new InstanceName(Instance, ResourceGroup);
            var  mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger);
            bool ok       = await mappings.RemoveRuleAsync(instance, Name);

            var rules = new AggregatorRules(context.Azure, context.Logger);

            //rules.Progress += Instances_Progress;
            ok = ok && await rules.RemoveAsync(instance, Name, cancellationToken);

            return(ok ? 0 : 1);
        }
コード例 #8
0
        internal override async Task <int> RunAsync()
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithVstsLogon()
                          .Build();

            var  instance = new InstanceName(Instance);
            var  mappings = new AggregatorMappings(context.Vsts, context.Azure, context.Logger);
            bool ok       = await mappings.RemoveRuleAsync(instance, Name);

            var rules = new AggregatorRules(context.Azure, context.Logger);

            //rules.Progress += Instances_Progress;
            ok = ok && await rules.RemoveAsync(instance, Name);

            return(ok ? 0 : 1);
        }
コード例 #9
0
ファイル: MapRuleCommand.cs プロジェクト: jawn/aggregator-cli
        internal override async Task <int> RunAsync()
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithVstsLogon()
                          .Build();

            var  mappings = new AggregatorMappings(context.Vsts, context.Azure, context.Logger);
            bool ok       = mappings.ValidateEvent(Event);

            if (!ok)
            {
                context.Logger.WriteError($"Invalid event type.");
                return(2);
            }
            var instance = new InstanceName(Instance);
            var id       = await mappings.Add(Project, Event, instance, Rule);

            return(id.Equals(Guid.Empty) ? 1 : 0);
        }
コード例 #10
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            var instance = context.Naming.Instance(Name, ResourceGroup);

            if (!Mappings)
            {
                var mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);
                _ = await mappings.RemoveInstanceAsync(instance);
            }

            var instances = new AggregatorInstances(context.Azure, context.Logger, context.Naming);
            var ok        = await instances.RemoveAsync(instance, Location);

            return(ok ? 0 : 1);
        }
コード例 #11
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            bool ok = DevOpsEvents.IsValidEvent(Event);

            if (!ok)
            {
                context.Logger.WriteError($"Invalid event type.");
                return(2);
            }
            var instance = context.Naming.Instance(Instance, ResourceGroup);
            var mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);

            ok = await mappings.RemoveRuleEventAsync(Event, instance, Project, Rule);

            return(ok ? 0 : 1);
        }
コード例 #12
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            var instance = context.Naming.Instance(Instance, ResourceGroup);
            var mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);
            var outcome  = await mappings.RemoveRuleAsync(instance, Name);

            if (outcome == RemoveOutcome.Failed)
            {
                return(ExitCodes.Failure);
            }

            var  rules = new AggregatorRules(context.Azure, context.Logger);
            bool ok    = await rules.RemoveAsync(instance, Name, cancellationToken);

            return(ok ? ExitCodes.Success : ExitCodes.Failure);
        }
コード例 #13
0
        internal override async Task <int> RunAsync()
        {
            var context = await Context
                          .WithVstsLogon()
                          .Build();

            var  instance = new InstanceName(Instance);
            var  mappings = new AggregatorMappings(context.Vsts, /*HACK*/ null, context.Logger);
            bool any      = false;

            foreach (var item in await mappings.ListAsync(instance))
            {
                context.Logger.WriteOutput(
                    item,
                    (data) => $"Project {item.project} invokes rule {instance.PlainName}/{item.rule} for {item.@event}");
                any = true;
            }
            if (!any)
            {
                context.Logger.WriteInfo("No rule mappings found.");
            }
            return(0);
        }
コード例 #14
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithDevOpsLogon()
                          .BuildAsync(cancellationToken);

            var instance = string.IsNullOrEmpty(Instance) ? null : new InstanceName(Instance, ResourceGroup);
            // HACK we pass null as the next calls do not use the Azure connection
            var  mappings = new AggregatorMappings(context.Devops, null, context.Logger);
            bool any      = false;

            cancellationToken.ThrowIfCancellationRequested();
            foreach (var item in await mappings.ListAsync(instance, Project))
            {
                context.Logger.WriteOutput(item);
                any = true;
            }
            if (!any)
            {
                context.Logger.WriteInfo("No rule mappings found.");
            }
            return(0);
        }
コード例 #15
0
        internal override async Task <int> RunAsync()
        {
            var context = await Context
                          .WithAzureLogon()
                          .WithVstsLogon()
                          .Build();

            var instance = new InstanceName(Name);

            bool ok;

            if (!Mappings)
            {
                var mappings = new AggregatorMappings(context.Vsts, context.Azure, context.Logger);
                ok = await mappings.RemoveInstanceAsync(instance);
            }

            var instances = new AggregatorInstances(context.Azure, context.Logger);

            ok = await instances.Remove(instance, Location);

            return(ok ? 0 : 1);
        }
コード例 #16
0
        internal override async Task <int> RunAsync(CancellationToken cancellationToken)
        {
            var context = await Context
                          .WithDevOpsLogon()
                          .WithAzureLogon()
                          .BuildAsync(cancellationToken);

            context.ResourceGroupDeprecationCheck(this.ResourceGroup);
            if (SourceInstance == DestInstance)
            {
                context.Logger.WriteError("Source must be different from destination.");
                return(ExitCodes.InvalidArguments);
            }
            var sourceInstance = context.Naming.Instance(SourceInstance, ResourceGroup);
            var destInstance   = context.Naming.Instance(DestInstance, ResourceGroup);
            // HACK we pass null as the next calls do not use the Azure connection
            var mappings = new AggregatorMappings(context.Devops, context.Azure, context.Logger, context.Naming);

            cancellationToken.ThrowIfCancellationRequested();
            var outcome = await mappings.RemapAsync(sourceInstance, destInstance, Project, cancellationToken);

            switch (outcome)
            {
            case UpdateOutcome.Succeeded:
                return(ExitCodes.Success);

            case UpdateOutcome.NotFound:
                context.Logger.WriteWarning($"No mappings found for instance {sourceInstance.PlainName}");
                return(ExitCodes.NotFound);

            case UpdateOutcome.Failed:
                return(ExitCodes.Failure);

            default:
                return(ExitCodes.Unexpected);
            }
        }
コード例 #17
0
        internal override async Task <int> RunAsync()
        {
            var context = await Context
                          .WithDevOpsLogon()
                          .Build();

            var instance = string.IsNullOrEmpty(Instance) ? null : new InstanceName(Instance, ResourceGroup);
            // HACK we pass null as the next calls do not use the Azure connection
            var  mappings = new AggregatorMappings(context.Devops, null, context.Logger);
            bool any      = false;

            foreach (var item in await mappings.ListAsync(instance, Project))
            {
                context.Logger.WriteOutput(
                    item,
                    (data) => $"Project {item.project} invokes rule {item.rule} for {item.@event} (status {item.status})");
                any = true;
            }
            if (!any)
            {
                context.Logger.WriteInfo("No rule mappings found.");
            }
            return(0);
        }