Add snapshot and gallery clients

This commit is contained in:
Paul Meyer 2020-03-25 21:36:51 +00:00
parent cfe37057bd
commit a3d8bf27e1
2 changed files with 44 additions and 0 deletions

View File

@ -15,7 +15,12 @@ type AzureClientSet interface {
MetadataClient() MetadataClientAPI MetadataClient() MetadataClientAPI
DisksClient() computeapi.DisksClientAPI DisksClient() computeapi.DisksClientAPI
SnapshotsClient() computeapi.SnapshotsClientAPI
ImagesClient() computeapi.ImagesClientAPI ImagesClient() computeapi.ImagesClientAPI
GalleryImagesClient() computeapi.GalleryImagesClientAPI
GalleryImageVersionsClient() computeapi.GalleryImageVersionsClientAPI
VirtualMachinesClient() computeapi.VirtualMachinesClientAPI VirtualMachinesClient() computeapi.VirtualMachinesClientAPI
VirtualMachineImagesClient() VirtualMachineImagesClientAPI VirtualMachineImagesClient() VirtualMachineImagesClientAPI
@ -77,6 +82,13 @@ func (s azureClientSet) DisksClient() computeapi.DisksClientAPI {
return c return c
} }
func (s azureClientSet) SnapshotsClient() computeapi.SnapshotsClientAPI {
c := compute.NewSnapshotsClient(s.subscriptionID)
s.configureAutorestClient(&c.Client)
c.PollingDelay = s.PollingDelay
return c
}
func (s azureClientSet) ImagesClient() computeapi.ImagesClientAPI { func (s azureClientSet) ImagesClient() computeapi.ImagesClientAPI {
c := compute.NewImagesClient(s.subscriptionID) c := compute.NewImagesClient(s.subscriptionID)
s.configureAutorestClient(&c.Client) s.configureAutorestClient(&c.Client)
@ -98,6 +110,20 @@ func (s azureClientSet) VirtualMachineImagesClient() VirtualMachineImagesClientA
return VirtualMachineImagesClient{c} return VirtualMachineImagesClient{c}
} }
func (s azureClientSet) GalleryImagesClient() computeapi.GalleryImagesClientAPI {
c := compute.NewGalleryImagesClient(s.subscriptionID)
s.configureAutorestClient(&c.Client)
c.PollingDelay = s.PollingDelay
return c
}
func (s azureClientSet) GalleryImageVersionsClient() computeapi.GalleryImageVersionsClientAPI {
c := compute.NewGalleryImageVersionsClient(s.subscriptionID)
s.configureAutorestClient(&c.Client)
c.PollingDelay = s.PollingDelay
return c
}
func (s azureClientSet) PollClient() autorest.Client { func (s azureClientSet) PollClient() autorest.Client {
c := autorest.NewClientWithUserAgent("Packer-Azure-ClientSet") c := autorest.NewClientWithUserAgent("Packer-Azure-ClientSet")
s.configureAutorestClient(&c) s.configureAutorestClient(&c)

View File

@ -10,9 +10,12 @@ var _ AzureClientSet = &AzureClientSetMock{}
// AzureClientSetMock provides a generic mock for AzureClientSet // AzureClientSetMock provides a generic mock for AzureClientSet
type AzureClientSetMock struct { type AzureClientSetMock struct {
DisksClientMock computeapi.DisksClientAPI DisksClientMock computeapi.DisksClientAPI
SnapshotsClientMock computeapi.SnapshotsClientAPI
ImagesClientMock computeapi.ImagesClientAPI ImagesClientMock computeapi.ImagesClientAPI
VirtualMachineImagesClientMock VirtualMachineImagesClientAPI VirtualMachineImagesClientMock VirtualMachineImagesClientAPI
VirtualMachinesClientMock computeapi.VirtualMachinesClientAPI VirtualMachinesClientMock computeapi.VirtualMachinesClientAPI
GalleryImagesClientMock computeapi.GalleryImagesClientAPI
GalleryImageVersionsClientMock computeapi.GalleryImageVersionsClientAPI
PollClientMock autorest.Client PollClientMock autorest.Client
MetadataClientMock MetadataClientAPI MetadataClientMock MetadataClientAPI
SubscriptionIDMock string SubscriptionIDMock string
@ -23,6 +26,11 @@ func (m *AzureClientSetMock) DisksClient() computeapi.DisksClientAPI {
return m.DisksClientMock return m.DisksClientMock
} }
// SnapshotsClient returns a SnapshotsClientAPI
func (m *AzureClientSetMock) SnapshotsClient() computeapi.SnapshotsClientAPI {
return m.SnapshotsClientMock
}
// ImagesClient returns a ImagesClientAPI // ImagesClient returns a ImagesClientAPI
func (m *AzureClientSetMock) ImagesClient() computeapi.ImagesClientAPI { func (m *AzureClientSetMock) ImagesClient() computeapi.ImagesClientAPI {
return m.ImagesClientMock return m.ImagesClientMock
@ -38,6 +46,16 @@ func (m *AzureClientSetMock) VirtualMachinesClient() computeapi.VirtualMachinesC
return m.VirtualMachinesClientMock return m.VirtualMachinesClientMock
} }
// GalleryImagesClient returns a GalleryImagesClientAPI
func (m *AzureClientSetMock) GalleryImagesClient() computeapi.GalleryImagesClientAPI {
return m.GalleryImagesClientMock
}
// GalleryImageVersionsClient returns a GalleryImageVersionsClientAPI
func (m *AzureClientSetMock) GalleryImageVersionsClient() computeapi.GalleryImageVersionsClientAPI {
return m.GalleryImageVersionsClientMock
}
// PollClient returns an autorest Client that can be used for polling async requests // PollClient returns an autorest Client that can be used for polling async requests
func (m *AzureClientSetMock) PollClient() autorest.Client { func (m *AzureClientSetMock) PollClient() autorest.Client {
return m.PollClientMock return m.PollClientMock