2013-11-09 16:22:13 -05:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
|
|
|
// ExportArtifact is an Artifact implementation for when a container is
|
|
|
|
// exported from docker into a single flat file.
|
|
|
|
type ExportArtifact struct {
|
|
|
|
path string
|
2020-01-30 05:27:58 -05:00
|
|
|
// StateData should store data such as GeneratedData
|
|
|
|
// to be shared with post-processors
|
|
|
|
StateData map[string]interface{}
|
2013-11-09 16:22:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (*ExportArtifact) BuilderId() string {
|
|
|
|
return BuilderId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ExportArtifact) Files() []string {
|
|
|
|
return []string{a.path}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*ExportArtifact) Id() string {
|
|
|
|
return "Container"
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *ExportArtifact) String() string {
|
|
|
|
return fmt.Sprintf("Exported Docker file: %s", a.path)
|
|
|
|
}
|
|
|
|
|
2014-01-19 13:32:44 -05:00
|
|
|
func (a *ExportArtifact) State(name string) interface{} {
|
2020-01-30 05:27:58 -05:00
|
|
|
return a.StateData[name]
|
2014-01-19 13:32:44 -05:00
|
|
|
}
|
|
|
|
|
2013-11-09 16:22:13 -05:00
|
|
|
func (a *ExportArtifact) Destroy() error {
|
2020-12-03 17:58:07 -05:00
|
|
|
if a.path != "" {
|
|
|
|
return os.Remove(a.path)
|
|
|
|
}
|
|
|
|
return nil
|
2013-11-09 16:22:13 -05:00
|
|
|
}
|