Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tail Up #86

Merged
merged 54 commits into from
Apr 10, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift click to select a range
7fb1b1b
Deployment Logs in CLI
JakeCooper Apr 7, 2021
c5b9fce
Deploy Logs in CLI
JakeCooper Apr 7, 2021
65c97a8
Live log tail
JakeCooper Apr 7, 2021
eb0d866
Remove loggin code
JakeCooper Apr 7, 2021
6d40cda
Update main.go
JakeCooper Apr 7, 2021
d9d2c94
Add detached flag
JakeCooper Apr 7, 2021
195c813
Merge branch 'cooper/deployment-logs' of github.com:railwayapp/cli in…
JakeCooper Apr 7, 2021
a156456
Don't fetch all deployments everytime
JakeCooper Apr 7, 2021
37d8166
Remove up command
JakeCooper Apr 7, 2021
4219921
Add line number
JakeCooper Apr 7, 2021
5160c21
Comment
JakeCooper Apr 7, 2021
790cf2f
Tail up on deploy
JakeCooper Apr 7, 2021
4318461
Cant spell FML
JakeCooper Apr 7, 2021
f89e601
Fix flag err
JakeCooper Apr 7, 2021
68bdaae
Merge branch 'cooper/deployment-logs' into cooper/tail-up
JakeCooper Apr 7, 2021
d69764e
Re add tail detach for up
JakeCooper Apr 7, 2021
14111a3
use latest deploy
JakeCooper Apr 7, 2021
43667d6
Remove println
JakeCooper Apr 7, 2021
c5e2e7d
Remove status indicator
JakeCooper Apr 7, 2021
8211097
Merge branch 'cooper/deployment-logs' into cooper/tail-up
JakeCooper Apr 7, 2021
0b4742e
Custom errors
JakeCooper Apr 8, 2021
7561a47
Factor out incorrect errors
JakeCooper Apr 8, 2021
605131c
Filter out removed
JakeCooper Apr 8, 2021
be59758
Tail up
JakeCooper Apr 8, 2021
56874e1
Fix pointer walk
JakeCooper Apr 8, 2021
26872fb
Update main.go
JakeCooper Apr 8, 2021
eaee90c
Flatten root cmd
JakeCooper Apr 8, 2021
ebe870e
Remove helper wrapper
JakeCooper Apr 8, 2021
b903df0
Remove helper flag
JakeCooper Apr 8, 2021
eadea0d
Merge branch 'cooper/deployment-logs' into cooper/tail-up
JakeCooper Apr 8, 2021
99e2392
Merge branch 'master' into cooper/tail-up
JakeCooper Apr 8, 2021
1612327
Fix print offset
JakeCooper Apr 8, 2021
3d0a471
WTF
JakeCooper Apr 8, 2021
e758abe
As if this section wasn't confusing enough
JakeCooper Apr 8, 2021
435862f
Use print
JakeCooper Apr 8, 2021
e0d29e8
Merge branch 'cooper/fix-offset-print' into cooper/tail-up
JakeCooper Apr 8, 2021
87a4ae6
Merge branch 'master' into cooper/tail-up
JakeCooper Apr 8, 2021
33b3dd1
Merge branch 'master' into cooper/tail-up
JakeCooper Apr 8, 2021
8ee0741
Support build log timeouts newlines
JakeCooper Apr 9, 2021
dc4499f
Attach to cloud build line
JakeCooper Apr 9, 2021
ae3b695
No idxMp
JakeCooper Apr 9, 2021
cb6016e
Remove unused function
JakeCooper Apr 9, 2021
3a8c17d
Move prevwalk up
JakeCooper Apr 9, 2021
3b7edab
Remove todo since it's done
JakeCooper Apr 9, 2021
0a0f732
Big refactory
JakeCooper Apr 9, 2021
bc7e15d
Remove unused
JakeCooper Apr 9, 2021
dcd5ac5
Fix NPE
JakeCooper Apr 9, 2021
00cbe76
GQL soft error
JakeCooper Apr 9, 2021
c85ae11
Handle build failure
JakeCooper Apr 9, 2021
9596b7c
Do not export active state
JakeCooper Apr 9, 2021
4267093
Remove surperfluous build function
JakeCooper Apr 9, 2021
1fa5ca9
Only check logs once
JakeCooper Apr 9, 2021
8441dd9
Added lil railway logs fin
JakeCooper Apr 9, 2021
ddcc28f
Deploy logs
JakeCooper Apr 9, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Deployment Logs in CLI
  • Loading branch information
JakeCooper committed Apr 7, 2021
commit 7fb1b1b3a975e3e640245faf145ec47a9240e097
20 changes: 20 additions & 0 deletions cmd/logs.go
Original file line number Diff line number Diff line change
@@ -0,0 1,20 @@
package cmd

import (
"context"
"fmt"

"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/ui"
)

func (h *Handler) Logs(ctx context.Context, req *entity.CommandRequest) error {
isLoggedIn, _ := h.ctrl.IsLoggedIn(ctx)

if !isLoggedIn {
return fmt.Errorf("%s\nRun %s", ui.RedText("Account require to init project"), ui.Bold("railway login"))
}

h.ctrl.GetActiveDeploymentLogs(ctx)
return nil
}
23 changes: 23 additions & 0 deletions controller/logs.go
Original file line number Diff line number Diff line change
@@ -0,0 1,23 @@
package controller

import (
"context"
"fmt"
)

func (c *Controller) GetActiveDeploymentLogs(ctx context.Context) (string, error) {
projectID, err := c.cfg.GetProject()
if err != nil {
return "", err
}
environmentID, err := c.cfg.GetEnvironment()
if err != nil {
return "", err
}
deployments, err := c.gtwy.GetDeploymentsForEnvironment(ctx, projectID, environmentID)
if err != nil {
return "", err
}
fmt.Println(deployments[0].DeployLogs)
return "", nil
}
6 changes: 6 additions & 0 deletions entity/deployment.go
Original file line number Diff line number Diff line change
@@ -0,0 1,6 @@
package entity

type Deployment struct {
BuildLogs string `json:"buildLogs"`
DeployLogs string `json:"deployLogs"`
}
33 changes: 33 additions & 0 deletions gateway/logs.go
Original file line number Diff line number Diff line change
@@ -0,0 1,33 @@
package gateway

import (
"context"

gql "github.com/machinebox/graphql"
"github.com/railwayapp/cli/entity"
"github.com/railwayapp/cli/errors"
)

func (g *Gateway) GetDeploymentsForEnvironment(ctx context.Context, projectId string, environmentId string) ([]entity.Deployment, error) {
gqlReq := gql.NewRequest(`
query ($projectId: ID!, $environmentId: ID!) {
allDeploymentsForEnvironment(projectId: $projectId, environmentId: $environmentId)
}
`)

gqlReq.Var("projectId", projectId)
gqlReq.Var("environmentId", environmentId)

err := g.authorize(ctx, gqlReq.Header)
if err != nil {
return nil, err
}

var resp struct {
Deployments []entity.Deployment `json:"allDeploymentsForEnvironment"`
}
if err := g.gqlClient.Run(ctx, gqlReq, &resp); err != nil {
return nil, errors.PluginGetFailed
}
return resp.Deployments, nil
}
6 changes: 6 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 182,12 @@ func init() {
RunE: contextualize(handler.Up, handler.Panic),
})

addRootCmd(&cobra.Command{
Use: "logs",
Short: "Get app logs",
RunE: contextualize(handler.Logs, handler.Panic),
})

addRootCmd(&cobra.Command{
Use: "docs",
Short: "Open Railway Documentation in default browser",
Expand Down