Ejemplo n.º 1
0
        public async Task WaitForDeploymentToComplete(
            IReadOnlyList <DeploymentResource> resources,
            ProjectResource project,
            ReleaseResource release,
            bool showProgress,
            bool noRawLog,
            string rawLogFile,
            bool cancelOnTimeout,
            TimeSpan deploymentStatusCheckSleepCycle,
            TimeSpan deploymentTimeout)
        {
            async Task GuidedFailureWarning(IExecutionResource guidedFailureDeployment)
            {
                var environment = await repository.Environments.Get(((DeploymentResource)guidedFailureDeployment).Link("Environment")).ConfigureAwait(false);

                commandOutputProvider.Warning("  - {Environment:l}: {Url:l}",
                                              environment.Name,
                                              GetPortalUrl(
                                                  $"/app#/projects/{project.Slug}/releases/{release.Version}/deployments/{guidedFailureDeployment.Id}"));
            }

            await WaitForExecutionToComplete(
                resources,
                showProgress,
                noRawLog,
                rawLogFile,
                cancelOnTimeout,
                deploymentStatusCheckSleepCycle,
                deploymentTimeout,
                GuidedFailureWarning,
                "deployment");
        }
Ejemplo n.º 2
0
    public virtual void Install(bool dryRun)
    {
        commandOutputProvider.Information($"Installing scripts in {ProfileLocation}");
        var tempOutput = new StringBuilder();

        if (fileSystem.FileExists(ProfileLocation))
        {
            var profileText = fileSystem.ReadAllText(ProfileLocation);
            if (!dryRun)
            {
                if (profileText.Contains(AllShellsPrefix) || profileText.Contains(AllShellsSuffix) || profileText.Contains(ProfileScript))
                {
                    if (!profileText.Contains(ProfileScript))
                    {
                        var message =
                            $"Looks like command line completion is already installed, but points to a different executable.{Environment.NewLine}" +
                            $"Please manually edit the file {ProfileLocation} to remove the existing auto complete script and then re-install.";
                        throw new CommandException(message);
                    }

                    commandOutputProvider.Information("Looks like command line completion is already installed. Nothing to do.");
                    return;
                }

                var backupPath = ProfileLocation + ".orig";
                commandOutputProvider.Information($"Backing up the existing profile to {backupPath}");
                fileSystem.CopyFile(ProfileLocation, backupPath);
            }

            commandOutputProvider.Information($"Updating profile at {ProfileLocation}");
            tempOutput.AppendLine(profileText);
        }
        else
        {
            commandOutputProvider.Information($"Creating profile at {ProfileLocation}");
            fileSystem.EnsureDirectoryExists(Path.GetDirectoryName(ProfileLocation));
        }

        tempOutput.AppendLine(AllShellsPrefix);
        tempOutput.AppendLine(ProfileScript);
        tempOutput.AppendLine(AllShellsSuffix);

        if (dryRun)
        {
            commandOutputProvider.Warning("Preview of script changes: ");
            commandOutputProvider.Information(tempOutput.ToString());
            commandOutputProvider.Warning("Preview of script changes finished. ");
        }
        else
        {
            fileSystem.OverwriteFile(ProfileLocation, tempOutput.ToString());
            commandOutputProvider.Warning("All Done! Please reload your shell or dot source your profile to get started! Use the <tab> key to autocomplete.");
        }
    }
        void ValidateOptions()
        {
            if (IsHealthStatusPendingDeprication)
            {
                if (statuses.Any())
                {
                    commandOutputProvider.Warning("The `--status` parameter will be deprecated in Octopus Deploy 4.0. You may want to execute this command with the `--health-status=` parameter instead.");
                }
            }
            else
            {
                if (healthStatuses.Any())
                {
                    throw new CommandException("The `--health-status` parameter is only available on Octopus Server instances from 3.4.0 onwards.");
                }
            }

            var missingStatuses = statuses.Where(s => !StatusNames.Contains(s, StringComparer.OrdinalIgnoreCase)).ToList();

            if (missingStatuses.Any())
            {
                throw new CommandException(
                          $"The following status value is unknown: {string.Join(", ", missingStatuses)}. Please choose from {string.Join(", ", StatusNames)}");
            }


            var missingHealthStatuses = healthStatuses.Where(s => !HealthStatusNames.Contains(s, StringComparer.OrdinalIgnoreCase)).ToList();

            if (missingHealthStatuses.Any())
            {
                throw new CommandException(
                          $"The following health status value is unknown: {string.Join(", ", missingHealthStatuses)}. Please choose from {string.Join(", ", HealthStatusNames)}");
            }
        }
Ejemplo n.º 4
0
 void ValidateOptions()
 {
     if (IsHealthStatusPendingDeprication)
     {
         if (statuses.Any())
         {
             commandOutputProvider.Warning("The `--status` parameter will be deprecated in Octopus Deploy 4.0. You may want to execute this command with the `--health-status=` parameter instead.");
         }
     }
     else
     {
         if (healthStatuses.Any())
         {
             throw new CommandException("The `--health-status` parameter is only available on Octopus Server instances from 3.4.0 onwards.");
         }
     }
 }