Skip to content

Commit

Permalink
feat(oci): Introduce lightweight name check
Browse files Browse the repository at this point in the history
For offline checks, a simple check of the naming format can help
determine whether the provided input source is valid.

Signed-off-by: Alexander Jung <[email protected]>
  • Loading branch information
nderjung committed Feb 21, 2024
1 parent c66ae8b commit 99918e0
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions oci/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,15 @@ func (manager *ociManager) IsCompatible(ctx context.Context, source string, qopt
return nil, false, err
}

isFullyQualifiedNameReference := func(source string) bool {
_, err := name.ParseReference(source)
if err != nil && errors.Is(err, &name.ErrBadName{}) {
return false
}

return true
}

query := packmanager.NewQuery(qopts...)

// Check if the provided source is a fully qualified OCI reference
Expand Down Expand Up @@ -788,6 +797,7 @@ func (manager *ociManager) IsCompatible(ctx context.Context, source string, qopt

checks := []func(string) bool{
isLocalImage,
isFullyQualifiedNameReference,
}

if query.Remote() {
Expand Down

0 comments on commit 99918e0

Please sign in to comment.