This repository has been archived by the owner on Jan 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3506 from hashicorp/f-pipelines
feature: Initial Pipelines
- Loading branch information
Showing
150 changed files
with
23,692 additions
and
13,775 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```release-note:improvement | ||
cli: Implement `waypoint job get-stream` to allow users to attach to running job | ||
streams and receieve output, or get the output from an existing job stream that | ||
already finished. | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/golang/protobuf/jsonpb" | ||
"github.com/posener/complete" | ||
"google.golang.org/grpc/codes" | ||
"google.golang.org/grpc/status" | ||
|
||
"github.com/hashicorp/waypoint-plugin-sdk/terminal" | ||
"github.com/hashicorp/waypoint/internal/clierrors" | ||
"github.com/hashicorp/waypoint/internal/pkg/flag" | ||
pb "github.com/hashicorp/waypoint/pkg/server/gen" | ||
) | ||
|
||
type PipelineInspectCommand struct { | ||
*baseCommand | ||
|
||
flagJson bool | ||
flagPipelineId string | ||
} | ||
|
||
func (c *PipelineInspectCommand) Run(args []string) int { | ||
// Initialize. If we fail, we just exit since Init handles the UI. | ||
if err := c.Init( | ||
WithArgs(args), | ||
WithFlags(c.Flags()), | ||
); err != nil { | ||
return 1 | ||
} | ||
|
||
var pipelineId string | ||
if len(c.args) == 0 { | ||
c.ui.Output("Pipeline ID required.\n\n%s", c.Help(), terminal.WithErrorStyle()) | ||
return 1 | ||
} | ||
|
||
pipelineId = c.args[0] | ||
|
||
// Pre-calculate our project ref | ||
projectRef := &pb.Ref_Project{Project: c.flagProject} | ||
if c.flagProject == "" { | ||
if c.project != nil { | ||
projectRef = c.project.Ref() | ||
} | ||
|
||
if projectRef == nil { | ||
c.ui.Output("You must specify a project with -project or be inside an existing project directory.\n"+c.Help(), | ||
terminal.WithErrorStyle()) | ||
return 1 | ||
} | ||
} | ||
|
||
resp, err := c.project.Client().GetPipeline(c.Ctx, &pb.GetPipelineRequest{ | ||
Pipeline: &pb.Ref_Pipeline{ | ||
Ref: &pb.Ref_Pipeline_Id{ | ||
Id: &pb.Ref_PipelineId{ | ||
Id: pipelineId, | ||
}, | ||
}, | ||
}, | ||
}) | ||
if err != nil { | ||
if status.Code(err) == codes.NotFound { | ||
c.ui.Output("Pipeline not found: %s", clierrors.Humanize(err), | ||
terminal.WithErrorStyle()) | ||
return 1 | ||
} | ||
|
||
c.ui.Output(clierrors.Humanize(err), terminal.WithErrorStyle()) | ||
return 1 | ||
} | ||
if resp == nil { | ||
c.ui.Output("The requested pipeline response was empty", terminal.WithWarningStyle()) | ||
return 0 | ||
} | ||
|
||
if c.flagJson { | ||
var m jsonpb.Marshaler | ||
m.Indent = "\t" | ||
str, err := m.MarshalToString(resp) | ||
if err != nil { | ||
c.ui.Output(clierrors.Humanize(err), terminal.WithErrorStyle()) | ||
return 1 | ||
} | ||
|
||
fmt.Println(str) | ||
return 0 | ||
} | ||
|
||
var owner string | ||
switch po := resp.Pipeline.Owner.(type) { | ||
case *pb.Pipeline_Project: | ||
owner = po.Project.Project | ||
default: | ||
owner = "???" | ||
} | ||
|
||
c.ui.Output("Pipeline Configuration", terminal.WithHeaderStyle()) | ||
c.ui.NamedValues([]terminal.NamedValue{ | ||
{ | ||
Name: "ID", Value: resp.Pipeline.Id, | ||
}, | ||
{ | ||
Name: "Name", Value: resp.Pipeline.Name, | ||
}, | ||
{ | ||
Name: "Owner", Value: owner, | ||
}, | ||
{ | ||
Name: "Root Step Name", Value: resp.RootStep, | ||
}, | ||
}, terminal.WithInfoStyle()) | ||
|
||
// TODO(briancain): Use graphviz to build a pipeline graph and display in the terminal? | ||
|
||
return 0 | ||
} | ||
|
||
func (c *PipelineInspectCommand) Flags() *flag.Sets { | ||
return c.flagSet(flagSetOperation, func(set *flag.Sets) { | ||
f := set.NewSet("Command Options") | ||
f.BoolVar(&flag.BoolVar{ | ||
Name: "json", | ||
Target: &c.flagJson, | ||
Default: false, | ||
Usage: "Output the Pipeline as json.", | ||
}) | ||
}) | ||
} | ||
|
||
func (c *PipelineInspectCommand) AutocompleteArgs() complete.Predictor { | ||
return complete.PredictNothing | ||
} | ||
|
||
func (c *PipelineInspectCommand) AutocompleteFlags() complete.Flags { | ||
return c.Flags().Completions() | ||
} | ||
|
||
func (c *PipelineInspectCommand) Synopsis() string { | ||
return "Inspect the full details of a pipeline by id" | ||
} | ||
|
||
func (c *PipelineInspectCommand) Help() string { | ||
return formatHelp(` | ||
Usage: waypoint pipeline inspect [options] <pipeline-id> | ||
Inspect the full details of a pipeline by id for a project. | ||
` + c.Flags().Help()) | ||
} |
Oops, something went wrong.