packer-cn/builder/yandex/artifact.go

47 lines
809 B
Go
Raw Normal View History

2019-03-26 08:29:15 -04:00
package yandex
import (
"fmt"
"github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1"
)
2019-03-26 08:29:15 -04:00
type Artifact struct {
config *Config
driver Driver
image *compute.Image
2019-03-26 08:29:15 -04:00
}
//revive:disable:var-naming
func (*Artifact) BuilderId() string {
return BuilderID
}
func (a *Artifact) Id() string {
return a.image.Id
2019-03-26 08:29:15 -04:00
}
func (*Artifact) Files() []string {
return nil
}
//revive:enable:var-naming
2019-03-26 08:29:15 -04:00
func (a *Artifact) String() string {
return fmt.Sprintf("A disk image was created: %v (id: %v) with family name %v", a.image.Name, a.image.Id, a.image.Family)
2019-03-26 08:29:15 -04:00
}
func (a *Artifact) State(name string) interface{} {
switch name {
case "ImageID":
return a.image.Id
2019-03-26 08:29:15 -04:00
case "FolderID":
return a.image.FolderId
2019-03-26 08:29:15 -04:00
}
return nil
}
func (a *Artifact) Destroy() error {
return a.driver.DeleteImage(a.image.Id)
2019-03-26 08:29:15 -04:00
}