Skip to content

Commit

Permalink
Enforce dependency build ownership of build recipe config map.
Browse files Browse the repository at this point in the history
  • Loading branch information
tecarter94 committed Sep 11, 2024
1 parent 53fe140 commit be58c5d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions deploy/operator/base/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ rules:
verbs:
- get
- create
- update
- apiGroups:
- ""
resources:
Expand Down
16 changes: 15 additions & 1 deletion pkg/reconciler/dependencybuild/dependencybuild.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,22 @@ func (r *ReconcileDependencyBuild) handleRedeployAnnotation(ctx context.Context,
func (r *ReconcileDependencyBuild) handleStateNew(ctx context.Context, db *v1alpha1.DependencyBuild) (reconcile.Result, error) {

log, _ := logr.FromContext(ctx)
var err error
if len(db.Spec.BuildRecipeConfigMap) > 0 {
configMap := v1.ConfigMap{}
err = r.client.Get(ctx, types.NamespacedName{Namespace: db.Namespace, Name: db.Spec.BuildRecipeConfigMap}, &configMap)
if err != nil {
return reconcile.Result{}, err
}
if err := controllerutil.SetOwnerReference(db, &configMap, r.scheme); err != nil {
return reconcile.Result{}, err
}
if err := r.client.Update(ctx, &configMap); err != nil {
return reconcile.Result{}, err
}
}
jbsConfig := &v1alpha1.JBSConfig{}
err := r.client.Get(ctx, types.NamespacedName{Namespace: db.Namespace, Name: v1alpha1.JBSConfigName}, jbsConfig)
err = r.client.Get(ctx, types.NamespacedName{Namespace: db.Namespace, Name: v1alpha1.JBSConfigName}, jbsConfig)
if err != nil && !errors.IsNotFound(err) {
return reconcile.Result{}, err
}
Expand Down

0 comments on commit be58c5d

Please sign in to comment.