Skip to content

Commit

Permalink
fix: added information to create release dir on export service (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguel-crespo-fdc authored Jun 24, 2024
1 parent a0502e9 commit b6dd6b7
Showing 1 changed file with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"github.com/freiheit-com/kuberpult/pkg/db"
"github.com/freiheit-com/kuberpult/pkg/logger"
"github.com/freiheit-com/kuberpult/pkg/sorting"
time2 "github.com/freiheit-com/kuberpult/pkg/time"
billy "github.com/go-git/go-billy/v5"
"github.com/go-git/go-billy/v5/util"
"google.golang.org/grpc/codes"
Expand All @@ -44,6 +45,10 @@ import (

const (
queueFileName = "queued_version"
fieldSourceAuthor = "source_author"
fieldSourceMessage = "source_message"
fieldSourceCommitId = "source_commit_id"
fieldDisplayVersion = "display_version"
fieldCreatedAt = "created_at"
fieldCreatedByName = "created_by_name"
fieldCreatedByEmail = "created_by_email"
Expand Down Expand Up @@ -627,6 +632,32 @@ func (c *CreateApplicationVersion) Transform(
checkForInvalidCommitId(c.SourceCommitId, "Source")
checkForInvalidCommitId(c.PreviousCommit, "Previous")

if c.SourceCommitId != "" {
c.SourceCommitId = strings.ToLower(c.SourceCommitId)
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceCommitId), []byte(c.SourceCommitId), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(err)
}
}

if c.SourceAuthor != "" {
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceAuthor), []byte(c.SourceAuthor), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(err)
}
}
if c.SourceMessage != "" {
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldSourceMessage), []byte(c.SourceMessage), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(err)
}
}
if c.DisplayVersion != "" {
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldDisplayVersion), []byte(c.DisplayVersion), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(err)
}
}
if err := util.WriteFile(fs, fs.Join(releaseDir, fieldCreatedAt), []byte(time2.GetTimeNow(ctx).Format(time.RFC3339)), 0666); err != nil {
return "", GetCreateReleaseGeneralFailure(err)
}

if c.Team != "" {
//util.WriteFile has a bug where it does not truncate the old file content. If two application versions with the same
//team are deployed, team names simply get concatenated. Just remove the file beforehand.
Expand Down

0 comments on commit b6dd6b7

Please sign in to comment.