From 42f2db66e93846aebb53056b59751c0c9a938451 Mon Sep 17 00:00:00 2001 From: Henrik Andersson Date: Wed, 18 Sep 2024 17:10:14 -0700 Subject: [PATCH] fix: include release notes and assembled date in json output after creating a release (#410) * fix: include release notes and assembled date in json output after creating a release * chore: refactor to appease tests --- pkg/cmd/release/create/create.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/release/create/create.go b/pkg/cmd/release/create/create.go index cca4f0af..ba62a582 100644 --- a/pkg/cmd/release/create/create.go +++ b/pkg/cmd/release/create/create.go @@ -9,6 +9,7 @@ import ( "regexp" "sort" "strings" + "time" "github.com/OctopusDeploy/cli/pkg/apiclient" @@ -288,12 +289,16 @@ func createRun(cmd *cobra.Command, f factory.Factory, flags *CreateFlags) error } if options.Response != nil { - printReleaseVersion := func(releaseVersion string, channel *channels.Channel) { + printReleaseVersion := func(releaseVersion string, assembled time.Time, releaseNotes string, channel *channels.Channel) { switch outputFormat { case constants.OutputFormatBasic: cmd.Printf("%s\n", releaseVersion) case constants.OutputFormatJson: - v := &list.ReleaseViewModel{Version: releaseVersion} + v := &list.ReleaseViewModel{ + Version: releaseVersion, + Assembled: assembled, + ReleaseNotes: releaseNotes, + } if channel != nil { v.Channel = channel.Name } @@ -317,14 +322,14 @@ func createRun(cmd *cobra.Command, f factory.Factory, flags *CreateFlags) error newlyCreatedRelease, lookupErr := octopus.Releases.GetByID(options.Response.ReleaseID) if lookupErr != nil { cmd.PrintErrf("Warning: cannot fetch release details: %v\n", lookupErr) - printReleaseVersion(options.Response.ReleaseVersion, nil) + printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, newlyCreatedRelease.ReleaseNotes, nil) } else { releaseChan, lookupErr := octopus.Channels.GetByID(newlyCreatedRelease.ChannelID) if lookupErr != nil { cmd.PrintErrf("Warning: cannot fetch release channel details: %v\n", lookupErr) - printReleaseVersion(options.Response.ReleaseVersion, nil) + printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, newlyCreatedRelease.ReleaseNotes, nil) } else { - printReleaseVersion(options.Response.ReleaseVersion, releaseChan) + printReleaseVersion(options.Response.ReleaseVersion, newlyCreatedRelease.Assembled, newlyCreatedRelease.ReleaseNotes, releaseChan) } }