Exemplo n.º 1
0
        private static void SetClonedLocation(MicroService microService)
        {
            var lastDash   = microService.GitRepo.LastIndexOf('/');
            var folderName = microService.GitRepo.Substring(lastDash + 1).Replace(".git", "");

            microService.RepoFolder = folderName;
            var path = Path.Combine(RepoTempDirName, folderName);

            microService.ClonePath = path;
        }
Exemplo n.º 2
0
        private static void CloneRepo(MicroService microService)
        {
            SetClonedLocation(microService);

            var co = new CloneOptions();

            co.BranchName          = microService.GitRepoBranch;
            co.CredentialsProvider = (_url, _user, _cred) => _gitCredentials;
            try
            {
                Repository.Clone(microService.GitRepo, microService.ClonePath, co);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Exemplo n.º 3
0
        private static void ModifyMicroServiceConfig(MicroService microService, List <ConfigOverride> globalConfigOverrides)
        {
            var configFileName = $"appsettings.{microService.AspNetCoreEnvironment}.json";
            var projectPath    = Path.Combine(microService.ClonePath, microService.ProjectPath);
            var configFilePath = Path.Combine(Path.GetDirectoryName(projectPath), configFileName);

            WriteHeader($"Modifying {microService.RepoFolder} configuration ({configFileName})");

            var configFileText = File.ReadAllText(configFilePath);
            var configJObject  = JObject.Parse(configFileText);

            // Process Micro Service level overrides
            ProcessConfigOverrides(configJObject, microService.ConfigOverrides);

            // Process Global Overrides
            ProcessConfigOverrides(configJObject, globalConfigOverrides.Where(x => !microService.ConfigOverrides.Contains(x)));

            var modifiedText = JsonConvert.SerializeObject(configJObject);

            File.WriteAllText(configFilePath, modifiedText);
        }