Пример #1
0
        public void GetSource_ThrowsOnInvalidSource(SourceType?type)
        {
            var source = new ServiceSource {
                Type = type
            };

            Assert.Throws <InvalidOperationException>(() => source.GetSource());
        }
Пример #2
0
        public IServiceInstaller GetLocalDirectoryInstaller(ServiceSource source)
        {
            _ = source.ValidateLocalDirectory(options => options
                                              .IncludeProperties(x => x.Type)
                                              .ThrowOnFailures());

            return(NoOpInstaller.Value);
        }
Пример #3
0
        public void GetSource_ThrowsOnNotSupportedSource()
        {
            var source = new ServiceSource {
                Type = (SourceType)69
            };

            Assert.Throws <NotSupportedException>(() => source.GetSource());
        }
Пример #4
0
        public IServiceInstaller GetGitInstaller(ServiceSource source)
        {
            var gitSource  = source.GetGitSource();
            var repository = _services.GetRequiredService <IRepositoryFunctions>();
            var progress   = _services.GetRequiredService <IProgressReporter>();

            return(new GitInstaller(gitSource.CloneUrl, repository, progress));
        }
Пример #5
0
 public Task <List <TPaymentDocumentEntity> > Get <TPaymentDocumentEntity>(ServiceTypes serviceType,
                                                                           ServiceSource serviceSource, string referenceCode)
     where TPaymentDocumentEntity : class, IPaymentDocumentEntity
 {
     return(_context.Set <TPaymentDocumentEntity>()
            .Where(i => i.ParentReferenceCode == referenceCode &&
                   i.ServiceType == serviceType &&
                   i.ServiceSource == serviceSource)
            .OrderByDescending(i => i.Date)
            .ToListAsync());
 }
Пример #6
0
        public void InferSourceType_InfersGit()
        {
            const SourceType expected = SourceType.Git;
            var source = new ServiceSource {
                CloneUrl = "url"
            };

            var inferred = source.InferSourceType();

            Assert.Equal(expected, inferred);
        }
Пример #7
0
        public static ValidationResult Validate(
            this ServiceSource source,
            Action <ValidationStrategy <ServiceSource> >?options = null)
        {
            if (!source.TryInferSourceType(out var inferred))
            {
                throw new NotSupportedException("Unable to infer source type to validate");
            }

            return(source.Validate(inferred, options));
        }
Пример #8
0
        public void InferSourceType_InfersDockerImage()
        {
            const SourceType expected = SourceType.DockerImage;
            var source = new ServiceSource {
                ImageName = "image"
            };

            var inferred = source.InferSourceType();

            Assert.Equal(expected, inferred);
        }
Пример #9
0
        public void InferSourceType_InfersDockerBuild()
        {
            const SourceType expected = SourceType.DockerBuild;
            var source = new ServiceSource {
                BuildContext = "context"
            };

            var inferred = source.InferSourceType();

            Assert.Equal(expected, inferred);
        }
Пример #10
0
        public void InferSourceType_ReturnsTypeWhenSet()
        {
            const SourceType expected = (SourceType)69;
            var source = new ServiceSource {
                Type = expected
            };

            var inferred = source.InferSourceType();

            Assert.Equal(expected, inferred);
        }
Пример #11
0
        public void TryInferSourceType_ReturnsTrueWhenSourceWasInferred()
        {
            const SourceType expected = SourceType.Git;
            var source = new ServiceSource {
                CloneUrl = "url"
            };

            var result = source.TryInferSourceType(out var inferred);

            Assert.True(result);
            Assert.Equal(expected, inferred);
        }
Пример #12
0
        public void InferSourceType_SetsTypeOnOutParameter()
        {
            const SourceType expected = SourceType.Git;
            var source = new ServiceSource {
                CloneUrl = "url"
            };

            _ = source.InferSourceType(out var updated);

            Assert.Equal(expected, updated.Type);
            Assert.NotEqual(source, updated);
        }
Пример #13
0
        public void TryGetSource_GetsInvalidSource(SourceType?type)
        {
            var source = new ServiceSource {
                Type = type
            };

            var result = source.TryGetSource(out var converted);

            Assert.False(result);
            var(serviceSource, errors) = Assert.IsType <InvalidSource>(converted);
            Assert.Equal(source, serviceSource);
            Assert.NotEmpty(errors);
        }
Пример #14
0
        public void GetSource_GetsGitSource()
        {
            var source = new ServiceSource {
                Type     = SourceType.Git,
                CloneUrl = "https://example.com/repo.git"
            };

            var result = source.GetSource();

            var git = Assert.IsType <GitSource>(result);

            Assert.Equal(source.CloneUrl, git.CloneUrl);
        }
Пример #15
0
 private static OkObjectResult AcequireToken(ServiceSource service)
 {
     if (service == ServiceSource.Amval)
     {
         string     username = "******";
         string     password = "******";
         RestClient client   = new RestClient("http://192.168.0.16:1002");
         IRestResponse <TokenString> token = GetToken(username, password, client, "/api/Login");
         client.Authenticator = new JwtAuthenticator(token.Data.token);
         return(new TestCtrl().Ok(token.Data.token));
     }
     throw new Exception();
 }
Пример #16
0
        public void GetSource_GetsDotnetToolSource()
        {
            var source = new ServiceSource {
                Type      = SourceType.DotnetTool,
                ToolName  = "tool",
                ExtraArgs = "args"
            };

            var result = source.GetSource();

            var(_, toolName, extraArgs) = Assert.IsType <DotnetToolSource>(result);
            Assert.Equal(source.ToolName, toolName);
            Assert.Equal(source.ExtraArgs, extraArgs);
        }
Пример #17
0
        public void GetSource_GetsDockerBuildSource()
        {
            var source = new ServiceSource {
                Type         = SourceType.DockerBuild,
                BuildContext = "context",
                Tag          = "tag",
            };

            var result = source.GetSource();

            var(_, buildContext, tag) = Assert.IsType <DockerBuildSource>(result);
            Assert.Equal(source.BuildContext, buildContext);
            Assert.Equal(source.Tag, tag);
        }
Пример #18
0
        public void GetSource_GetsDockerImageSource()
        {
            var source = new ServiceSource {
                Type      = SourceType.DockerImage,
                ImageName = "image",
                Tag       = "tag",
            };

            var result = source.GetSource();

            var(_, imageName, tag) = Assert.IsType <DockerImageSource>(result);
            Assert.Equal(source.ImageName, imageName);
            Assert.Equal(source.Tag, tag);
        }
Пример #19
0
            private static ValidateOptionsResult Validate(ServiceSource source)
            {
                if (source == null)
                {
                    return(ValidateOptionsResult.Skip);
                }

                return(source.Type switch {
                    SourceType.Git => ValidateGit(source),
                    SourceType.DotnetTool => ValidateDotnetTool(source),
                    SourceType.LocalDirectory => ValidateLocalDirectory(source),
                    null => ValidateOptionsResult.Fail("Source type not configured"),
                    _ => ValidateOptionsResult.Fail("Invalid source type")
                });
Пример #20
0
 public static OkObjectResult GetToken(ServiceSource Service)
 {
     if (!Tokens.ContainsKey(Service))
     {
         Tokens[Service] = new TokenData {
             Token = AcequireToken(Service)
         }
     }
     ;
     if (DateTime.Now > Tokens[Service].ExpireTime)
     {
         Tokens[Service] = new TokenData {
             Token = AcequireToken(Service), ExpireTime = DateTime.Now.Add(new TimeSpan(0, 115, 0))
         }
     }
     ;
     return(Tokens[Service].Token);
 }
Пример #21
0
        public Service(ServiceDescription description, ServiceSource source)
        {
            Description = description;

            Logs.Subscribe(entry =>
            {
                if (CachedLogs.Count > 5000)
                {
                    CachedLogs.TryDequeue(out _);
                }

                CachedLogs.Enqueue(entry);
            });

            ReplicaEvents.Subscribe(entry =>
            {
                entry.Replica.State = entry.State;
            });

            ServiceSource = source;
        }
Пример #22
0
 public ExternalServiceBuilder(string name, ServiceSource source)
     : base(name, source)
 {
 }
Пример #23
0
 public AzureFunctionServiceBuilder(string name, string path, ServiceSource source)
     : base(name, source)
 {
     FunctionPath = path;
 }
Пример #24
0
 public DotnetProjectServiceBuilder(string name, FileInfo projectFile, ServiceSource source)
     : base(name, source)
 {
     ProjectFile = projectFile;
 }
Пример #25
0
 public LaunchedServiceBuilder(string name, ServiceSource source)
     : base(name, source)
 {
 }
Пример #26
0
 public ProjectServiceBuilder(string name, ServiceSource source)
     : base(name, source)
 {
 }
Пример #27
0
 public static IServiceInstaller GetInstaller(this IServiceInstallerFactory factory, ServiceSource source)
 => source.InferSourceType() switch
 {
Пример #28
0
 public static SourceType?InferSourceType(this ServiceSource source)
 => source switch
 {
     { Type : not null } => source.Type,
Пример #29
0
 public ContainerServiceBuilder(string name, string image, ServiceSource source)
     : base(name, source)
 {
     Image = image;
 }
Пример #30
0
 public ExecutableServiceBuilder(string name, string executable, ServiceSource source)
     : base(name, source)
 {
     Executable = executable;
 }