Skip to content

Commit 57ba042

Browse files
committed
feat: update logic
Signed-off-by: Chen Keinan <hen.keinan@gmail.com>
1 parent a37a27d commit 57ba042

2 files changed

Lines changed: 3 additions & 40 deletions

File tree

pkg/cmd/release/promote/promote.go

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,43 +1026,6 @@ func PrintAdvancedSummary(stdout io.Writer, options *executor.TaskOptionsPromote
10261026
`)), deployAtStr, skipStepsStr, gfmStr, pkgDownloadStr, depTargetsStr)
10271027
}
10281028

1029-
// findReleaseFromSourceEnvironment finds the release deployed to the source environment using the dashboard API
1030-
func findReleaseFromSourceEnvironment(octopus *octopusApiClient.Client, space *spaces.Space, project *projects.Project, sourceEnvironmentName string, latestSuccessful bool) (*releases.Release, error) {
1031-
// Find the source environment
1032-
sourceEnv, err := selectors.FindEnvironment(octopus, sourceEnvironmentName)
1033-
if err != nil {
1034-
return nil, err
1035-
}
1036-
1037-
// Get dashboard items for the project and source environment
1038-
dashboardItem, err := dashboard.GetDynamicDashboardItem(octopus, space.ID, dashboard.DashboardDynamicQuery{
1039-
Environments: []string{sourceEnv.ID},
1040-
Projects: []string{project.ID},
1041-
IncludePrevious: latestSuccessful,
1042-
})
1043-
if err != nil {
1044-
return nil, err
1045-
}
1046-
1047-
if len(dashboardItem.Items) == 0 {
1048-
return nil, fmt.Errorf("no releases found in source environment '%s'", sourceEnvironmentName)
1049-
}
1050-
1051-
// Sort by release version (ascending) to get the latest
1052-
sort.Slice(dashboardItem.Items, func(i, j int) bool {
1053-
return dashboardItem.Items[i].ReleaseVersion < dashboardItem.Items[j].ReleaseVersion
1054-
})
1055-
1056-
// Get the latest (last) release
1057-
latestReleaseVersion := dashboardItem.Items[len(dashboardItem.Items)-1].ReleaseVersion
1058-
selectedRelease, err := releases.GetReleaseInProject(octopus, space.ID, project.ID, latestReleaseVersion)
1059-
if err != nil {
1060-
return nil, err
1061-
}
1062-
1063-
return selectedRelease, nil
1064-
}
1065-
10661029
// determineIsTenanted returns true if we are going to do a tenanted deployment, false if untenanted
10671030
// NOTE: Tenant can be disabled or forced. In these cases we know what to do.
10681031
// The middle case is "allowed, but not forced", in which case we don't know ahead of time what to do WRT tenants,

pkg/executor/release.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package executor
33
import (
44
"errors"
55
"fmt"
6-
76
"strconv"
87
"strings"
98

@@ -171,6 +170,7 @@ func releaseDeploy(octopus *client.Client, space *spaces.Space, input any) error
171170
return fmt.Errorf("'%s' is not a valid value for guided failure mode", params.GuidedFailureMode)
172171
}
173172
}
173+
174174
// If either tenants or tenantTags are specified then it must be a tenanted deployment.
175175
// Otherwise it must be untenanted.
176176
// If the server has a tenanted deployment and both TenantNames+Tags are empty, the request fails,
@@ -218,8 +218,8 @@ func releaseDeploy(octopus *client.Client, space *spaces.Space, input any) error
218218

219219
type TaskOptionsPromoteRelease struct {
220220
TaskOptionsDeployRelease
221-
SourceEnvironment string // the source environment to promote from
222-
LatestSuccessful bool
221+
SourceEnvironment string // the source environment to promote from
222+
LatestSuccessful bool
223223
// After we send the request to the server, the response is stored here
224224
Response *deployments.CreateDeploymentResponseV1
225225
}

0 commit comments

Comments
 (0)