@@ -11,7 +11,7 @@ import (
1111)
1212
1313// Pull pulls an artifact from a registry and stores it in the content store
14- func Pull (ctx context.Context , registryRef string , opts ... crane.Option ) (string , error ) {
14+ func Pull (ctx context.Context , registryRef string , force bool , opts ... crane.Option ) (string , error ) {
1515 opts = append (opts , crane .WithContext (ctx ))
1616
1717 ref , err := name .ParseReference (registryRef )
@@ -30,12 +30,14 @@ func Pull(ctx context.Context, registryRef string, opts ...crane.Option) (string
3030 }
3131
3232 localRef := ref .Context ().RepositoryStr () + ":" + ref .Identifier ()
33- if meta , metaErr := store .GetArtifactMetadata (localRef ); metaErr == nil {
34- if meta .Digest == remoteDigest {
35- if ! hasCagentAnnotation (meta .Annotations ) {
36- return "" , fmt .Errorf ("artifact %s found in store wasn't created by cagent" , localRef )
33+ if ! force {
34+ if meta , metaErr := store .GetArtifactMetadata (localRef ); metaErr == nil {
35+ if meta .Digest == remoteDigest {
36+ if ! hasCagentAnnotation (meta .Annotations ) {
37+ return "" , fmt .Errorf ("artifact %s found in store wasn't created by cagent" , localRef )
38+ }
39+ return meta .Digest , nil
3740 }
38- return meta .Digest , nil
3941 }
4042 }
4143
@@ -49,7 +51,7 @@ func Pull(ctx context.Context, registryRef string, opts ...crane.Option) (string
4951 return "" , fmt .Errorf ("getting manifest from pulled image: %w" , err )
5052 }
5153 if ! hasCagentAnnotation (manifest .Annotations ) {
52- return "" , fmt .Errorf ("artifact %s found in store wasn't created by cagent" , localRef )
54+ return "" , fmt .Errorf ("artifact %s wasn't created by cagent" , localRef )
5355 }
5456
5557 digest , err := store .StoreArtifact (img , localRef )
0 commit comments