Skip to content

[gitpod-cli] change gp rebuild to gp validate #16867

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

Merged
merged 4 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions components/dashboard/src/start/StartWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -778,8 +778,8 @@ function ImageBuildView(props: ImageBuildViewProps) {
<>
<div className="mt-6 w-11/12 lg:w-3/5">
<p className="text-center text-gray-400 dark:text-gray-500">
💡 You can use the <code>gp rebuild</code> command to rebuild the workspace from the editor
terminal. &nbsp;
💡 You can use the <code>gp validate</code> command to validate the workspace configuration
from the editor terminal. &nbsp;
<a
href="https://www.gitpod.io/docs/configure/workspaces/workspace-image#trying-out-changes-to-your-dockerfile"
target="_blank"
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-cli/cmd/ports-await.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ var awaitPortCmdAlias = &cobra.Command{
Short: awaitPortCmd.Short,
Long: awaitPortCmd.Long,
Args: awaitPortCmd.Args,
Run: awaitPortCmd.Run,
RunE: awaitPortCmd.RunE,
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion components/gitpod-cli/cmd/ports-expose.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ var portExposeCmdAlias = &cobra.Command{
Short: portExposeCmd.Short,
Long: portExposeCmd.Long,
Args: portExposeCmd.Args,
Run: portExposeCmd.Run,
RunE: portExposeCmd.RunE,
}

func init() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func stopDebugContainer(ctx context.Context, dockerPath string) error {
}

func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClient) error {
logLevel, err := logrus.ParseLevel(rebuildOpts.LogLevel)
logLevel, err := logrus.ParseLevel(validateOpts.LogLevel)
if err != nil {
return GpError{Err: err, OutCome: utils.Outcome_UserErr, ErrorCode: utils.RebuildErrorCode_InvaligLogLevel}
}
Expand All @@ -57,7 +57,7 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
return err
}

checkoutLocation := rebuildOpts.WorkspaceFolder
checkoutLocation := validateOpts.WorkspaceFolder
if checkoutLocation == "" {
checkoutLocation = wsInfo.CheckoutLocation
}
Expand Down Expand Up @@ -206,11 +206,11 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie

workspaceType := api.DebugWorkspaceType_regular
contentSource := api.ContentSource_from_other
if rebuildOpts.Prebuild {
if validateOpts.Prebuild {
workspaceType = api.DebugWorkspaceType_prebuild
} else if rebuildOpts.From == "prebuild" {
} else if validateOpts.From == "prebuild" {
contentSource = api.ContentSource_from_prebuild
} else if rebuildOpts.From == "snapshot" {
} else if validateOpts.From == "snapshot" {
contentSource = api.ContentSource_from_backup
}
debugEnvs, err := supervisorClient.Control.CreateDebugEnv(ctx, &api.CreateDebugEnvRequest{
Expand Down Expand Up @@ -238,7 +238,7 @@ func runRebuild(ctx context.Context, supervisorClient *supervisor.SupervisorClie
for _, env := range debugEnvs.Envs {
envs += env + "\n"
}
for _, env := range rebuildOpts.GitpodEnvs {
for _, env := range validateOpts.GitpodEnvs {
envs += env + "\n"
}
for _, env := range workspaceEnvs {
Expand Down Expand Up @@ -462,7 +462,7 @@ func openWindow(ctx context.Context, workspaceUrl string) error {
return gpCmd.Run()
}

var rebuildOpts struct {
var validateOpts struct {
WorkspaceFolder string
LogLevel string
From string
Expand All @@ -472,9 +472,9 @@ var rebuildOpts struct {
GitpodEnvs []string
}

var rebuildCmd = &cobra.Command{
Use: "rebuild",
Short: "[experimental] Re-builds the workspace (useful to debug a workspace configuration)",
var validateCmd = &cobra.Command{
Use: "validate",
Short: "[experimental] Validates the workspace (useful to debug a workspace configuration)",
Hidden: false,
RunE: func(cmd *cobra.Command, args []string) error {
supervisorClient, err := supervisor.New(cmd.Context())
Expand All @@ -487,6 +487,14 @@ var rebuildCmd = &cobra.Command{
},
}

var rebuildCmd = &cobra.Command{
Hidden: true,
Use: "rebuild",
Deprecated: "please use `gp validate` instead.",
Short: validateCmd.Short,
RunE: validateCmd.RunE,
}

func init() {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
Expand All @@ -500,13 +508,22 @@ func init() {
}
}

rootCmd.AddCommand(rebuildCmd)
rebuildCmd.PersistentFlags().StringVarP(&rebuildOpts.WorkspaceFolder, "workspace-folder", "w", workspaceFolder, "Path to the workspace folder.")
rebuildCmd.PersistentFlags().StringVarP(&rebuildOpts.LogLevel, "log", "", "error", "Log level to use. Allowed values are 'error', 'warn', 'info', 'debug', 'trace'.")
rebuildCmd.PersistentFlags().StringVarP(&rebuildOpts.From, "from", "", "", "Starts from 'prebuild' or 'snapshot'.")
rebuildCmd.PersistentFlags().BoolVarP(&rebuildOpts.Prebuild, "prebuild", "", false, "starts as a prebuild workspace (--from is ignored).")
setFlags := func(cmd *cobra.Command) {
cmd.PersistentFlags().BoolVarP(&validateOpts.Prebuild, "prebuild", "", false, "starts as a prebuild workspace.")
cmd.PersistentFlags().StringVarP(&validateOpts.LogLevel, "log", "", "error", "Log level to use. Allowed values are 'error', 'warn', 'info', 'debug', 'trace'.")

// internal
rebuildCmd.PersistentFlags().StringArrayVarP(&rebuildOpts.GitpodEnvs, "gitpod-env", "", nil, "")
rebuildCmd.PersistentFlags().MarkHidden("gitpod-env")
// internal
cmd.PersistentFlags().StringArrayVarP(&validateOpts.GitpodEnvs, "gitpod-env", "", nil, "")
cmd.PersistentFlags().StringVarP(&validateOpts.WorkspaceFolder, "workspace-folder", "w", workspaceFolder, "Path to the workspace folder.")
cmd.PersistentFlags().StringVarP(&validateOpts.From, "from", "", "", "Starts from 'prebuild' or 'snapshot'.")
_ = cmd.PersistentFlags().MarkHidden("gitpod-env")
_ = cmd.PersistentFlags().MarkHidden("workspace-folder")
_ = cmd.PersistentFlags().MarkHidden("from")
}

setFlags(validateCmd)
setFlags(rebuildCmd)

rootCmd.AddCommand(validateCmd)
rootCmd.AddCommand(rebuildCmd)
}
2 changes: 1 addition & 1 deletion components/supervisor/validate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ sudo rm -rf /.supervisor/frontend && true
sudo ln -s "$DIR/frontend/dist" /.supervisor/frontend
echo "$DIR/frontend/dist linked in /.supervisor/frontend"

gp rebuild --workspace-folder="$ROOT_DIR/dev/ide/example/workspace" --gitpod-env "GITPOD_ANALYTICS_SEGMENT_KEY=YErmvd89wPsrCuGcVnF2XAl846W9WIGl" --gitpod-env "GP_OPEN_EDITOR=" --gitpod-env "GP_PREVIEW_BROWSER=" --gitpod-env "GP_EXTERNAL_BROWSER=" "$@"
gp validate --workspace-folder="$ROOT_DIR/dev/ide/example/workspace" --gitpod-env "GITPOD_ANALYTICS_SEGMENT_KEY=YErmvd89wPsrCuGcVnF2XAl846W9WIGl" --gitpod-env "GP_OPEN_EDITOR=" --gitpod-env "GP_PREVIEW_BROWSER=" --gitpod-env "GP_EXTERNAL_BROWSER=" "$@"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions install/installer/cmd/testdata/render/aws-setup/output.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions install/installer/cmd/testdata/render/gcp-setup/output.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions install/installer/cmd/testdata/render/kind-ide/output.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions install/installer/cmd/testdata/render/kind-meta/output.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions install/installer/cmd/testdata/render/minimal/output.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading