Ejemplo n.º 1
0
// Update replaces a given BuildConfig instance with an existing instance in storage.registry.
func (storage *Storage) Update(obj interface{}) (<-chan interface{}, error) {
	buildConfig, ok := obj.(*api.BuildConfig)
	if !ok {
		return nil, fmt.Errorf("not a buildConfig: %#v", obj)
	}
	if errs := validation.ValidateBuildConfig(buildConfig); len(errs) > 0 {
		return nil, errors.NewInvalid("buildConfig", buildConfig.ID, errs)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		err := storage.registry.UpdateBuildConfig(buildConfig)
		if err != nil {
			return nil, err
		}
		return buildConfig, nil
	}), nil
}
Ejemplo n.º 2
0
// Create registers a given new BuildConfig instance to storage.registry.
func (storage *Storage) Create(obj interface{}) (<-chan interface{}, error) {
	buildConfig, ok := obj.(*api.BuildConfig)
	if !ok {
		return nil, fmt.Errorf("not a buildConfig: %#v", obj)
	}
	if len(buildConfig.ID) == 0 {
		buildConfig.ID = uuid.NewUUID().String()
	}
	buildConfig.CreationTimestamp = util.Now()
	if errs := validation.ValidateBuildConfig(buildConfig); len(errs) > 0 {
		return nil, errors.NewInvalid("buildConfig", buildConfig.ID, errs)
	}
	return apiserver.MakeAsync(func() (interface{}, error) {
		err := storage.registry.CreateBuildConfig(buildConfig)
		if err != nil {
			return nil, err
		}
		return buildConfig, nil
	}), nil
}
Ejemplo n.º 3
0
// Validate validates a new policy.
func (strategy) Validate(ctx kapi.Context, obj runtime.Object) fielderrors.ValidationErrorList {
	return validation.ValidateBuildConfig(obj.(*api.BuildConfig))
}