(octopus *octopusApiClient.Client, asker question.Asker, spaceID string, releaseID string, deploymentEnvironmentIDs []string)
| 779 | } |
| 780 | |
| 781 | func askDeploymentTargets(octopus *octopusApiClient.Client, asker question.Asker, spaceID string, releaseID string, deploymentEnvironmentIDs []string) ([]string, error) { |
| 782 | var results []string |
| 783 | |
| 784 | // this is what the portal does. Can we do it better? I don't know |
| 785 | for _, envID := range deploymentEnvironmentIDs { |
| 786 | preview, err := deployments.GetReleaseDeploymentPreview(octopus, spaceID, releaseID, envID, true) |
| 787 | if err != nil { |
| 788 | return nil, err |
| 789 | } |
| 790 | for _, step := range preview.StepsToExecute { |
| 791 | for _, m := range step.MachineNames { |
| 792 | if !util.SliceContains(results, m) { |
| 793 | results = append(results, m) |
| 794 | } |
| 795 | } |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | // if there are no machines, then either |
| 800 | // a) everything is server based |
| 801 | // b) machines will be provisioned dynamically |
| 802 | // c) or the deployment will fail. |
| 803 | // In all of the above cases, we can't do anything about it so the correct course of action is just skip the question |
| 804 | if len(results) > 0 { |
| 805 | var selectedDeploymentTargetNames []string |
| 806 | err := asker(&survey.MultiSelect{ |
| 807 | Message: "Deployment targets (If none selected, deploy to all)", |
| 808 | Options: results, |
| 809 | }, &selectedDeploymentTargetNames) |
| 810 | if err != nil { |
| 811 | return nil, err |
| 812 | } |
| 813 | |
| 814 | return selectedDeploymentTargetNames, nil |
| 815 | } |
| 816 | return nil, nil |
| 817 | } |
| 818 | |
| 819 | func askDeploymentPreviewVariables(octopus *octopusApiClient.Client, variablesFromCmd map[string]string, asker question.Asker, spaceID string, releaseID string, deploymentPreviewsReqests []deployments.DeploymentPreviewRequest) (map[string]string, error) { |
| 820 | previews, err := deployments.GetReleaseDeploymentPreviews(octopus, spaceID, releaseID, deploymentPreviewsReqests, true) |
no test coverage detected