Skip to content
Merged
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
2 changes: 2 additions & 0 deletions config/base/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ resources:
- role.yaml
- role_binding.yaml
- operator.yaml
- tekton_config_role.yaml
- tekton_config_role_binding.yaml
22 changes: 22 additions & 0 deletions config/base/tekton_config_role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Copyright 2022 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: tekton-config-read-role
rules:
- apiGroups: ["operator.tekton.dev"]
resources: ["tektonconfigs"]
verbs: ["get", "watch", "list"]
26 changes: 26 additions & 0 deletions config/base/tekton_config_role_binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Copyright 2022 The Tekton Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: tekton-config-read-rolebinding
subjects:
- kind: Group
apiGroup: rbac.authorization.k8s.io
name: 'system:authenticated'
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: tekton-config-read-role
18 changes: 18 additions & 0 deletions docs/TektonConfig.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ The TektonConfig CR provides the following features
- pipelinerun
keep: 3
schedule: "* * * * *"
hub:
params:
- name: enable-devconsole-integration
value: "true"
dashboard:
readonly: true
```
Expand Down Expand Up @@ -166,6 +170,20 @@ addon:
**NOTE**: TektonAddon is currently available for OpenShift Platform only. Enabling this for Kubernetes platform is in roadmap
of Operator.

### Hub

This is to enable/disable showing hub resources in pipeline builder of devconsole(OpenShift UI). By default, the field is
not there in the config object. If you want to disable the integration, you can add the param like below in config with value `false`.
The possible values are `true` and `false`.

Example:
```yaml
hub:
params:
- name: enable-devconsole-integration
value: "false"
```

### Dashboard

Dashboard provides configuration options for the Tekton Dashboard if the specified profile value includes the Dashboard component. (E.g. `all` on Kubernetes)
Expand Down
7 changes: 7 additions & 0 deletions pkg/apis/operator/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const (
ClusterTasksParam = "clusterTasks"
PipelineTemplatesParam = "pipelineTemplates"

// Hub Params
EnableDevconsoleIntegrationParam = "enable-devconsole-integration"

ApiFieldAlpha = "alpha"
ApiFieldStable = "stable"
)
Expand All @@ -63,6 +66,10 @@ var (
ClusterTasksParam: defaultParamValue,
PipelineTemplatesParam: defaultParamValue,
}

HubParams = map[string]ParamValue{
EnableDevconsoleIntegrationParam: defaultParamValue,
}
)

var (
Expand Down
3 changes: 3 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ type TektonConfigSpec struct {
// Addon holds the addons config
// +optional
Addon Addon `json:"addon,omitempty"`
// Hub holds the hub config
// +optional
Hub Hub `json:"hub,omitempty"`
// Pipeline holds the customizable option for pipeline component
// +optional
Pipeline Pipeline `json:"pipeline,omitempty"`
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonconfig_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func (tc *TektonConfig) Validate(ctx context.Context) (errs *apis.FieldError) {
errs = errs.Also(validateAddonParams(tc.Spec.Addon.Params, "spec.addon.params"))
}

if !tc.Spec.Hub.IsEmpty() {
errs = errs.Also(validateHubParams(tc.Spec.Hub.Params, "spec.hub.params"))
}

errs = errs.Also(tc.Spec.Pipeline.PipelineProperties.validate("spec.pipeline"))

return errs.Also(tc.Spec.Trigger.TriggersProperties.validate("spec.trigger"))
Expand Down
28 changes: 28 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonhub_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
Copyright 2022 The Tekton Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

// Hub defines the field to customize Hub component
type Hub struct {
// Params is the list of params passed for Hub customization
// +optional
Params []Param `json:"params,omitempty"`
}

func (h Hub) IsEmpty() bool {
return len(h.Params) == 0
}
39 changes: 39 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonhub_validation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
Copyright 2022 The Tekton Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"knative.dev/pkg/apis"
)

func validateHubParams(params []Param, pathToParams string) *apis.FieldError {
var errs *apis.FieldError

for i, p := range params {
paramValue, ok := HubParams[p.Name]
if !ok {
errs = errs.Also(apis.ErrInvalidKeyName(p.Name, pathToParams))
continue
}
if !isValueInArray(paramValue.Possible, p.Value) {
path := pathToParams + "." + p.Name
errs = errs.Also(apis.ErrInvalidArrayValue(p.Value, path, i))
}
}

return errs
}
79 changes: 79 additions & 0 deletions pkg/apis/operator/v1alpha1/tektonhub_validation_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
Copyright 2022 The Tekton Authors

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"context"
"testing"

"gotest.tools/v3/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func Test_ValidateTektonConfig_InvalidHubParam(t *testing.T) {

tc := &TektonConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "config",
Namespace: "namespace",
},
Spec: TektonConfigSpec{
CommonSpec: CommonSpec{
TargetNamespace: "namespace",
},
Profile: "all",
Hub: Hub{
Params: []Param{
{
Name: "invalid-param",
Value: "val",
},
},
},
},
}

err := tc.Validate(context.TODO())
assert.Equal(t, "invalid key name \"invalid-param\": spec.hub.params", err.Error())
}

func Test_ValidateTektonConfig_InvalidHubParamValue(t *testing.T) {

tc := &TektonConfig{
ObjectMeta: metav1.ObjectMeta{
Name: "config",
Namespace: "namespace",
},
Spec: TektonConfigSpec{
CommonSpec: CommonSpec{
TargetNamespace: "namespace",
},
Profile: "all",
Hub: Hub{
Params: []Param{
{
Name: "enable-devconsole-integration",
Value: "test",
},
},
},
},
}

err := tc.Validate(context.TODO())
assert.Equal(t, "invalid value: test: spec.hub.params.enable-devconsole-integration[0]", err.Error())
}
22 changes: 22 additions & 0 deletions pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go

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