diff --git a/builder/file/artifact.go b/builder/file/artifact.go index 6854fa11214..1a7442370d0 100644 --- a/builder/file/artifact.go +++ b/builder/file/artifact.go @@ -10,6 +10,7 @@ import ( ) type FileArtifact struct { + source string filename string } @@ -34,6 +35,7 @@ func (a *FileArtifact) State(name string) interface{} { img, err := registryimage.FromArtifact(a, registryimage.WithID(path.Base(a.filename)), registryimage.WithRegion(path.Dir(a.filename)), + registryimage.WithSourceID(a.source), ) if err != nil { diff --git a/builder/file/builder.go b/builder/file/builder.go index 08a991b7996..82ddd095951 100644 --- a/builder/file/builder.go +++ b/builder/file/builder.go @@ -68,6 +68,8 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) return nil, err } ui.Say(fmt.Sprintf("Copied %d bytes", bytes)) + + artifact.source = b.config.Source artifact.filename = target.Name() } else { // We're going to write Contents; if it's empty we'll just create an @@ -76,6 +78,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) if err != nil { return nil, err } + artifact.source = "" artifact.filename = b.config.Target }