Skip to content

Commit

Permalink
Remove creation of cluster task installersets
Browse files Browse the repository at this point in the history
This patch will remove the creation of cluster task installersets
but keep the existing cluster task installersets

Signed-off-by: Shiv Verma <[email protected]>
  • Loading branch information
pratap0007 committed Oct 21, 2024
1 parent efd8c40 commit f743fbf
Show file tree
Hide file tree
Showing 20 changed files with 41 additions and 339 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ spec:
targetNamespace: openshift-pipelines
addon:
params:
- name: clusterTasks
value: "true"
- name: pipelineTemplates
value: "true"
- name: communityClusterTasks
value: "true"
- name: resolverTasks
value: "true"
- name: resolverStepActions
Expand Down
6 changes: 1 addition & 5 deletions docs/TektonAddon.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ weight: 6
-->
# Tekton Addon

TektonAddon custom resource allows user to install resource like clusterTasks and pipelineTemplate along with Pipelines.
TektonAddon custom resource allows user to install resource like resolverTasks and pipelineTemplate along with Pipelines.
It also allows user to install various Tasks in openshift-pipelines namespace.

**NOTE:** TektonAddon is currently available only for OpenShift Platform. This is roadmap to enable it for Kubernetes platform.
Expand All @@ -22,8 +22,6 @@ metadata:
spec:
targetNamespace: openshift-pipelines
params:
- name: clusterTasks
value: "true"
- name: pipelineTemplates
value: "true"
- name: resolverTasks
Expand All @@ -37,8 +35,6 @@ You can install this component using [TektonConfig](./TektonConfig.md) by choosi

params provide a way to enable/disable the installation of resources.
Available params are

- `clusterTasks` (Default: `true`)
- `pipelineTemplates` (Default: `true`)
- `resolverTasks` (Default: `true`)
- `resolverStepActions` (Default: `true`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ spec:
x-descriptors:
- urn:alm:descriptor:com.tectonic.ui:label
version: v1alpha1
- description: Represents an installation of latest version of Addons (exclusively ClusterTasks, consoleyamlsamples, consoleclidownloads and consolequickstarts)
- description: Represents an installation of latest version of Addons (exclusively consoleyamlsamples, consoleclidownloads and consolequickstarts)
displayName: Tekton Addons
kind: TektonAddon
name: tektonaddons.operator.tekton.dev
Expand Down
4 changes: 0 additions & 4 deletions pkg/apis/operator/v1alpha1/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ const (
ProfileLite = "lite"

// Addon Params
ClusterTasksParam = "clusterTasks"
PipelineTemplatesParam = "pipelineTemplates"
CommunityClusterTasks = "communityClusterTasks"
ResolverTasks = "resolverTasks"
ResolverStepActions = "resolverStepActions"

Expand Down Expand Up @@ -111,9 +109,7 @@ var (
}

AddonParams = map[string]ParamValue{
ClusterTasksParam: defaultParamValue,
PipelineTemplatesParam: defaultParamValue,
CommunityClusterTasks: defaultParamValue,
ResolverTasks: defaultParamValue,
ResolverStepActions: defaultParamValue,
}
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/operator/v1alpha1/tektonaddon_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ func Test_AddonSetDefaults_DefaultParamsWithValues(t *testing.T) {
}

ta.SetDefaults(context.TODO())
assert.Equal(t, 5, len(ta.Spec.Params))
assert.Equal(t, 3, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[ClusterTasksParam]
value, ok := params[PipelineTemplatesParam]
assert.Equal(t, true, ok)
assert.Equal(t, "true", value)
}
Expand All @@ -61,7 +61,7 @@ func Test_AddonSetDefaults_ClusterTaskIsFalse(t *testing.T) {
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Name: "resolverTasks",
Value: "false",
},
},
Expand All @@ -70,10 +70,10 @@ func Test_AddonSetDefaults_ClusterTaskIsFalse(t *testing.T) {
}

ta.SetDefaults(context.TODO())
assert.Equal(t, 5, len(ta.Spec.Params))
assert.Equal(t, 3, len(ta.Spec.Params))

params := ParseParams(ta.Spec.Params)
value, ok := params[PipelineTemplatesParam]
value, ok := params[ResolverTasks]
assert.Equal(t, true, ok)
assert.Equal(t, "false", value)
}
14 changes: 0 additions & 14 deletions pkg/apis/operator/v1alpha1/tektonaddon_defaults.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,8 @@ func (ta *TektonAddon) SetDefaults(ctx context.Context) {
}

func setAddonDefaults(addon *Addon) {

paramsMap := ParseParams(addon.Params)
_, ptOk := paramsMap[PipelineTemplatesParam]
ct, ctOk := paramsMap[ClusterTasksParam]

// If clusterTasks is false and pipelineTemplate is not set, then set it as false
// as pipelines templates are created using clusterTasks
if ctOk && (ct == "false" && !ptOk) {
addon.Params = append(addon.Params, Param{
Name: PipelineTemplatesParam,
Value: "false",
})
paramsMap = ParseParams(addon.Params)
}

// set the params with default values if not set in cr
for d := range AddonParams {
_, ok := paramsMap[d]
if !ok {
Expand Down
8 changes: 0 additions & 8 deletions pkg/apis/operator/v1alpha1/tektonaddon_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,5 @@ func validateAddonParams(params []Param, pathToParams string) *apis.FieldError {
}
}

paramsMap := ParseParams(params)
if (paramsMap[ClusterTasksParam] == "false") && (paramsMap[PipelineTemplatesParam] == "true") {
errs = errs.Also(apis.ErrGeneric("pipelineTemplates cannot be true if clusterTask is false", pathToParams))
}
if (paramsMap[ClusterTasksParam] == "false") && (paramsMap[CommunityClusterTasks] == "true") {
errs = errs.Also(apis.ErrGeneric("communityClusterTasks cannot be true if clusterTask is false", pathToParams))
}

return errs
}
34 changes: 2 additions & 32 deletions pkg/apis/operator/v1alpha1/tektonaddon_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func Test_ValidateTektonAddon_InvalidParamValue(t *testing.T) {
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Name: "resolverTasks",
Value: "test",
},
},
Expand All @@ -94,35 +94,5 @@ func Test_ValidateTektonAddon_InvalidParamValue(t *testing.T) {
}

err := ta.Validate(context.TODO())
assert.Equal(t, "invalid value: test: spec.params.clusterTasks[0]", err.Error())
}

func Test_ValidateTektonAddon_ClusterTaskIsFalseAndPipelineTemplateIsTrue(t *testing.T) {

ta := &TektonAddon{
ObjectMeta: metav1.ObjectMeta{
Name: "addon",
Namespace: "namespace",
},
Spec: TektonAddonSpec{
CommonSpec: CommonSpec{
TargetNamespace: "namespace",
},
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Value: "false",
},
{
Name: "pipelineTemplates",
Value: "true",
},
},
},
},
}

err := ta.Validate(context.TODO())
assert.Equal(t, "pipelineTemplates cannot be true if clusterTask is false: spec.params", err.Error())
assert.Equal(t, "invalid value: test: spec.params.resolverTasks[0]", err.Error())
}
2 changes: 1 addition & 1 deletion pkg/apis/operator/v1alpha1/tektonconfig_default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func Test_SetDefaults_Addon_Params(t *testing.T) {
t.Setenv("PLATFORM", "openshift")

tc.SetDefaults(context.TODO())
if len(tc.Spec.Addon.Params) != 5 {
if len(tc.Spec.Addon.Params) != 3 {
t.Error("Setting default failed for TektonConfig (spec.addon.params)")
}
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/operator/v1alpha1/tektonconfig_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ func Test_ValidateTektonConfig_InvalidAddonParamValue(t *testing.T) {
Addon: Addon{
Params: []Param{
{
Name: "clusterTasks",
Name: "resolverTasks",
Value: "test",
},
},
Expand All @@ -180,7 +180,7 @@ func Test_ValidateTektonConfig_InvalidAddonParamValue(t *testing.T) {
}

err := tc.Validate(context.TODO())
assert.Equal(t, "invalid value: test: spec.addon.params.clusterTasks[0]", err.Error())
assert.Equal(t, "invalid value: test: spec.addon.params.resolverTasks[0]", err.Error())
}

func Test_ValidateTektonConfig_InvalidPipelineProperties(t *testing.T) {
Expand Down
36 changes: 0 additions & 36 deletions pkg/reconciler/openshift/tektonaddon/cluster_task.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,46 +17,10 @@ limitations under the License.
package tektonaddon

import (
"context"
"fmt"
"strings"

mf "github.com/manifestival/manifestival"
"github.com/tektoncd/operator/pkg/apis/operator/v1alpha1"
"github.com/tektoncd/operator/pkg/reconciler/common"
"github.com/tektoncd/operator/pkg/reconciler/kubernetes/tektoninstallerset/client"
)

func (r *Reconciler) EnsureClusterTask(ctx context.Context, enable string, ta *v1alpha1.TektonAddon) error {
manifest := *r.clusterTaskManifest
if enable == "true" {
addonImages := common.ToLowerCaseKeys(common.ImagesFromEnv(common.AddonsImagePrefix))
tfs := []mf.Transformer{
replaceKind(KindTask, KindClusterTask),
injectLabel(labelProviderType, providerTypeRedHat, overwrite, KindClusterTask),
common.TaskImages(ctx, addonImages),
}
if err := r.installerSetClient.CustomSet(ctx, ta, ClusterTaskInstallerSet, &manifest, filterAndTransformClusterTask(tfs), nil); err != nil {
return err
}
} else {
if err := r.installerSetClient.CleanupCustomSet(ctx, ClusterTaskInstallerSet); err != nil {
return err
}
}
return nil
}

func filterAndTransformClusterTask(tfs []mf.Transformer) client.FilterAndTransform {
return func(ctx context.Context, manifest *mf.Manifest, comp v1alpha1.TektonComponent) (*mf.Manifest, error) {
addon := comp.(*v1alpha1.TektonAddon)
if err := transformers(ctx, manifest, addon, tfs...); err != nil {
return nil, err
}
return manifest, nil
}
}

func formattedVersionMajorMinorX(version, x string) string {
ver := getPatchVersionTrimmed(version)
ver = fmt.Sprintf("%s.%s", ver, x)
Expand Down
47 changes: 0 additions & 47 deletions pkg/reconciler/openshift/tektonaddon/cluster_task_versioned.go

This file was deleted.

89 changes: 0 additions & 89 deletions pkg/reconciler/openshift/tektonaddon/community_cluster_tasks.go

This file was deleted.

Loading

0 comments on commit f743fbf

Please sign in to comment.