public void ApplySettings(IActivityMonitor m)
        {
            if (!_f.EnsureDirectory(m))
            {
                return;
            }
            var solution = _solutionDriver.GetSolution(m, allowInvalidSolution: true);

            if (solution == null)
            {
                return;
            }

            var       slnFile    = solution.Tag <SolutionFile>();
            MSProject ccbProject = slnFile.MSProjects.SingleOrDefault(p => p.ProjectName == "CodeCakeBuilder");

            if (ccbProject == null)
            {
                m.Error($"Missing CodeCakeBuilder project in '{slnFile.FilePath}'.");
                return;
            }
            // This is the baseline of CCB.
            // This should be modeled in the world xml.
            var framework    = MSProject.Savors.FindOrCreate("netcoreapp3.1");
            var dependencies = new[] {
        public void ApplySettings(IActivityMonitor m)
        {
            if (!_f.EnsureDirectory(m))
            {
                return;
            }
            var s = _driver.GetSolution(m, allowInvalidSolution: true);

            if (s == null)
            {
                return;
            }

            if (_driver.BuildRequiredSecrets.Count == 0)
            {
                m.Warn("No build secrets collected for this solution. Skipping KeyVault configuration.");
                return;
            }

            var passPhrase = _secretStore.GetSecretKey(m, SolutionDriver.CODECAKEBUILDER_SECRET_KEY, true);

            // Opens the actual current vault: if more secrets are defined we keep them.
            Dictionary <string, string> current = KeyVault.DecryptValues(TextContent, passPhrase);

            current.Clear();

            // The central CICDKeyVault is protected with the same CODECAKEBUILDER_SECRET_KEY secret.
            Dictionary <string, string> centralized = KeyVault.DecryptValues(_sharedState.CICDKeyVault, passPhrase);

            bool complete = true;

            foreach (var name in _driver.BuildRequiredSecrets.Select(x => x.SecretKeyName))
            {
                if (!centralized.TryGetValue(name, out var secret))
                {
                    m.Error($"Missing required build secret '{name}' in central CICDKeyVault. It must be added.");
                    complete = false;
                }
                else
                {
                    current[name] = secret;
                }
            }
            if (complete)
            {
                Updating?.Invoke(this, new CodeCakeBuilderKeyVaultUpdatingArgs(m, _solutionSpec, s, current));
                string result = KeyVault.EncryptValuesToString(current, passPhrase);
                CreateOrUpdate(m, result);
            }
        }
示例#3
0
        public void ApplySettings(IActivityMonitor m)
        {
            if (!_f.EnsureDirectory(m))
            {
                return;
            }
            var solution = _solutionDriver.GetSolution(m, allowInvalidSolution: true);

            if (solution == null)
            {
                return;
            }

            var       slnFile    = solution.Tag <SolutionFile>();
            MSProject ccbProject = slnFile.MSProjects.SingleOrDefault(p => p.ProjectName == "CodeCakeBuilder");

            if (ccbProject == null)
            {
                m.Error($"Missing CodeCakeBuilder project in '{slnFile.FilePath}'.");
                return;
            }
            //slnFile.Save( m );//TODO
        }