address code review comments

pull/113/head
vaikas-google 10 years ago
parent 9041e8b644
commit 1ad5106b08

@ -38,7 +38,7 @@ type Deployer interface {
// NewDeployer returns a new initialized Deployer. // NewDeployer returns a new initialized Deployer.
// TODO(vaikas): Add a flag for setting the timeout. // TODO(vaikas): Add a flag for setting the timeout.
func NewDeployer(url string) Deployer { func NewDeployer(url string) Deployer {
return &deployer{url, 5} return &deployer{url, 15}
} }
type deployer struct { type deployer struct {
@ -126,7 +126,7 @@ func (d *deployer) callServiceWithConfiguration(method, operation string, config
return nil, fmt.Errorf("cannot unmarshal response: (%v)", err) return nil, fmt.Errorf("cannot unmarshal response: (%v)", err)
} }
} }
return result, err return result, nil
} }
func (d *deployer) callService(method, url string, reader io.Reader, callback formatter) ([]byte, error) { func (d *deployer) callService(method, url string, reader io.Reader, callback formatter) ([]byte, error) {
@ -140,9 +140,7 @@ func (d *deployer) callService(method, url string, reader io.Reader, callback fo
} }
timeout := time.Duration(time.Duration(d.timeout) * time.Second) timeout := time.Duration(time.Duration(d.timeout) * time.Second)
client := http.Client{ client := http.Client{Timeout: timeout}
Timeout: timeout,
}
response, err := client.Do(request) response, err := client.Do(request)
if err != nil { if err != nil {
return nil, callback(err) return nil, callback(err)

@ -104,9 +104,8 @@ func (m *manager) CreateDeployment(t *Template) (*Deployment, error) {
return nil, err return nil, err
} }
actualConfig, err := m.deployer.CreateConfiguration(manifest.ExpandedConfig) actualConfig, createErr := m.deployer.CreateConfiguration(manifest.ExpandedConfig)
log.Printf("Got Back %s", actualConfig) if createErr != nil {
if err != nil {
// Deployment failed, mark as failed // Deployment failed, mark as failed
log.Printf("CreateConfiguration failed: %v", err) log.Printf("CreateConfiguration failed: %v", err)
m.repository.SetDeploymentStatus(t.Name, FailedStatus) m.repository.SetDeploymentStatus(t.Name, FailedStatus)
@ -114,7 +113,7 @@ func (m *manager) CreateDeployment(t *Template) (*Deployment, error) {
// return the failure as such. Otherwise, we're going to add the manifest // return the failure as such. Otherwise, we're going to add the manifest
// and hence resource specific errors down below. // and hence resource specific errors down below.
if actualConfig == nil { if actualConfig == nil {
return nil, err return nil, createErr
} }
} else { } else {
m.repository.SetDeploymentStatus(t.Name, DeployedStatus) m.repository.SetDeploymentStatus(t.Name, DeployedStatus)
@ -131,8 +130,8 @@ func (m *manager) CreateDeployment(t *Template) (*Deployment, error) {
// to a check fail (either deployment doesn't exist, or a manifest with the same // to a check fail (either deployment doesn't exist, or a manifest with the same
// name already exists). // name already exists).
// TODO(vaikas): Should we combine both errors and return a nicely formatted error for both? // TODO(vaikas): Should we combine both errors and return a nicely formatted error for both?
if err != nil { if createErr != nil {
return nil, err return nil, createErr
} else { } else {
return nil, aErr return nil, aErr
} }

Loading…
Cancel
Save