Skip to content

Commit

Permalink
Add a value for SourceID to file artifact (#11315)
Browse files Browse the repository at this point in the history
  • Loading branch information
nywilken committed Oct 8, 2021
1 parent 2e114e8 commit b2f9d58
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builder/file/artifact.go
Expand Up @@ -10,6 +10,7 @@ import (
)

type FileArtifact struct {
source string
filename string
}

Expand All @@ -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 {
Expand Down
3 changes: 3 additions & 0 deletions builder/file/builder.go
Expand Up @@ -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
Expand All @@ -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 = "<no-defined-source-file>"
artifact.filename = b.config.Target
}

Expand Down

0 comments on commit b2f9d58

Please sign in to comment.