Skip to content

Commit 6483e37

Browse files
committed
refactor: Remove deprecated ClusterTask logic from generate command
* Removed cluster access logic previously used to check for ClusterTasks. * Removed the functionality tied to the `--use-clustertasks` flag. * Marked the `--use-clustertasks` flag as deprecated since ClusterTasks are no longer supported in this context. * Cleaned up unused imports and function parameters. Signed-off-by: Chmouel Boudjnah <chmouel@redhat.com>
1 parent 82282b8 commit 6483e37

File tree

1 file changed

+5
-21
lines changed

1 file changed

+5
-21
lines changed

pkg/cmd/tknpac/generate/generate.go

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package generate
22

33
import (
4-
"context"
54
"fmt"
65
"os"
76
"path/filepath"
@@ -16,7 +15,6 @@ import (
1615
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/settings"
1716
"github.com/openshift-pipelines/pipelines-as-code/pkg/params/triggertype"
1817
"github.com/spf13/cobra"
19-
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2018
)
2119

2220
var eventTypes = map[string]string{triggertype.PullRequest.String(): "Pull Request", "push": "Push to a Branch or a Tag"}
@@ -51,34 +49,19 @@ func MakeOpts() *Opts {
5149
}
5250
}
5351

54-
func Command(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command {
52+
func Command(_ *params.Run, ioStreams *cli.IOStreams) *cobra.Command {
5553
gopt := MakeOpts()
5654
gopt.IOStreams = ioStreams
5755
cmd := &cobra.Command{
5856
Use: "generate",
5957
Aliases: []string{"gen"},
6058
Short: "Generate PipelineRun",
6159
RunE: func(_ *cobra.Command, _ []string) error {
62-
ctx := context.Background()
6360
gopt.CLIOpts = cli.NewCliOptions()
6461
gopt.IOStreams.SetColorEnabled(!gopt.CLIOpts.NoColoring)
6562

6663
if gopt.generateWithClusterTask {
67-
if err := run.Clients.NewClients(ctx, &run.Info); err != nil {
68-
// if we don't have access to the cluster we can't do much about it
69-
gopt.generateWithClusterTask = false
70-
} else {
71-
// NOTE(chmou): This is for v1beta1, we need to figure out how to do this for v1.
72-
// Trying to find resolver with that same name?
73-
_, err := run.Clients.Tekton.TektonV1beta1().ClusterTasks().Get(ctx,
74-
gitCloneClusterTaskName,
75-
metav1.GetOptions{})
76-
if err == nil {
77-
gopt.generateWithClusterTask = true
78-
} else {
79-
gopt.generateWithClusterTask = false
80-
}
81-
}
64+
return fmt.Errorf("ClusterTasks is deprecated and not available anymore")
8265
}
8366
cwd, err := os.Getwd()
8467
if err != nil {
@@ -103,8 +86,9 @@ func Command(run *params.Run, ioStreams *cli.IOStreams) *cobra.Command {
10386
"Whether to overwrite the file if it exist")
10487
cmd.PersistentFlags().StringVarP(&gopt.language, "language", "l", "",
10588
"Generate for this programming language")
106-
cmd.PersistentFlags().BoolVarP(&gopt.generateWithClusterTask, "use-clustertasks", "", true,
107-
"By default we try to use the clustertasks unless not available")
89+
cmd.PersistentFlags().BoolVarP(&gopt.generateWithClusterTask, "use-clustertasks", "", false,
90+
"Deprecated, not available anymore")
91+
_ = cmd.PersistentFlags().MarkDeprecated("use-clustertasks", "This flag will be removed in a future release")
10892
return cmd
10993
}
11094

0 commit comments

Comments
 (0)