Merge pull request #7248 from oceyral/oceyral/feat/add_user_data

Add "custom_data" key to packer manifest post-processor
This commit is contained in:
Megan Marsh 2019-02-01 11:37:44 -08:00 committed by GitHub
commit 6cac03044f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 12 deletions

View File

@ -10,12 +10,13 @@ type ArtifactFile struct {
}
type Artifact struct {
BuildName string `json:"name"`
BuilderType string `json:"builder_type"`
BuildTime int64 `json:"build_time"`
ArtifactFiles []ArtifactFile `json:"files"`
ArtifactId string `json:"artifact_id"`
PackerRunUUID string `json:"packer_run_uuid"`
BuildName string `json:"name"`
BuilderType string `json:"builder_type"`
BuildTime int64 `json:"build_time"`
ArtifactFiles []ArtifactFile `json:"files"`
ArtifactId string `json:"artifact_id"`
PackerRunUUID string `json:"packer_run_uuid"`
CustomData map[string]string `json:"custom_data"`
}
func (a *Artifact) BuilderId() string {

View File

@ -18,8 +18,9 @@ import (
type Config struct {
common.PackerConfig `mapstructure:",squash"`
OutputPath string `mapstructure:"output"`
StripPath bool `mapstructure:"strip_path"`
OutputPath string `mapstructure:"output"`
StripPath bool `mapstructure:"strip_path"`
CustomData map[string]string `mapstructure:"custom_data"`
ctx interpolate.Context
}
@ -75,6 +76,7 @@ func (p *PostProcessor) PostProcess(ui packer.Ui, source packer.Artifact) (packe
artifact.ArtifactFiles = append(artifact.ArtifactFiles, af)
}
artifact.ArtifactId = source.Id()
artifact.CustomData = p.config.CustomData
artifact.BuilderType = p.config.PackerBuilderType
artifact.BuildName = p.config.PackerBuildName
artifact.BuildTime = time.Now().Unix()

View File

@ -38,11 +38,12 @@ post-processors such as Docker and Artifice.
to `packer-manifest.json`.
- `strip_path` (boolean) Write only filename without the path to the manifest
file. This defaults to false.
- `custom_data` (map of strings) Arbitrary data to add to the manifest.
### Example Configuration
You can simply add `{"type":"manifest"}` to your post-processor section. Below
is a more verbose example:
is a more complete example:
``` json
{
@ -50,7 +51,10 @@ is a more verbose example:
{
"type": "manifest",
"output": "manifest.json",
"strip_path": true
"strip_path": true,
"custom_data": {
"my_custom_data": "example"
}
}
]
}
@ -72,7 +76,10 @@ An example manifest file looks like:
}
],
"artifact_id": "Container",
"packer_run_uuid": "6d5d3185-fa95-44e1-8775-9e64fe2e2d8f"
"packer_run_uuid": "6d5d3185-fa95-44e1-8775-9e64fe2e2d8f",
"custom_data": {
"my_custom_data": "example"
}
}
],
"last_run_uuid": "6d5d3185-fa95-44e1-8775-9e64fe2e2d8f"
@ -114,7 +121,10 @@ The above manifest was generated with this packer.json:
{
"type": "manifest",
"output": "manifest.json",
"strip_path": true
"strip_path": true,
"custom_data": {
"my_custom_data": "example"
}
}
]
}