add oci/classic artifact
This commit is contained in:
parent
44befb0857
commit
603881d990
|
@ -1,7 +1,15 @@
|
|||
package classic
|
||||
|
||||
// Artifact is an artifact implementation that contains a built Custom Image.
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/go-oracle-terraform/compute"
|
||||
)
|
||||
|
||||
// Artifact is an artifact implementation that contains a Snapshot.
|
||||
type Artifact struct {
|
||||
Snapshot *compute.Snapshot
|
||||
driver *compute.ComputeClient
|
||||
}
|
||||
|
||||
// BuilderId uniquely identifies the builder.
|
||||
|
@ -15,13 +23,17 @@ func (a *Artifact) Files() []string {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Id returns the OCID of the associated Image.
|
||||
func (a *Artifact) Id() string {
|
||||
return ""
|
||||
return a.Snapshot.Name
|
||||
}
|
||||
|
||||
func (a *Artifact) String() string {
|
||||
return ""
|
||||
return fmt.Sprintf("A Snapshot was created: \n"+
|
||||
"Name: %s\n"+
|
||||
"Instance: %s\n"+
|
||||
"MachineImage: %s\n"+
|
||||
"URI: %s",
|
||||
a.Snapshot.Name, a.Snapshot.Instance, a.Snapshot.MachineImage, a.Snapshot.URI)
|
||||
}
|
||||
|
||||
func (a *Artifact) State(name string) interface{} {
|
||||
|
@ -30,5 +42,11 @@ func (a *Artifact) State(name string) interface{} {
|
|||
|
||||
// Destroy deletes the custom image associated with the artifact.
|
||||
func (a *Artifact) Destroy() error {
|
||||
return nil
|
||||
client := a.driver.Snapshots()
|
||||
mic := a.driver.MachineImages()
|
||||
input := &compute.DeleteSnapshotInput{
|
||||
Snapshot: a.Snapshot.Name,
|
||||
MachineImage: a.Snapshot.MachineImage,
|
||||
}
|
||||
return client.DeleteSnapshot(mic, input)
|
||||
}
|
||||
|
|
|
@ -89,17 +89,13 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe
|
|||
return nil, rawErr.(error)
|
||||
}
|
||||
|
||||
/*
|
||||
// Build the artifact and return it
|
||||
artifact := &Artifact{
|
||||
Image: state.Get("image").(client.Image),
|
||||
Region: b.config.AccessCfg.Region,
|
||||
driver: driver,
|
||||
}
|
||||
// Build the artifact and return it
|
||||
artifact := &Artifact{
|
||||
Snapshot: state.Get("snapshot").(*compute.Snapshot),
|
||||
driver: client,
|
||||
}
|
||||
|
||||
return artifact, nil
|
||||
*/
|
||||
return nil, nil
|
||||
return artifact, nil
|
||||
}
|
||||
|
||||
// Cancel terminates a running build.
|
||||
|
|
|
@ -35,6 +35,7 @@ func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction {
|
|||
return multistep.ActionHalt
|
||||
}
|
||||
|
||||
state.Put("snapshot", snap)
|
||||
ui.Say(fmt.Sprintf("Created snapshot (%s).", snap.Name))
|
||||
return multistep.ActionContinue
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue