Googlebuilder: Add image key encryption
This commit is contained in:
parent
9b39e3f928
commit
f1e9664012
|
@ -156,6 +156,21 @@ func TestConfigPrepare(t *testing.T) {
|
||||||
"foo bar",
|
"foo bar",
|
||||||
true,
|
true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"image_encryption_key",
|
||||||
|
map[string]string{"kmsKeyName": "foo"},
|
||||||
|
false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image_encryption_key",
|
||||||
|
map[string]string{"No such key": "foo"},
|
||||||
|
true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"image_encryption_key",
|
||||||
|
map[string]string{"kmsKeyName": "foo", "RawKey": "foo"},
|
||||||
|
false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"scopes",
|
"scopes",
|
||||||
[]string{},
|
[]string{},
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package googlecompute
|
package googlecompute
|
||||||
|
|
||||||
import "fmt"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
compute "google.golang.org/api/compute/v1"
|
||||||
|
)
|
||||||
|
|
||||||
// DriverMock is a Driver implementation that is a mocked out so that
|
// DriverMock is a Driver implementation that is a mocked out so that
|
||||||
// it can be used for tests.
|
// it can be used for tests.
|
||||||
|
@ -9,6 +13,7 @@ type DriverMock struct {
|
||||||
CreateImageDesc string
|
CreateImageDesc string
|
||||||
CreateImageFamily string
|
CreateImageFamily string
|
||||||
CreateImageLabels map[string]string
|
CreateImageLabels map[string]string
|
||||||
|
CreateImageEncryptionKey *compute.CustomerEncryptionKey
|
||||||
CreateImageLicenses []string
|
CreateImageLicenses []string
|
||||||
CreateImageZone string
|
CreateImageZone string
|
||||||
CreateImageDisk string
|
CreateImageDisk string
|
||||||
|
@ -82,14 +87,16 @@ type DriverMock struct {
|
||||||
WaitForInstanceErrCh <-chan error
|
WaitForInstanceErrCh <-chan error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *DriverMock) CreateImage(name, description, family, zone, disk string, image_labels map[string]string, image_licenses []string) (<-chan *Image, <-chan error) {
|
func (d *DriverMock) CreateImage(config Config) (<-chan *Image, <-chan error) {
|
||||||
d.CreateImageName = name
|
d.CreateImageName = config.GetImageName()
|
||||||
d.CreateImageDesc = description
|
d.CreateImageDesc = config.GetImageDescription()
|
||||||
d.CreateImageFamily = family
|
d.CreateImageFamily = config.GetImageFamily()
|
||||||
d.CreateImageLabels = image_labels
|
d.CreateImageLabels = config.GetImageLabels()
|
||||||
d.CreateImageLicenses = image_licenses
|
d.CreateImageLicenses = config.GetImageLicenses()
|
||||||
d.CreateImageZone = zone
|
d.CreateImageZone = config.GetZone()
|
||||||
d.CreateImageDisk = disk
|
d.CreateImageDisk = config.GetDiskName()
|
||||||
|
d.CreateImageEncryptionKey = config.GetImageEncryptionKey()
|
||||||
|
|
||||||
if d.CreateImageResultProjectId == "" {
|
if d.CreateImageResultProjectId == "" {
|
||||||
d.CreateImageResultProjectId = "test"
|
d.CreateImageResultProjectId = "test"
|
||||||
}
|
}
|
||||||
|
@ -108,7 +115,7 @@ func (d *DriverMock) CreateImage(name, description, family, zone, disk string, i
|
||||||
ch <- &Image{
|
ch <- &Image{
|
||||||
Labels: d.CreateImageLabels,
|
Labels: d.CreateImageLabels,
|
||||||
Licenses: d.CreateImageLicenses,
|
Licenses: d.CreateImageLicenses,
|
||||||
Name: name,
|
Name: d.CreateImageName,
|
||||||
ProjectId: d.CreateImageResultProjectId,
|
ProjectId: d.CreateImageResultProjectId,
|
||||||
SelfLink: d.CreateImageResultSelfLink,
|
SelfLink: d.CreateImageResultSelfLink,
|
||||||
SizeGb: d.CreateImageResultSizeGb,
|
SizeGb: d.CreateImageResultSizeGb,
|
||||||
|
|
|
@ -47,6 +47,7 @@ func TestStepCreateImage(t *testing.T) {
|
||||||
assert.Equal(t, d.CreateImageDisk, c.DiskName, "Incorrect disk passed to driver.")
|
assert.Equal(t, d.CreateImageDisk, c.DiskName, "Incorrect disk passed to driver.")
|
||||||
assert.Equal(t, d.CreateImageLabels, c.ImageLabels, "Incorrect image_labels passed to driver.")
|
assert.Equal(t, d.CreateImageLabels, c.ImageLabels, "Incorrect image_labels passed to driver.")
|
||||||
assert.Equal(t, d.CreateImageLicenses, c.ImageLicenses, "Incorrect image_licenses passed to driver.")
|
assert.Equal(t, d.CreateImageLicenses, c.ImageLicenses, "Incorrect image_licenses passed to driver.")
|
||||||
|
assert.Equal(t, d.CreateImageEncryptionKey, c.ImageEncryptionKey, "Incorrect image_encryption_key passed to driver.")
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestStepCreateImage_errorOnChannel(t *testing.T) {
|
func TestStepCreateImage_errorOnChannel(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue