From 547cfa3602b87a4713ff09b281e8505f67be8e09 Mon Sep 17 00:00:00 2001 From: Pavel Vasilevich Date: Wed, 7 Jun 2017 14:12:03 +0700 Subject: [PATCH] Add information about artifact in manifest post-processor in azure-arm builder --- builder/azure/arm/artifact.go | 4 ++-- builder/azure/arm/artifact_test.go | 31 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/builder/azure/arm/artifact.go b/builder/azure/arm/artifact.go index 25672c6f2..5de9f90e1 100644 --- a/builder/azure/arm/artifact.go +++ b/builder/azure/arm/artifact.go @@ -86,8 +86,8 @@ func (*Artifact) Files() []string { return []string{} } -func (*Artifact) Id() string { - return "" +func (a *Artifact) Id() string { + return a.OSDiskUri } func (a *Artifact) State(name string) interface{} { diff --git a/builder/azure/arm/artifact_test.go b/builder/azure/arm/artifact_test.go index e7900ff53..7202b6529 100644 --- a/builder/azure/arm/artifact_test.go +++ b/builder/azure/arm/artifact_test.go @@ -13,6 +13,37 @@ func getFakeSasUrl(name string) string { return fmt.Sprintf("SAS-%s", name) } +func TestArtifactId(t *testing.T) { + template := CaptureTemplate{ + Resources: []CaptureResources{ + { + Properties: CaptureProperties{ + StorageProfile: CaptureStorageProfile{ + OSDisk: CaptureDisk{ + Image: CaptureUri{ + Uri: "https://storage.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.4085bb15-3644-4641-b9cd-f575918640b4.vhd", + }, + }, + }, + }, + Location: "southcentralus", + }, + }, + } + + artifact, err := NewArtifact(&template, getFakeSasUrl) + if err != nil { + t.Fatalf("err=%s", err) + } + + expected := "https://storage.blob.core.windows.net/system/Microsoft.Compute/Images/images/packer-osDisk.4085bb15-3644-4641-b9cd-f575918640b4.vhd" + + result := artifact.Id() + if result != expected { + t.Fatalf("bad: %s", result) + } +} + func TestArtifactString(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{