Skip to content

Commit

Permalink
Allow existing EKS-A releases to be updated (aws#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
abhay-krishna authored Sep 21, 2021
1 parent c881b41 commit c67c271
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
3 changes: 2 additions & 1 deletion release/cmd/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ var releaseCmd = &cobra.Command{
os.Exit(1)
}

release.Spec.Releases = append(release.Spec.Releases, eksARelease)
currentReleases := pkg.EksAReleases(release.Spec.Releases)
release.Spec.Releases = currentReleases.AppendOrUpdateRelease(eksARelease)

output, err := yaml.Marshal(release)
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions release/pkg/prepare_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ import (
"github.com/aws/aws-sdk-go/service/ecrpublic"
"github.com/aws/aws-sdk-go/service/s3"
"github.com/aws/aws-sdk-go/service/s3/s3manager"
anywherev1alpha1 "github.com/aws/eks-anywhere/release/api/v1alpha1"
docker "github.com/fsouza/go-dockerclient"
"github.com/go-git/go-git/v5"
"github.com/pkg/errors"
)

type EksAReleases []anywherev1alpha1.EksARelease

func (r *ReleaseConfig) SetRepoHeads() error {
// Get the repos from env var
cliRepoUrl := os.Getenv("CLI_REPO_URL")
Expand Down Expand Up @@ -426,3 +429,16 @@ func UpdateImageDigests(releaseClients *ReleaseClients, r *ReleaseConfig, eksArt

return imageDigests, nil
}

func (releases EksAReleases) AppendOrUpdateRelease(r anywherev1alpha1.EksARelease) EksAReleases {
for i, release := range releases {
if release.Version == r.Version {
releases[i] = r
fmt.Println("Updating existing release in releases manifest")
return releases
}
}
releases = append(releases, r)
fmt.Println("Adding new release to releases manifest")
return releases
}

0 comments on commit c67c271

Please sign in to comment.