From b2f9d58c5ae9c008eb980215a623721e426c2c0f Mon Sep 17 00:00:00 2001 From: Wilken Rivera Date: Fri, 8 Oct 2021 06:26:42 -0400 Subject: [PATCH] Add a value for SourceID to file artifact (#11315) --- builder/file/artifact.go | 2 ++ builder/file/builder.go | 3 +++ 2 files changed, 5 insertions(+) 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 }