Skip to content

Commit

Permalink
Fixes value for storage.oci.repository
Browse files Browse the repository at this point in the history
Previously while providing repo url value for storage
oci repository, chains controller was giving an error
as

`a digest must contain exactly one '@' separator (e.g.
registry/repository@digest)`

because, it was not able to add digest and repo name

Hence this patch fixes it, by formatting the value
provided by the user and thus storing the
attestations/signatures in the provide location

Signed-off-by: PuneetPunamiya <[email protected]>
  • Loading branch information
PuneetPunamiya committed Oct 27, 2023
1 parent b6f3857 commit 86aacdc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/chains/storage/oci/legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"encoding/base64"
"encoding/json"
"fmt"
"strings"

"github.com/tektoncd/chains/pkg/chains/formats"
"github.com/tektoncd/chains/pkg/chains/objects"
Expand Down Expand Up @@ -280,8 +281,11 @@ func (b *Backend) RetrieveArtifact(ctx context.Context, obj objects.TektonObject

func newDigest(cfg config.Config, imageName string) (name.Digest, error) {
// Override image name from config if set.
if r := cfg.Storage.OCI.Repository; r != "" {
imageName = r
if storageOCIRepository := cfg.Storage.OCI.Repository; storageOCIRepository != "" {
parts := strings.SplitN(imageName, "/", 3)
if len(parts) == 3 && (strings.ContainsRune(parts[0], '.') || strings.ContainsRune(parts[0], ':')) {
imageName = fmt.Sprintf("%s/%s", cfg.Storage.OCI.Repository, parts[2])
}
}

var opts []name.Option
Expand Down

0 comments on commit 86aacdc

Please sign in to comment.