diff --git a/docs/TekonDashboard.md b/docs/TekonDashboard.md index 373abd4696..16a8a45263 100644 --- a/docs/TekonDashboard.md +++ b/docs/TekonDashboard.md @@ -12,6 +12,7 @@ metadata: name: dashboard spec: targetNamespace: tekton-pipelines + readonly: false ``` You can install this component using [TektonConfig](./TektonConfig.md) by choosing appropriate `profile`. diff --git a/docs/TektonConfig.md b/docs/TektonConfig.md index 0e4b3b3c49..799d18760f 100644 --- a/docs/TektonConfig.md +++ b/docs/TektonConfig.md @@ -1,6 +1,6 @@ # Tekton Config -TektonConfig custom resource is the top most component of the operator which allows user to install and customize all other +TektonConfig custom resource is the top most component of the operator which allows user to install and customize all other components at a single place. Operator provides support for installing and managing following operator components through `TektonConfig`: @@ -11,7 +11,7 @@ Other than the above components depending on the platform operator also provides - On Kubernetes - [TektonDashboard](./TekonDashboard.md) - On OpenShift - - [TektonAddon](./TektonAddon.md) + - [TektonAddon](./TektonAddon.md) The TektonConfig CR provides the following features @@ -35,7 +35,8 @@ The TektonConfig CR provides the following features require-git-ssh-secret-known-hosts: false running-in-environment-with-injected-sidecars: true pruner: {} - addon: {} + addon: {} + dashboard: {} ``` Look for the particular section to understand a particular field in the spec. @@ -45,13 +46,13 @@ This allows user to choose a namespace to install all the pipelines, triggers an By default, namespace would be `tekton-pipelines` for Kubernetes and `openshift-pipelines` for OpenShift. ### Profile -This allows user to choose which all components to install on the cluster. +This allows user to choose which all components to install on the cluster. There are 3 profiles available: -- `all`: This profile will install all components +- `all`: This profile will install all components - `basic`: This profile will install TektonPipeline and TektonTrigger component - `lite`: This profile will install only TektonPipeline component -On Kubernetes, `all` profile will install `TektonDashboard` and on OpenShift `TektonAddon` will be installed. +On Kubernetes, `all` profile will install `TektonDashboard` and on OpenShift `TektonAddon` will be installed. ### Config @@ -59,7 +60,7 @@ Config provides fields to configure deployments created by the Operator. This provides following fields: - [`nodeSelector`][node-selector] - [`toleration`][toleration] - + User can pass the required fields and this would be passed to all Operator components which will get added in all deployments created by Operator. @@ -72,7 +73,7 @@ config: - key: "key1" operator: "Equal" value: "value1" - effect: "NoSchedule" + effect: "NoSchedule" ``` This is an `Optional` section. @@ -122,7 +123,7 @@ This is an `Optional` section. ### Addon -TektonAddon install some resources along with Tekton Pipelines on the cluster. This provides few ClusterTasks, PipelineTemplates. +TektonAddon install some resources along with Tekton Pipelines on the cluster. This provides few ClusterTasks, PipelineTemplates. This section allows to customize installation of those resources through params. You can read more about the supported params [here](./TektonAddon.md). @@ -139,6 +140,22 @@ addon: **NOTE**: TektonAddon is currently available for OpenShift Platform only. Enabling this for Kubernetes platform is in roadmap of Operator. +### Dashboard + +Dashboard provides configuration options for the Tekton Dashboard if the specified profile value includes the Dashboard component. (E.g. `all` on Kubernetes) + +Example: + +```yaml +dashboard: + readonly: true +``` + +- `readonly`: If set to true, install the Dashboard in read-only mode + +This is an `Optional` section. + + [node-selector]:https://kubernetes.io/docs/concepts/scheduling-eviction/assign-pod-node/#nodeselector [toleration]:https://kubernetes.io/docs/concepts/scheduling-eviction/taint-and-toleration/ [schedule]:https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#cron-schedule-syntax diff --git a/hack/fetch-releases.sh b/hack/fetch-releases.sh index eeb55e6360..55b21b5b0a 100755 --- a/hack/fetch-releases.sh +++ b/hack/fetch-releases.sh @@ -20,7 +20,18 @@ release_yaml() { dir="trigger" fi - #nightly -> 0.0.0-nightly + if [[ $comp == "dashboard" ]]; then + if [[ ${releaseFileName} == "tekton-dashboard-release" ]]; then + dir="dashboard/tekton-dashboard-fullaccess" + fi + + if [[ ${releaseFileName} == "tekton-dashboard-release-readonly" ]]; then + dir="dashboard/tekton-dashboard-readonly" + fi + fi + + + #nightly -> 0.0.0-nightly` #latest -> find version till then -> 0.0.0-latest #version -> directory with version @@ -97,6 +108,7 @@ main() { if [[ ${TARGET} != "openshift" ]]; then d_version=${4} release_yaml dashboard tekton-dashboard-release 00-dashboard ${d_version} + release_yaml dashboard tekton-dashboard-release-readonly 00-dashboard ${d_version} r_version=${5} release_yaml results release 00-results ${r_version} diff --git a/pkg/apis/operator/v1alpha1/tektonconfig_types.go b/pkg/apis/operator/v1alpha1/tektonconfig_types.go index f33b26274a..b4dcede530 100644 --- a/pkg/apis/operator/v1alpha1/tektonconfig_types.go +++ b/pkg/apis/operator/v1alpha1/tektonconfig_types.go @@ -86,6 +86,9 @@ type TektonConfigSpec struct { // Trigger holds the customizable option for triggers component // +optional Trigger Trigger `json:"trigger,omitempty"` + // Dashboard holds the customizable options for dashboards component + // +optional + Dashboard Dashboard `json:"dashboard,omitempty"` } // TektonConfigStatus defines the observed state of TektonConfig @@ -130,6 +133,11 @@ type Trigger struct { TriggersProperties `json:",inline"` } +// Dashboard degines the fields to customize the Dashboard component +type Dashboard struct { + DashboardProperties `json:",inline"` +} + type Config struct { NodeSelector map[string]string `json:"nodeSelector,omitempty"` Tolerations []corev1.Toleration `json:"tolerations,omitempty"` diff --git a/pkg/apis/operator/v1alpha1/tektondashboard_types.go b/pkg/apis/operator/v1alpha1/tektondashboard_types.go index a0f4004720..b290388763 100644 --- a/pkg/apis/operator/v1alpha1/tektondashboard_types.go +++ b/pkg/apis/operator/v1alpha1/tektondashboard_types.go @@ -51,7 +51,8 @@ func (tp *TektonDashboard) GetStatus() TektonComponentStatus { // TektonDashboardSpec defines the desired state of TektonDashboard type TektonDashboardSpec struct { - CommonSpec `json:",inline"` + CommonSpec `json:",inline"` + DashboardProperties `json:",inline"` // Config holds the configuration for resources created by TektonDashboard // +optional Config Config `json:"config,omitempty"` @@ -77,3 +78,9 @@ type TektonDashboardList struct { metav1.ListMeta `json:"metadata,omitempty"` Items []TektonDashboard `json:"items"` } + +// Dashboard degines the fields to customize the Dashboard component +type DashboardProperties struct { + // Readonly when set to true configures the Tekton dashboard in read-only mode + Readonly bool `json:"readonly"` +} diff --git a/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go index 2dcca1491f..2488381cea 100644 --- a/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go @@ -93,6 +93,39 @@ func (in *Config) DeepCopy() *Config { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *Dashboard) DeepCopyInto(out *Dashboard) { + *out = *in + out.DashboardProperties = in.DashboardProperties + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new Dashboard. +func (in *Dashboard) DeepCopy() *Dashboard { + if in == nil { + return nil + } + out := new(Dashboard) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *DashboardProperties) DeepCopyInto(out *DashboardProperties) { + *out = *in + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DashboardProperties. +func (in *DashboardProperties) DeepCopy() *DashboardProperties { + if in == nil { + return nil + } + out := new(DashboardProperties) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *OptionalPipelineProperties) DeepCopyInto(out *OptionalPipelineProperties) { *out = *in @@ -431,6 +464,7 @@ func (in *TektonConfigSpec) DeepCopyInto(out *TektonConfigSpec) { in.Addon.DeepCopyInto(&out.Addon) in.Pipeline.DeepCopyInto(&out.Pipeline) out.Trigger = in.Trigger + out.Dashboard = in.Dashboard return } @@ -531,6 +565,7 @@ func (in *TektonDashboardList) DeepCopyObject() runtime.Object { func (in *TektonDashboardSpec) DeepCopyInto(out *TektonDashboardSpec) { *out = *in out.CommonSpec = in.CommonSpec + out.DashboardProperties = in.DashboardProperties in.Config.DeepCopyInto(&out.Config) return } diff --git a/pkg/reconciler/common/releases.go b/pkg/reconciler/common/releases.go index 49bd39a66d..1cdbbdf71a 100644 --- a/pkg/reconciler/common/releases.go +++ b/pkg/reconciler/common/releases.go @@ -76,13 +76,16 @@ func Fetch(path string) (mf.Manifest, error) { func ComponentDir(instance v1alpha1.TektonComponent) string { koDataDir := os.Getenv(KoEnvKey) - switch instance.(type) { + switch ins := instance.(type) { case *v1alpha1.TektonPipeline: return filepath.Join(koDataDir, "tekton-pipeline") case *v1alpha1.TektonTrigger: return filepath.Join(koDataDir, "tekton-trigger") case *v1alpha1.TektonDashboard: - return filepath.Join(koDataDir, "tekton-dashboard") + if ins.Spec.Readonly { + return filepath.Join(koDataDir, "tekton-dashboard/tekton-dashboard-readonly") + } + return filepath.Join(koDataDir, "tekton-dashboard/tekton-dashboard-fullaccess") case *v1alpha1.TektonAddon: return filepath.Join(koDataDir, "tekton-addon") case *v1alpha1.TektonConfig: diff --git a/pkg/reconciler/kubernetes/tektonconfig/extension/dashboard.go b/pkg/reconciler/kubernetes/tektonconfig/extension/dashboard.go index 4146bae98d..3cb4b237a7 100644 --- a/pkg/reconciler/kubernetes/tektonconfig/extension/dashboard.go +++ b/pkg/reconciler/kubernetes/tektonconfig/extension/dashboard.go @@ -57,6 +57,11 @@ func ensureTektonDashboardExists(clients op.TektonDashboardInterface, config *v1 updated = true } + if !reflect.DeepEqual(tdCR.Spec.DashboardProperties, config.Spec.Dashboard.DashboardProperties) { + tdCR.Spec.DashboardProperties = config.Spec.Dashboard.DashboardProperties + updated = true + } + if !reflect.DeepEqual(tdCR.Spec.Config, config.Spec.Config) { tdCR.Spec.Config = config.Spec.Config updated = true @@ -84,7 +89,8 @@ func ensureTektonDashboardExists(clients op.TektonDashboardInterface, config *v1 CommonSpec: v1alpha1.CommonSpec{ TargetNamespace: config.Spec.TargetNamespace, }, - Config: config.Spec.Config, + Config: config.Spec.Config, + DashboardProperties: config.Spec.Dashboard.DashboardProperties, }, } return clients.Create(context.TODO(), tdCR, metav1.CreateOptions{}) diff --git a/tekton/task-fetch-components.yaml b/tekton/task-fetch-components.yaml index 3512920817..f18dcbec7e 100644 --- a/tekton/task-fetch-components.yaml +++ b/tekton/task-fetch-components.yaml @@ -125,6 +125,7 @@ spec: d_version=${4} release_yaml dashboard tekton-dashboard-release 00-dashboard ${d_version} + release_yaml dashboard tekton-dashboard-release-readonly 00-dashboard-readonly ${d_version} r_version=${5} release_yaml results release 00-results ${r_version} @@ -138,4 +139,4 @@ spec: runAsUser: 0 workspaces: - mountPath: /go/src/github.com/tektoncd/operator - name: source \ No newline at end of file + name: source diff --git a/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go b/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go index a0b97e3f77..92d70934d6 100644 --- a/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go +++ b/third_party/github.com/hashicorp/golang-lru/simplelru/lru_interface.go @@ -34,6 +34,6 @@ type LRUCache interface { // Clears all cache entries. Purge() - // Resizes cache, returning number evicted - Resize(int) int + // Resizes cache, returning number evicted + Resize(int) int }