2013-08-28 01:35:59 -04:00
|
|
|
package openstack
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2014-10-27 19:40:49 -04:00
|
|
|
|
2016-11-27 19:59:26 -05:00
|
|
|
"github.com/gophercloud/gophercloud"
|
2018-11-25 14:30:31 -05:00
|
|
|
"github.com/gophercloud/gophercloud/openstack/imageservice/v2/images"
|
2013-08-28 01:35:59 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
// Artifact is an artifact implementation that contains built images.
|
|
|
|
type Artifact struct {
|
|
|
|
// ImageId of built image
|
|
|
|
ImageId string
|
|
|
|
|
|
|
|
// BuilderId is the unique ID for the builder that created this image
|
|
|
|
BuilderIdValue string
|
|
|
|
|
|
|
|
// OpenStack connection for performing API stuff.
|
2015-06-12 00:16:43 -04:00
|
|
|
Client *gophercloud.ServiceClient
|
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-08-28 01:35:59 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) BuilderId() string {
|
|
|
|
return a.BuilderIdValue
|
|
|
|
}
|
|
|
|
|
|
|
|
func (*Artifact) Files() []string {
|
|
|
|
// We have no files
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) Id() string {
|
|
|
|
return a.ImageId
|
|
|
|
}
|
|
|
|
|
|
|
|
func (a *Artifact) String() string {
|
|
|
|
return fmt.Sprintf("An image was created: %v", a.ImageId)
|
|
|
|
}
|
|
|
|
|
2014-01-19 13:32:44 -05:00
|
|
|
func (a *Artifact) 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-08-28 01:35:59 -04:00
|
|
|
func (a *Artifact) Destroy() error {
|
2014-12-15 13:18:06 -05:00
|
|
|
log.Printf("Destroying image: %s", a.ImageId)
|
2015-06-12 00:16:43 -04:00
|
|
|
return images.Delete(a.Client, a.ImageId).ExtractErr()
|
2013-08-28 01:35:59 -04:00
|
|
|
}
|