예제 #1
0
// CreateDeployment creates a new deployment and stores it in the repository.
func (r *pRepository) CreateDeployment(name string) (*common.Deployment, error) {
	exists, _ := r.GetValidDeployment(name)
	if exists != nil {
		return nil, fmt.Errorf("deployment %s already exists", name)
	}

	d := common.NewDeployment(name)
	if err := r.insertDeployment(d); err != nil {
		return nil, err
	}

	log.Printf("created deployment: %v", d)
	return d, nil
}
예제 #2
0
// CreateDeployment creates a new deployment and stores it in the repository.
func (r *tRepository) CreateDeployment(name string) (*common.Deployment, error) {
	r.Lock()
	defer r.Unlock()

	exists, _ := r.GetValidDeployment(name)
	if exists != nil {
		return nil, fmt.Errorf("Deployment %s already exists", name)
	}

	d := common.NewDeployment(name)
	r.deployments[name] = *d

	log.Printf("created deployment: %v", d)
	return d, nil
}
예제 #3
0
// CreateDeployment creates a new deployment and stores it in the repository.
func (r *mapBasedRepository) CreateDeployment(name string) (*common.Deployment, error) {
	d, err := func() (*common.Deployment, error) {
		r.Lock()
		defer r.Unlock()

		exists, _ := r.GetValidDeployment(name)
		if exists != nil {
			return nil, fmt.Errorf("Deployment %s already exists", name)
		}

		d := common.NewDeployment(name)
		d.DeployedAt = time.Now()
		r.deployments[name] = *d
		return d, nil
	}()

	if err != nil {
		return nil, err
	}

	log.Printf("created deployment: %v", d)
	return d, nil
}