2014-04-26 12:22:10 -04:00
|
|
|
package compress
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
)
|
|
|
|
|
2015-06-10 17:04:24 -04:00
|
|
|
const BuilderId = "packer.post-processor.compress"
|
2014-04-26 12:22:10 -04:00
|
|
|
|
|
|
|
type Artifact struct {
|
2015-06-12 20:25:09 -04:00
|
|
|
Path string
|
|
|
|
Provider string
|
|
|
|
files []string
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewArtifact(provider, path string) *Artifact {
|
|
|
|
return &Artifact{
|
|
|
|
Path: path,
|
|
|
|
Provider: provider,
|
|
|
|
}
|
2014-04-26 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
2015-06-10 15:30:18 -04:00
|
|
|
func (a *Artifact) BuilderId() string {
|
2014-04-26 12:22:10 -04:00
|
|
|
return BuilderId
|
|
|
|
}
|
|
|
|
|
2015-06-12 20:25:09 -04:00
|
|
|
func (*Artifact) Id() string {
|
|
|
|
return ""
|
2014-04-26 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
2015-06-12 20:25:09 -04:00
|
|
|
func (a *Artifact) Files() []string {
|
2015-06-18 08:13:48 -04:00
|
|
|
return []string{a.Path}
|
2014-04-26 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
2015-06-10 15:30:18 -04:00
|
|
|
func (a *Artifact) String() string {
|
2015-06-12 20:25:09 -04:00
|
|
|
return fmt.Sprintf("'%s' compressing: %s", a.Provider, a.Path)
|
2014-04-26 12:22:10 -04:00
|
|
|
}
|
|
|
|
|
2014-01-19 13:32:44 -05:00
|
|
|
func (*Artifact) State(name string) interface{} {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-06-10 15:30:18 -04:00
|
|
|
func (a *Artifact) Destroy() error {
|
2015-06-12 20:25:09 -04:00
|
|
|
return os.Remove(a.Path)
|
2014-04-26 12:22:10 -04:00
|
|
|
}
|