-
Notifications
You must be signed in to change notification settings - Fork 444
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 #1227 from loft-sh/thomaskosiewski/eng-2091-vclust…
…er-ui Added UI command
- Loading branch information
Showing
7 changed files
with
143 additions
and
11 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
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,55 @@ | ||
package cmd | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
loftctl "github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd" | ||
"github.com/loft-sh/log" | ||
"github.com/loft-sh/vcluster/cmd/vclusterctl/flags" | ||
"github.com/loft-sh/vcluster/pkg/pro" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func NewUICmd(globalFlags *flags.GlobalFlags) (*cobra.Command, error) { | ||
loftctlGlobalFlags, err := pro.GlobalFlags(globalFlags) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to parse pro flags: %w", err) | ||
} | ||
|
||
cmd := &loftctl.UiCmd{ | ||
GlobalFlags: loftctlGlobalFlags, | ||
Log: log.GetInstance(), | ||
} | ||
|
||
description := `######################################################## | ||
##################### vcluster ui ###################### | ||
######################################################## | ||
Open the vCluster.Pro web UI | ||
Example: | ||
vcluster ui | ||
######################################################## | ||
` | ||
|
||
uiCmd := &cobra.Command{ | ||
Use: "ui", | ||
Short: "Start the web UI", | ||
Long: description, | ||
Args: cobra.NoArgs, | ||
RunE: func(cobraCmd *cobra.Command, args []string) error { | ||
err := cmd.Run(cobraCmd.Context(), args) | ||
if err != nil { | ||
if errors.Is(err, loftctl.ErrNoUrl) { | ||
return fmt.Errorf("%w: please login first using 'vcluster login' or start using 'vcluster pro start'", err) | ||
} | ||
|
||
return fmt.Errorf("failed to run ui command: %w", err) | ||
} | ||
|
||
return nil | ||
}, | ||
} | ||
|
||
return uiCmd, nil | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
vendor/github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd/ui.go
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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