diff --git a/pkg/git/package.go b/pkg/git/package.go index 5a817816..6cd7e93a 100644 --- a/pkg/git/package.go +++ b/pkg/git/package.go @@ -15,6 +15,7 @@ package git import ( + "bytes" "context" "crypto/sha1" "encoding/hex" @@ -24,6 +25,7 @@ import ( "time" "github.com/go-git/go-git/v5/plumbing" + "github.com/google/uuid" "github.com/nephio-project/porch/api/porch/v1alpha1" "github.com/nephio-project/porch/internal/kpt/pkg" kptfile "github.com/nephio-project/porch/pkg/kpt/api/kptfile/v1" @@ -33,6 +35,10 @@ import ( "k8s.io/klog/v2" ) +const ( + uuidSpace = "aac71d91-5c67-456f-8fd2-902ef6da820e" +) + type gitPackageRevision struct { repo *gitRepository // repo is repo containing the package path string // the path to the package from the repo root @@ -103,13 +109,15 @@ func (p *gitPackageRevision) Key() repository.PackageRevisionKey { } func (p *gitPackageRevision) uid() types.UID { - var s string - if p.revision == string(p.repo.branch) { - s = p.revision - } else { - s = string(p.workspaceName) - } - return types.UID(fmt.Sprintf("uid:%s:%s", p.path, s)) + space := uuid.MustParse(uuidSpace) + buff := bytes.Buffer{} + buff.WriteString("packagerevisions.") + buff.WriteString(v1alpha1.SchemeGroupVersion.Identifier()) + buff.WriteString("/") + buff.WriteString(p.KubeObjectNamespace()) + buff.WriteString("/") + buff.WriteString(p.KubeObjectName()) // KubeObjectName() is unique in a given namespace + return types.UID(uuid.NewSHA1(space, buff.Bytes()).String()) } func (p *gitPackageRevision) GetPackageRevision(ctx context.Context) (*v1alpha1.PackageRevision, error) { diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 2e25cbbc..147d0345 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -1141,10 +1141,11 @@ func (t *PorchSuite) TestDeleteAndRecreate(ctx context.Context) { var pkg porchapi.PackageRevision t.mustExist(ctx, client.ObjectKey{Namespace: t.namespace, Name: created.Name}, &pkg) - // Propose the package revision to be finalized + t.Log("Propose the package revision to be finalized") pkg.Spec.Lifecycle = porchapi.PackageRevisionLifecycleProposed t.UpdateF(ctx, &pkg) + t.Log("Approve the package revision to be finalized") pkg.Spec.Lifecycle = porchapi.PackageRevisionLifecyclePublished t.UpdateApprovalF(ctx, &pkg, metav1.UpdateOptions{})