public static GitHubUpgrader Create(
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            bool dryRun,
            bool noVerify,
            LocalScalarConfig localConfig,
            out string error)
        {
            GitHubUpgrader       upgrader             = null;
            GitHubUpgraderConfig gitHubUpgraderConfig = new GitHubUpgraderConfig(tracer, localConfig);

            if (!gitHubUpgraderConfig.TryLoad(out error))
            {
                return(null);
            }

            if (gitHubUpgraderConfig.ConfigError())
            {
                gitHubUpgraderConfig.ConfigAlertMessage(out error);
                return(null);
            }

            upgrader = new GitHubUpgrader(
                ProcessHelper.GetCurrentProcessVersion(),
                tracer,
                fileSystem,
                gitHubUpgraderConfig,
                dryRun,
                noVerify);

            return(upgrader);
        }
 public static GitHubUpgrader Create(
     ITracer tracer,
     PhysicalFileSystem fileSystem,
     LocalScalarConfig scalarConfig,
     bool dryRun,
     bool noVerify,
     out string error)
 {
     return(Create(tracer, fileSystem, dryRun, noVerify, scalarConfig, out error));
 }
Beispiel #3
0
        public static bool TryCreateUpgrader(
            ITracer tracer,
            PhysicalFileSystem fileSystem,
            LocalScalarConfig scalarConfig,
            ICredentialStore credentialStore,
            bool dryRun,
            bool noVerify,
            out ProductUpgrader newUpgrader,
            out string error)
        {
            Dictionary <string, string> entries;

            if (!scalarConfig.TryGetAllConfig(out entries, out error))
            {
                newUpgrader = null;
                return(false);
            }

            bool containsUpgradeFeedUrl     = entries.ContainsKey(ScalarConstants.LocalScalarConfig.UpgradeFeedUrl);
            bool containsUpgradePackageName = entries.ContainsKey(ScalarConstants.LocalScalarConfig.UpgradeFeedPackageName);
            bool containsOrgInfoServerUrl   = entries.ContainsKey(ScalarConstants.LocalScalarConfig.OrgInfoServerUrl);

            if (!containsUpgradeFeedUrl && !containsUpgradePackageName)
            {
                error = "Custom upgrade feed is not configured";
                tracer.RelatedWarning(error);
                newUpgrader = null;
                return(false);
            }

            // We are configured for NuGet - determine if we are using OrgNuGetUpgrader or not
            if (containsOrgInfoServerUrl)
            {
                if (OrgNuGetUpgrader.TryCreate(
                        tracer,
                        fileSystem,
                        scalarConfig,
                        new HttpClient(),
                        credentialStore,
                        dryRun,
                        noVerify,
                        out OrgNuGetUpgrader orgNuGetUpgrader,
                        out error))
                {
                    // We were successfully able to load a NuGetUpgrader - use that.
                    newUpgrader = orgNuGetUpgrader;
                    return(true);
                }
                else
                {
                    tracer.RelatedError($"{nameof(TryCreateUpgrader)}: Could not create organization based upgrader. {error}");
                    newUpgrader = null;
                    return(false);
                }
            }
 public GitHubUpgraderConfig(ITracer tracer, LocalScalarConfig localScalarConfig)
 {
     this.Tracer      = tracer;
     this.LocalConfig = localScalarConfig;
 }