Amend commit author for license pass

This commit is contained in:
Gareth Rees 2020-12-02 11:16:16 +00:00
parent 3ab9bae79c
commit 833855eec5
6 changed files with 28 additions and 28 deletions

View File

@ -287,8 +287,8 @@ type Config struct {
VaultGCPOauthEngine string `mapstructure:"vault_gcp_oauth_engine"`
// The time to wait between the creation of the instance used to create the image,
// and the addition of SSH configuration, including SSH keys, to that instance.
// The delay is intended to protect packer from anything in the instance boot
// sequence that has potential to disrupt the creation of SSH configuration
// The delay is intended to protect packer from anything in the instance boot
// sequence that has potential to disrupt the creation of SSH configuration
// (e.g. SSH user creation, SSH key creation) on the instance.
// Note: All other instance metadata, including startup scripts, are still added to the instance
// during it's creation.

View File

@ -764,6 +764,6 @@ func (d *driverGCE) AddToInstanceMetadata(zone string, name string, metadata map
case <-time.After(time.Second * 30):
err = errors.New("time out while waiting for SSH keys to be added to instance")
}
return newErrCh, err
}
}

View File

@ -93,7 +93,7 @@ type DriverMock struct {
AddToInstanceMetadataName string
AddToInstanceMetadataKVPairs map[string]string
AddToInstanceMetadataErrCh <-chan error
AddToInstanceMetadataErr error
AddToInstanceMetadataErr error
}
func (d *DriverMock) CreateImage(name, description, family, zone, disk string, image_labels map[string]string, image_licenses []string, image_encryption_key *compute.CustomerEncryptionKey, imageStorageLocations []string) (<-chan *Image, <-chan error) {
@ -296,8 +296,8 @@ func (d *DriverMock) DeleteOSLoginSSHKey(user, fingerprint string) error {
}
func (d *DriverMock) AddToInstanceMetadata(zone string, name string, metadata map[string]string) (<-chan error, error) {
d.AddToInstanceMetadataZone = zone
d.AddToInstanceMetadataName = name
d.AddToInstanceMetadataZone = zone
d.AddToInstanceMetadataName = name
d.AddToInstanceMetadataKVPairs = metadata
resultCh := d.AddToInstanceMetadataErrCh
@ -308,4 +308,4 @@ func (d *DriverMock) AddToInstanceMetadata(zone string, name string, metadata ma
}
return resultCh, d.AddToInstanceMetadataErr
}
}

View File

@ -1,7 +1,7 @@
package googlecompute
import (
"fmt"
"fmt"
)
const StartupScriptKey string = "startup-script"
@ -57,4 +57,4 @@ SetMetadata %s %s
exit $RETVAL
`, StartupWrappedScriptKey, StartupScriptStatusKey, StartupScriptStatusDone)
var StartupScriptWindows string = ""
var StartupScriptWindows string = ""

View File

@ -5,9 +5,9 @@ import (
"errors"
"fmt"
"io/ioutil"
"log"
"strings"
"time"
"log"
"github.com/hashicorp/packer/packer"
"github.com/hashicorp/packer/packer-plugin-sdk/multistep"
@ -142,7 +142,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
var errCh <-chan error
metadataNoSSHKeys := make(map[string]string)
metadataSSHKeys := make(map[string]string)
metadataSSHKeys := make(map[string]string)
metadataForInstance := make(map[string]string)
metadataNoSSHKeys, metadataSSHKeys, errs := c.createInstanceMetadata(sourceImage, string(c.Comm.SSHPublicKey))
@ -160,7 +160,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
// Union of both non-SSH key meta data and SSH key meta data
addmap(metadataForInstance, metadataSSHKeys)
addmap(metadataForInstance, metadataNoSSHKeys)
addmap(metadataForInstance, metadataNoSSHKeys)
}
errCh, err = d.RunInstance(&InstanceConfig{
@ -230,9 +230,9 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
if cancelled {
return multistep.ActionHalt
}
log.Printf("[DEBUG] %s wait is over. Adding SSH keys to existing instance...",
c.WaitToAddSSHKeys.String())
c.WaitToAddSSHKeys.String())
errCh, err = d.AddToInstanceMetadata(c.Zone, name, metadataSSHKeys)
if err != nil {
@ -241,7 +241,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
return multistep.ActionHalt
}
}
return multistep.ActionContinue
}
@ -252,7 +252,7 @@ func (s *StepCreateInstance) waitForBoot(ctx context.Context, waitLen time.Durat
return true
case <-time.After(waitLen):
}
return false
}
@ -316,7 +316,7 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) {
}
func addmap(a map[string]string, b map[string]string) {
for k,v := range b {
for k, v := range b {
a[k] = v
}
}
}

View File

@ -337,7 +337,7 @@ func TestCreateInstanceMetadata_metadataFile(t *testing.T) {
c.MetadataFiles["user-data"] = fileName
// create our metadata
metadataNoSSHKeys, _,err := c.createInstanceMetadata(image, "")
metadataNoSSHKeys, _, err := c.createInstanceMetadata(image, "")
assert.True(t, err == nil, "Metadata creation should have succeeded.")
@ -391,14 +391,14 @@ func TestCreateInstanceMetadataWaitToAddSSHKeys(t *testing.T) {
c := state.Get("config").(*Config)
image := StubImage("test-image", "test-project", []string{}, 100)
key := "abcdefgh12345678"
var waitTime int = 4
c.WaitToAddSSHKeys = time.Duration(waitTime) * time.Second
c.Metadata = map[string]string{
"metadatakey1": "xyz",
"metadatakey2": "123",
}
// create our metadata
metadataNoSSHKeys, metadataSSHKeys, err := c.createInstanceMetadata(image, key)
@ -406,8 +406,8 @@ func TestCreateInstanceMetadataWaitToAddSSHKeys(t *testing.T) {
// ensure our metadata is listed
assert.True(t, strings.Contains(metadataSSHKeys["ssh-keys"], key), "Instance metadata should contain provided SSH key")
assert.True(t, strings.Contains(metadataNoSSHKeys["metadatakey1"], "xyz"), "Instance metadata should contain provided key: metadatakey1")
assert.True(t, strings.Contains(metadataNoSSHKeys["metadatakey2"], "123"), "Instance metadata should contain provided key: metadatakey2")
assert.True(t, strings.Contains(metadataNoSSHKeys["metadatakey1"], "xyz"), "Instance metadata should contain provided key: metadatakey1")
assert.True(t, strings.Contains(metadataNoSSHKeys["metadatakey2"], "123"), "Instance metadata should contain provided key: metadatakey2")
}
func TestStepCreateInstanceWaitToAddSSHKeys(t *testing.T) {
@ -422,7 +422,7 @@ func TestStepCreateInstanceWaitToAddSSHKeys(t *testing.T) {
d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100)
key := "abcdefgh12345678"
var waitTime int = 5
c.WaitToAddSSHKeys = time.Duration(waitTime) * time.Second
c.Comm.SSHPublicKey = []byte(key)
@ -455,14 +455,14 @@ func TestStepCreateInstanceNoWaitToAddSSHKeys(t *testing.T) {
d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100)
key := "abcdefgh12345678"
c.Comm.SSHPublicKey = []byte(key)
c.Metadata = map[string]string{
"metadatakey1": "xyz",
"metadatakey2": "123",
}
// run the step
assert.Equal(t, step.Run(context.Background(), state), multistep.ActionContinue, "Step should have passed and continued.")
@ -472,4 +472,4 @@ func TestStepCreateInstanceNoWaitToAddSSHKeys(t *testing.T) {
// cleanup
step.Cleanup(state)
}
}