Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@ spec:

The operator will deploy Shipwright Builds in the provided `targetNamespace`.
When `.spec.targetNamespace` is not set, the namespace will default to `shipwright-build`.

To deploy [Shipwright Triggers](https://github.com/shipwright-io/triggers), add the `triggers` field:

```yaml
---
apiVersion: operator.shipwright.io/v1alpha1
kind: ShipwrightBuild
metadata:
name: shipwright-operator
spec:
targetNamespace: shipwright-build
triggers:
deployment: Enabled
```

Refer to the [ShipwrightBuild documentation](docs/shipwrightbuild.md) for more information about this custom resource.

The operator handles differents environment variables to customize Shiprwright controller installation:
Expand All @@ -52,6 +67,7 @@ The operator handles differents environment variables to customize Shiprwright c
- IMAGE_SHIPWRIGHT_BUNDLE_CONTAINER_IMAGE: defines the Shipwright Bundle Image to use
- IMAGE_SHIPWRIGHT_WAITER_CONTAINER_IMAGE: defines the Shipwright Waiter Image to use
- IMAGE_SHIPWRIGHT_SHIPWRIGHT_BUILD_WEBHOOK: defines the Shipwright Build Webhook Image to use
- IMAGE_SHIPWRIGHT_SHIPWRIGHT_TRIGGERS: defines the Shipwright Triggers Image to use

For more information about the function of these images, please consider the Shipwright Build doc https://github.com/shipwright-io/build/blob/main/docs/configuration.md

Expand Down
37 changes: 37 additions & 0 deletions api/v1alpha1/shipwrightbuild_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,47 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// TriggersDeployment indicates whether the Shipwright Triggers component
// should be deployed.
// +kubebuilder:validation:Enum=Enabled;Disabled
type TriggersDeployment string

const (
// TriggersDeploymentEnabled indicates that the Shipwright Triggers
// component should be deployed.
TriggersDeploymentEnabled TriggersDeployment = "Enabled"
// TriggersDeploymentDisabled indicates that the Shipwright Triggers
// component should not be deployed.
TriggersDeploymentDisabled TriggersDeployment = "Disabled"
)

// TriggersSpec defines the desired state of the Triggers component.
type TriggersSpec struct {
// Deployment controls whether the triggers component is deployed.
// Defaults to "Disabled".
// +kubebuilder:default=Disabled
// +optional
Deployment TriggersDeployment `json:"deployment,omitempty"`
}

// ShipwrightBuildSpec defines the configuration of a Shipwright Build deployment.
type ShipwrightBuildSpec struct {
// TargetNamespace is the target namespace where Shipwright's build controller will be deployed.
TargetNamespace string `json:"targetNamespace,omitempty"`

// Triggers configures the deployment of the Shipwright Triggers component.
// When omitted, triggers are not deployed.
// +optional
Triggers *TriggersSpec `json:"triggers,omitempty"`
}

// TriggersEnabled returns true if the Triggers component should be deployed.
// Triggers are only deployed when spec.triggers.deployment is set to "Enabled".
func (s *ShipwrightBuildSpec) TriggersEnabled() bool {
if s.Triggers == nil {
return false
}
return s.Triggers.Deployment == TriggersDeploymentEnabled
}

// ShipwrightBuildStatus defines the observed state of ShipwrightBuild
Expand Down
22 changes: 21 additions & 1 deletion api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions bundle/manifests/operator.shipwright.io_shipwrightbuilds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ spec:
description: TargetNamespace is the target namespace where Shipwright's
build controller will be deployed.
type: string
triggers:
description: |-
Triggers configures the deployment of the Shipwright Triggers component.
When omitted, triggers are not deployed.
properties:
deployment:
default: Disabled
description: |-
Deployment controls whether the triggers component is deployed.
Defaults to "Disabled".
enum:
- Enabled
- Disabled
type: string
type: object
type: object
status:
description: ShipwrightBuildStatus defines the observed state of ShipwrightBuild
Expand Down
86 changes: 86 additions & 0 deletions bundle/manifests/shipwright-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,17 @@ spec:
- delete
- patch
- update
- apiGroups:
- ""
resourceNames:
- shipwright-triggers
resources:
- serviceaccounts
- services
verbs:
- delete
- patch
- update
- apiGroups:
- admissionregistration.k8s.io
- admissionregistration.k8s.io/v1beta1
Expand Down Expand Up @@ -389,6 +400,16 @@ spec:
- delete
- patch
- update
- apiGroups:
- apps
resourceNames:
- shipwright-triggers
resources:
- deployments
verbs:
- delete
- patch
- update
- apiGroups:
- apps
resourceNames:
Expand All @@ -405,6 +426,14 @@ spec:
- deployments/finalizers
verbs:
- update
- apiGroups:
- apps
resourceNames:
- shipwright-triggers
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- cert-manager.io
resourceNames:
Expand Down Expand Up @@ -505,6 +534,19 @@ spec:
- delete
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
- shipwright-triggers
resources:
- clusterrolebindings
- clusterroles
- rolebindings
- roles
verbs:
- delete
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
Expand Down Expand Up @@ -549,6 +591,50 @@ spec:
- subjectaccessreviews
verbs:
- create
- apiGroups:
- shipwright.io
resources:
- buildruns
verbs:
- create
- get
- list
- update
- watch
- apiGroups:
- shipwright.io
resources:
- builds
verbs:
- get
- list
- watch
- apiGroups:
- tekton.dev
resources:
- customruns
verbs:
- get
- list
- watch
- apiGroups:
- tekton.dev
resources:
- customruns/finalizers
- customruns/status
verbs:
- patch
- update
- apiGroups:
- tekton.dev
resources:
- pipelineruns
verbs:
- get
- list
- patch
- update
- watch
serviceAccountName: shipwright-operator
deployments:
- label:
Expand Down
15 changes: 15 additions & 0 deletions config/crd/bases/operator.shipwright.io_shipwrightbuilds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,21 @@ spec:
description: TargetNamespace is the target namespace where Shipwright's
build controller will be deployed.
type: string
triggers:
description: |-
Triggers configures the deployment of the Shipwright Triggers component.
When omitted, triggers are not deployed.
properties:
deployment:
default: Disabled
description: |-
Deployment controls whether the triggers component is deployed.
Defaults to "Disabled".
enum:
- Enabled
- Disabled
type: string
type: object
type: object
status:
description: ShipwrightBuildStatus defines the observed state of ShipwrightBuild
Expand Down
2 changes: 2 additions & 0 deletions config/rbac/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ resources:
- shipwright_build_aggregate_role_binding.yaml
- shipwright_build_webhook_role.yaml
- shipwright_build_webhook_role_binding.yaml
- shipwright_triggers_controller_role.yaml
- shipwright_triggers_controller_role_binding.yaml
42 changes: 42 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,17 @@ rules:
- delete
- patch
- update
- apiGroups:
- ""
resourceNames:
- shipwright-triggers
resources:
- serviceaccounts
- services
verbs:
- delete
- patch
- update
- apiGroups:
- admissionregistration.k8s.io
- admissionregistration.k8s.io/v1beta1
Expand Down Expand Up @@ -115,6 +126,16 @@ rules:
- delete
- patch
- update
- apiGroups:
- apps
resourceNames:
- shipwright-triggers
resources:
- deployments
verbs:
- delete
- patch
- update
- apiGroups:
- apps
resourceNames:
Expand All @@ -131,6 +152,14 @@ rules:
- deployments/finalizers
verbs:
- update
- apiGroups:
- apps
resourceNames:
- shipwright-triggers
resources:
- deployments/finalizers
verbs:
- update
- apiGroups:
- cert-manager.io
resourceNames:
Expand Down Expand Up @@ -231,6 +260,19 @@ rules:
- delete
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
- shipwright-triggers
resources:
- clusterrolebindings
- clusterroles
- rolebindings
- roles
verbs:
- delete
- patch
- update
- apiGroups:
- rbac.authorization.k8s.io
resourceNames:
Expand Down
20 changes: 20 additions & 0 deletions config/rbac/shipwright_triggers_controller_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: triggers-controller
rules:
- apiGroups: ['shipwright.io']
resources: ['buildruns']
verbs: ['create', 'get', 'list', 'update', 'watch']
- apiGroups: ['shipwright.io']
resources: ['builds']
verbs: ['get', 'list', 'watch']
- apiGroups: ['tekton.dev']
resources: ['customruns']
verbs: ['get', 'list', 'watch']
- apiGroups: ['tekton.dev']
resources: ['customruns/finalizers', 'customruns/status']
verbs: ['patch', 'update']
- apiGroups: ['tekton.dev']
resources: ['pipelineruns']
verbs: ['get', 'list', 'patch', 'update', 'watch']
12 changes: 12 additions & 0 deletions config/rbac/shipwright_triggers_controller_role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: triggers-controller
roleRef:
kind: ClusterRole
name: triggers-controller
apiGroup: rbac.authorization.k8s.io
subjects:
- kind: ServiceAccount
name: operator
namespace: system
Loading
Loading