Add a value for SourceID to file artifact (#11315)

pull/11316/head
Wilken Rivera 5 years ago committed by GitHub
parent 2e114e82d6
commit b2f9d58c5a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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 {

@ -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 = "<no-defined-source-file>"
artifact.filename = b.config.Target
}

Loading…
Cancel
Save