-
Notifications
You must be signed in to change notification settings - Fork 1.3k
proposal: gp prebuild-logs
Gitpod cli command
#13505
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License-AGPL.txt in the project root for license information. | ||
|
||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"github.com/gitpod-io/gitpod/gitpod-cli/pkg/theialib" | ||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// initCmd represents the init command | ||
var prebuildLogs = &cobra.Command{ | ||
Use: "prebuild-logs", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about Although there is only on prebuild. I would think it should somehow resolve around
but I'm not sure what would the best UX There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Currently There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think they are special characters for shell and should be interpreted properly. We don't write anything else to these files besides what was produced by pty devices for shell. |
||
Short: "Opens logs of Gitpod prebuilds", | ||
Long: ` | ||
Opens all logs of Gitpod prebuilds. | ||
Number of logs depends upon the init tasks you have configured. | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
|
||
const prebuildFilePath = "/workspace/.gitpod/prebuild-log-*" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is implementation detail of supervisor, i think it should be a secret of supervisor how to store and fetch content. Clients should not rely on it. |
||
err := openPrebuildLogs(prebuildFilePath) | ||
|
||
if err != nil { | ||
log.WithError(err) | ||
return | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(prebuildLogs) | ||
} | ||
|
||
func openPrebuildLogs(prebuildFilePath string) error { | ||
service, err := theialib.NewServiceFromEnv() | ||
if err != nil { | ||
log.WithError(err) | ||
return err | ||
} | ||
|
||
for { | ||
_, err := service.OpenFile(theialib.OpenFileRequest{Path: prebuildFilePath}) | ||
if err != nil { | ||
log.WithError(err) | ||
fmt.Println("Prebuild logs not found.\nMake sure you have configured prebuilds.\nLearn more about Prebuilds: https://www.gitpod.io/docs/configure/projects/prebuilds") | ||
return nil | ||
} | ||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should ditch theialib. The official api is supervisor API, maybe we should think about how enrich it to return task output. We were discussing such API in the past with @geropl that dashboard could as well return output of prebuild task even if some task already finished.
I think it would be in the right direction to make prebuild UX is more reliable. cc @csweichel