Skip to content

Commit

Permalink
Add v1 support for pr logs
Browse files Browse the repository at this point in the history
This will do the changes related to
moving the taskrunstatusfield to childreference
in pipelinerun to add support for v1 pr logs

Part of #1804
  • Loading branch information
piyush-garg authored and tekton-robot committed Mar 27, 2023
1 parent ceca3dc commit 4f7ee9a
Show file tree
Hide file tree
Showing 17 changed files with 2,993 additions and 1,258 deletions.
33 changes: 1 addition & 32 deletions pkg/cmd/pipeline/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package pipeline

import (
"context"
"fmt"
"io"
"strings"
Expand All @@ -31,9 +30,7 @@ import (
pipelinepkg "github.com/tektoncd/cli/pkg/pipeline"
prsort "github.com/tektoncd/cli/pkg/pipelinerun/sort"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime/schema"
cliopts "k8s.io/cli-runtime/pkg/genericclioptions"
)

Expand Down Expand Up @@ -160,7 +157,7 @@ func describeCommand(p cli.Params) *cobra.Command {
}

func printPipelineDescription(out io.Writer, c *cli.Clients, ns string, pName string, time clockwork.Clock) error {
pipeline, err := getPipeline(pipelineGroupResource, c, pName, ns)
pipeline, err := pipelinepkg.GetPipeline(pipelineGroupResource, c, pName, ns)
if err != nil {
return err
}
Expand Down Expand Up @@ -223,31 +220,3 @@ func askPipelineName(opts *options.DescribeOptions, pipelineNames []string) erro

return nil
}

func getPipeline(gr schema.GroupVersionResource, c *cli.Clients, pName, ns string) (*v1.Pipeline, error) {
var pipeline v1.Pipeline
gvr, err := actions.GetGroupVersionResource(gr, c.Tekton.Discovery())
if err != nil {
return nil, err
}

if gvr.Version == "v1" {
err := actions.GetV1(pipelineGroupResource, c, pName, ns, metav1.GetOptions{}, &pipeline)
if err != nil {
return nil, err
}
return &pipeline, nil

}

var pipelineV1beta1 v1beta1.Pipeline
err = actions.GetV1(pipelineGroupResource, c, pName, ns, metav1.GetOptions{}, &pipelineV1beta1)
if err != nil {
return nil, err
}
err = pipelineV1beta1.ConvertTo(context.Background(), &pipeline)
if err != nil {
return nil, err
}
return &pipeline, nil
}
14 changes: 3 additions & 11 deletions pkg/cmd/pipeline/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/tektoncd/cli/pkg/flags"
"github.com/tektoncd/cli/pkg/formatted"
"github.com/tektoncd/cli/pkg/options"
"github.com/tektoncd/cli/pkg/pipeline"
pipelinepkg "github.com/tektoncd/cli/pkg/pipeline"
pipelinerunpkg "github.com/tektoncd/cli/pkg/pipelinerun"
v1 "github.com/tektoncd/pipeline/pkg/apis/pipeline/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -147,7 +147,7 @@ func getAllInputs(opts *options.LogOptions) error {
return err
}

ps, err := pipeline.GetAllPipelineNames(pipelineGroupResource, cs, opts.Params.Namespace())
ps, err := pipelinepkg.GetAllPipelineNames(pipelineGroupResource, cs, opts.Params.Namespace())
if err != nil {
return err
}
Expand Down Expand Up @@ -177,7 +177,7 @@ func askRunName(opts *options.LogOptions) error {
}

if opts.Last {
name, err := initLastRunName(cs, opts.PipelineName, opts.Params.Namespace())
name, err := pipelinepkg.LastRunName(cs, opts.PipelineName, opts.Params.Namespace())
if err != nil {
return err
}
Expand Down Expand Up @@ -206,11 +206,3 @@ func askRunName(opts *options.LogOptions) error {

return opts.Ask(options.ResourceNamePipelineRun, prs)
}

func initLastRunName(cs *cli.Clients, name, namespace string) (string, error) {
lastrun, err := pipeline.LastRun(cs, name, namespace)
if err != nil {
return "", err
}
return lastrun.Name, nil
}
Loading

0 comments on commit 4f7ee9a

Please sign in to comment.