FindDeployableEnvironmentIDs returns an array of environment IDs that we can deploy to, the preferred 'next' environment, and an error
(octopus *octopusApiClient.Client, release *releases.Release)
| 906 | // FindDeployableEnvironmentIDs returns an array of environment IDs that we can deploy to, |
| 907 | // the preferred 'next' environment, and an error |
| 908 | func FindDeployableEnvironmentIDs(octopus *octopusApiClient.Client, release *releases.Release) ([]string, string, error) { |
| 909 | var result []string |
| 910 | // to determine the list of viable environments we need to hit /api/projects/{ID}/progression. |
| 911 | releaseProgression, err := octopus.Deployments.GetProgression(release) |
| 912 | if err != nil { |
| 913 | return nil, "", err |
| 914 | } |
| 915 | for _, phase := range releaseProgression.Phases { |
| 916 | if phase.Progress == releases.PhaseProgressPending { |
| 917 | continue // we can't deploy to this phase yet |
| 918 | } |
| 919 | for _, id := range phase.AutomaticDeploymentTargets { |
| 920 | if !util.SliceContains(result, id) { |
| 921 | result = append(result, id) |
| 922 | } |
| 923 | } |
| 924 | for _, id := range phase.OptionalDeploymentTargets { |
| 925 | if !util.SliceContains(result, id) { |
| 926 | result = append(result, id) |
| 927 | } |
| 928 | } |
| 929 | } |
| 930 | nextDeployEnvID := "" |
| 931 | if len(releaseProgression.NextDeployments) > 0 { |
| 932 | nextDeployEnvID = releaseProgression.NextDeployments[0] |
| 933 | } |
| 934 | |
| 935 | return result, nextDeployEnvID, nil |
| 936 | } |
| 937 | |
| 938 | func loadEnvironmentsForDeploy(octopus *octopusApiClient.Client, deployableEnvironmentIDs []string, nextDeployEnvironmentID string) ([]*environments.Environment, string, error) { |
| 939 | envResources, err := octopus.Environments.Get(environments.EnvironmentsQuery{IDs: deployableEnvironmentIDs}) |
no test coverage detected