Skip to content

Commit

Permalink
Allow manually trigger PaC builds,
Browse files Browse the repository at this point in the history
by adding request 'trigger-pac-build'

STONEBLD-1438

Signed-off-by: Robert Cerven <[email protected]>
  • Loading branch information
rcerven committed Oct 19, 2023
1 parent 99cebd0 commit 3b27c5b
Show file tree
Hide file tree
Showing 8 changed files with 723 additions and 38 deletions.
9 changes: 9 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ rules:
- customresourcedefinitions
verbs:
- get
- apiGroups:
- appstudio.redhat.com
resources:
- applications
verbs:
- get
- list
- watch
- apiGroups:
- appstudio.redhat.com
resources:
Expand Down Expand Up @@ -80,6 +88,7 @@ rules:
- secrets
verbs:
- create
- delete
- get
- list
- patch
Expand Down
15 changes: 14 additions & 1 deletion controllers/component_build_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import (
const (
BuildRequestAnnotationName = "build.appstudio.openshift.io/request"
BuildRequestTriggerSimpleBuildAnnotationValue = "trigger-simple-build"
BuildRequestTriggerPaCBuildAnnotationValue = "trigger-pac-build"
BuildRequestConfigurePaCAnnotationValue = "configure-pac"
BuildRequestUnconfigurePaCAnnotationValue = "unconfigure-pac"

Expand Down Expand Up @@ -175,14 +176,15 @@ func (r *ComponentBuildReconciler) SetupWithManager(mgr ctrl.Manager) error {
Complete(r)
}

//+kubebuilder:rbac:groups=appstudio.redhat.com,resources=applications,verbs=get;list;watch
//+kubebuilder:rbac:groups=appstudio.redhat.com,resources=components,verbs=get;list;watch;update;patch
//+kubebuilder:rbac:groups=appstudio.redhat.com,resources=components/status,verbs=get;list;watch
//+kubebuilder:rbac:groups=appstudio.redhat.com,resources=buildpipelineselectors,verbs=get;list;watch;create;update;patch
//+kubebuilder:rbac:groups=appstudio.redhat.com,resources=spiaccesstokenbindings,verbs=get;list;watch
//+kubebuilder:rbac:groups=tekton.dev,resources=pipelineruns,verbs=create
//+kubebuilder:rbac:groups=pipelinesascode.tekton.dev,resources=repositories,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch
//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;patch;update
//+kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;patch;update;delete
//+kubebuilder:rbac:groups="",resources=serviceaccounts,verbs=get;list;watch;create;update;patch
//+kubebuilder:rbac:groups="",resources=events,verbs=create;patch
//+kubebuilder:rbac:groups=route.openshift.io,resources=routes,verbs=get;list;watch
Expand Down Expand Up @@ -352,6 +354,17 @@ func (r *ComponentBuildReconciler) Reconcile(ctx context.Context, req ctrl.Reque
buildStatus.Message = "done"
writeBuildStatus(&component, buildStatus)

case BuildRequestTriggerPaCBuildAnnotationValue:
if err := r.TriggerPaCBuild(ctx, &component); err != nil {
if boErr, ok := err.(*boerrors.BuildOpError); ok && boErr.IsPersistent() {
log.Error(err, "PaC build trigger for the Component failed")
} else {
// transient error, retry
log.Error(err, "PaC build trigger for Component transient error")
}
return ctrl.Result{}, err
}

case BuildRequestConfigurePaCAnnotationValue:
pacBuildStatus := &PaCBuildStatus{}
if mergeUrl, err := r.ProvisionPaCForComponent(ctx, &component); err != nil {
Expand Down
Loading

0 comments on commit 3b27c5b

Please sign in to comment.