Amend commit author for license pass
This commit is contained in:
parent
833855eec5
commit
d6831a4de3
|
@ -71,7 +71,7 @@ type Driver interface {
|
|||
DeleteOSLoginSSHKey(user, fingerprint string) error
|
||||
|
||||
// Add to the instance metadata for the existing instance
|
||||
AddToInstanceMetadata(zone string, name string, metadata map[string]string) (<-chan error, error)
|
||||
AddToInstanceMetadata(zone string, name string, metadata map[string]string) error
|
||||
}
|
||||
|
||||
type InstanceConfig struct {
|
||||
|
|
|
@ -728,11 +728,11 @@ func waitForState(errCh chan<- error, target string, refresh stateRefreshFunc) e
|
|||
return err
|
||||
}
|
||||
|
||||
func (d *driverGCE) AddToInstanceMetadata(zone string, name string, metadata map[string]string) (<-chan error, error) {
|
||||
func (d *driverGCE) AddToInstanceMetadata(zone string, name string, metadata map[string]string) error {
|
||||
|
||||
instance, err := d.service.Instances.Get(d.projectId, zone, name).Do()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
// Build up the metadata
|
||||
|
@ -753,7 +753,7 @@ func (d *driverGCE) AddToInstanceMetadata(zone string, name string, metadata map
|
|||
}).Do()
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return err
|
||||
}
|
||||
|
||||
newErrCh := make(chan error, 1)
|
||||
|
@ -762,8 +762,13 @@ func (d *driverGCE) AddToInstanceMetadata(zone string, name string, metadata map
|
|||
select {
|
||||
case err = <-newErrCh:
|
||||
case <-time.After(time.Second * 30):
|
||||
err = errors.New("time out while waiting for SSH keys to be added to instance")
|
||||
err = errors.New("time out while waiting for instance to create")
|
||||
}
|
||||
|
||||
return newErrCh, err
|
||||
if err != nil {
|
||||
newErrCh <- err
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -295,7 +295,7 @@ func (d *DriverMock) DeleteOSLoginSSHKey(user, fingerprint string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (d *DriverMock) AddToInstanceMetadata(zone string, name string, metadata map[string]string) (<-chan error, error) {
|
||||
func (d *DriverMock) AddToInstanceMetadata(zone string, name string, metadata map[string]string) error {
|
||||
d.AddToInstanceMetadataZone = zone
|
||||
d.AddToInstanceMetadataName = name
|
||||
d.AddToInstanceMetadataKVPairs = metadata
|
||||
|
@ -307,5 +307,5 @@ func (d *DriverMock) AddToInstanceMetadata(zone string, name string, metadata ma
|
|||
resultCh = ch
|
||||
}
|
||||
|
||||
return resultCh, d.AddToInstanceMetadataErr
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -141,8 +141,8 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||
name := c.InstanceName
|
||||
|
||||
var errCh <-chan error
|
||||
metadataNoSSHKeys := make(map[string]string)
|
||||
metadataSSHKeys := make(map[string]string)
|
||||
var metadataNoSSHKeys map[string]string
|
||||
var metadataSSHKeys map[string]string
|
||||
metadataForInstance := make(map[string]string)
|
||||
|
||||
metadataNoSSHKeys, metadataSSHKeys, errs := c.createInstanceMetadata(sourceImage, string(c.Comm.SSHPublicKey))
|
||||
|
@ -233,11 +233,12 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag)
|
|||
|
||||
log.Printf("[DEBUG] %s wait is over. Adding SSH keys to existing instance...",
|
||||
c.WaitToAddSSHKeys.String())
|
||||
errCh, err = d.AddToInstanceMetadata(c.Zone, name, metadataSSHKeys)
|
||||
err = d.AddToInstanceMetadata(c.Zone, name, metadataSSHKeys)
|
||||
|
||||
if err != nil {
|
||||
state.Put("error", errs.Error())
|
||||
ui.Error(errs.Error())
|
||||
err := fmt.Errorf("Error adding SSH keys to existing instance: %s", err)
|
||||
state.Put("error", err)
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
}
|
||||
|
@ -316,6 +317,7 @@ func (s *StepCreateInstance) Cleanup(state multistep.StateBag) {
|
|||
}
|
||||
|
||||
func addmap(a map[string]string, b map[string]string) {
|
||||
|
||||
for k, v := range b {
|
||||
a[k] = v
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue