packer-cn/builder/oracle/oci/artifact.go

52 lines
1.1 KiB
Go
Raw Normal View History

package oci
import (
"fmt"
2018-01-22 20:21:10 -05:00
2018-04-11 05:20:40 -04:00
"github.com/oracle/oci-go-sdk/core"
)
// Artifact is an artifact implementation that contains a built Custom Image.
type Artifact struct {
2018-04-11 05:20:40 -04:00
Image core.Image
Region string
driver Driver
}
// BuilderId uniquely identifies the builder.
func (a *Artifact) BuilderId() string {
return BuilderId
}
// Files lists the files associated with an artifact. We don't have any files
// as the custom image is stored server side.
func (a *Artifact) Files() []string {
return nil
}
// Id returns the OCID of the associated Image.
func (a *Artifact) Id() string {
2018-04-11 05:20:40 -04:00
return *a.Image.Id
}
func (a *Artifact) String() string {
2018-04-11 05:20:40 -04:00
var displayName string
if a.Image.DisplayName != nil {
displayName = *a.Image.DisplayName
}
return fmt.Sprintf(
"An image was created: '%v' (OCID: %v) in region '%v'",
2018-04-11 05:20:40 -04:00
displayName, *a.Image.Id, a.Region,
)
}
func (a *Artifact) State(name string) interface{} {
return nil
}
// Destroy deletes the custom image associated with the artifact.
func (a *Artifact) Destroy() error {
2018-04-11 05:20:40 -04:00
return a.driver.DeleteImage(*a.Image.Id)
}