From 76c62643a5140cb9fbeb300742d58d438b5fa46f Mon Sep 17 00:00:00 2001 From: Danny Eiselt Date: Thu, 19 Sep 2024 17:34:30 +0200 Subject: [PATCH 1/2] added: gitignore IDE specific files Signed-off-by: Danny Eiselt --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0d642bd1..b5713230 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ releases/ .release .envrc dist/ +.idea/ \ No newline at end of file From bb6f55696fc40c7fea315bb82d80e319e56456cf Mon Sep 17 00:00:00 2001 From: Danny Eiselt Date: Thu, 19 Sep 2024 17:35:07 +0200 Subject: [PATCH 2/2] added: check if hash release exists in OCI and reject push Signed-off-by: Danny Eiselt --- pkg/cmd/publish.go | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pkg/cmd/publish.go b/pkg/cmd/publish.go index 7b635921..9b511c64 100644 --- a/pkg/cmd/publish.go +++ b/pkg/cmd/publish.go @@ -347,6 +347,16 @@ func (p *PublishOptions) generateRelease(ctx context.Context) error { func pushReleaseAssets(ctx context.Context, pusher assetsclient.Pusher, clusterStackReleasePath, releaseName string, annotations map[string]string) error { releaseAssets := []assetsclient.ReleaseAsset{} + ociclient, err := oci.NewClient() + if err != nil { + return fmt.Errorf("error creating oci client: %w", err) + } + + if ociclient.FoundRelease(ctx, releaseName) { + fmt.Printf("release tag \"%s\" found in oci registry. aborting push\n", releaseName) + return nil + } + files, err := os.ReadDir(clusterStackReleasePath) if err != nil { return fmt.Errorf("failed to read directory %s: %w", clusterStackReleasePath, err) @@ -365,11 +375,6 @@ func pushReleaseAssets(ctx context.Context, pusher assetsclient.Pusher, clusterS return fmt.Errorf("failed to push release assets to oci registry: %w", err) } - ociclient, err := oci.NewClient() - if err != nil { - return fmt.Errorf("error creating oci client: %w", err) - } - fmt.Printf("successfully pushed clusterstack release: %s:%s \n", ociclient.Repository.Reference.String(), releaseName) return nil }