diff --git a/post-processor/manifest/artifact.go b/post-processor/manifest/artifact.go index 984330e0e..9a68d0e7e 100644 --- a/post-processor/manifest/artifact.go +++ b/post-processor/manifest/artifact.go @@ -5,11 +5,13 @@ import "fmt" const BuilderId = "packer.post-processor.manifest" type Artifact struct { - BuildName string `json:"build_name"` - BuildTime int64 `json:"build_time"` - Description string `json:"description"` - BuildFiles []string `json:"files"` - BuildId string `json:"artifact_id"` + BuildName string `json:"name"` + BuilderType string `json:"builder_type"` + InputType string `json:"input_type"` + BuildTime int64 `json:"build_time"` + Description string `json:"description"` + ArtifactFiles []string `json:"files"` + ArtifactId string `json:"artifact_id"` } func (a *Artifact) BuilderId() string { @@ -17,15 +19,15 @@ func (a *Artifact) BuilderId() string { } func (a *Artifact) Files() []string { - return a.BuildFiles + return a.ArtifactFiles } func (a *Artifact) Id() string { - return a.BuildId + return a.ArtifactId } func (a *Artifact) String() string { - return fmt.Sprintf("%s-%s", a.BuildName, a.BuildId) + return fmt.Sprintf("%s-%s", a.BuildName, a.ArtifactId) } func (a *Artifact) State(name string) interface{} { diff --git a/post-processor/manifest/post-processor.go b/post-processor/manifest/post-processor.go index fe23455f1..1ed894718 100644 --- a/post-processor/manifest/post-processor.go +++ b/post-processor/manifest/post-processor.go @@ -13,12 +13,6 @@ import ( "github.com/mitchellh/packer/template/interpolate" ) -// The artifact-override post-processor allows you to specify arbitrary files as -// artifacts. These will override any other artifacts created by the builder. -// This allows you to use a builder and provisioner to create some file, such as -// a compiled binary or tarball, extract it from the builder (VM or container) -// and then save that binary or tarball and throw away the builder. - type Config struct { common.PackerConfig `mapstructure:",squash"` @@ -58,18 +52,24 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe artifact := &Artifact{} // Create the current artifact. - artifact.BuildFiles = source.Files() - artifact.BuildId = source.Id() - artifact.BuildName = source.BuilderId() + artifact.ArtifactFiles = source.Files() + artifact.ArtifactId = source.Id() + artifact.InputType = source.BuilderId() + artifact.BuilderType = p.config.PackerBuilderType + artifact.BuildName = p.config.PackerBuildName artifact.BuildTime = time.Now().Unix() artifact.Description = source.String() // Create a lock file with exclusive access. If this fails we will retry // after a delay + // TODO add retry lockFilename := p.config.Filename + ".lock" _, err := os.OpenFile(lockFilename, os.O_RDWR|os.O_CREATE|os.O_EXCL, 0600) defer os.Remove(lockFilename) + // TODO fix error on first run: + // * Post-processor failed: open packer-manifest.json: no such file or directory + // // Read the current manifest file from disk contents := []byte{} if contents, err = ioutil.ReadFile(p.config.Filename); err != nil && !os.IsNotExist(err) {