From 5dc4ff95da143fb5d12fa131b5643b1d6bb24596 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Tue, 9 Oct 2018 15:43:23 -0700 Subject: [PATCH 1/2] fix azure artifact so it works with managed images as well as VHDs --- builder/azure/arm/artifact.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/builder/azure/arm/artifact.go b/builder/azure/arm/artifact.go index f7e63d6c4..8a234090d 100644 --- a/builder/azure/arm/artifact.go +++ b/builder/azure/arm/artifact.go @@ -133,7 +133,10 @@ func (*Artifact) Files() []string { } func (a *Artifact) Id() string { - return a.OSDiskUri + if a.OSDiskUri != "" { + return a.OSDiskUri + } + return a.ManagedImageId } func (a *Artifact) State(name string) interface{} { From 53bce398bbedae01cce24234b5894a231f58a83a Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 10 Oct 2018 10:00:55 -0700 Subject: [PATCH 2/2] add Managed Image test to azure artifact --- builder/azure/arm/artifact_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/builder/azure/arm/artifact_test.go b/builder/azure/arm/artifact_test.go index a65427897..0bfd0d58d 100644 --- a/builder/azure/arm/artifact_test.go +++ b/builder/azure/arm/artifact_test.go @@ -10,7 +10,7 @@ func getFakeSasUrl(name string) string { return fmt.Sprintf("SAS-%s", name) } -func TestArtifactId(t *testing.T) { +func TestArtifactIdVHD(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{ { @@ -41,6 +41,20 @@ func TestArtifactId(t *testing.T) { } } +func TestArtifactIDManagedImage(t *testing.T) { + artifact, err := NewManagedImageArtifact("Linux", "fakeResourceGroup", "fakeName", "fakeLocation", "fakeID") + if err != nil { + t.Fatalf("err=%s", err) + } + + expected := "fakeID" + + result := artifact.Id() + if result != expected { + t.Fatalf("bad: %s", result) + } +} + func TestArtifactString(t *testing.T) { template := CaptureTemplate{ Resources: []CaptureResources{