Skip to content

Commit

Permalink
Merge pull request #1227 from loft-sh/thomaskosiewski/eng-2091-vclust…
Browse files Browse the repository at this point in the history
…er-ui

Added UI command
  • Loading branch information
FabianKramm committed Sep 22, 2023
2 parents 1d82320 + c353b9f commit e05c07a
Show file tree
Hide file tree
Showing 7 changed files with 143 additions and 11 deletions.
6 changes: 6 additions & 0 deletions cmd/vclusterctl/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ func BuildRoot(log log.Logger) (*cobra.Command, error) {
}
rootCmd.AddCommand(logoutCmd)

uiCmd, err := NewUICmd(globalFlags)
if err != nil {
return nil, fmt.Errorf("failed to create ui command: %w", err)
}
rootCmd.AddCommand(uiCmd)

// add completion command
err = rootCmd.RegisterFlagCompletionFunc("namespace", newNamespaceCompletionFunc(rootCmd.Context()))
if err != nil {
Expand Down
55 changes: 55 additions & 0 deletions cmd/vclusterctl/cmd/ui.go
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
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ require (
github.com/gorilla/websocket v1.5.0
github.com/hashicorp/golang-lru/v2 v2.0.2
github.com/kubernetes-csi/external-snapshotter/client/v4 v4.2.0
github.com/loft-sh/agentapi/v3 v3.3.0-ci.1.0.20230921083523-e1d74f6f8fd1
github.com/loft-sh/api/v3 v3.0.0-20230922094800-6d0c1cbf0fa6
github.com/loft-sh/loftctl/v3 v3.0.0-20230922100229-83e8d117af6d
github.com/loft-sh/loftctl/v3 v3.0.0-20230922112452-20febcea05a7
github.com/loft-sh/utils v0.0.25
github.com/mitchellh/go-homedir v1.1.0
github.com/moby/term v0.5.0
Expand Down Expand Up @@ -75,7 +76,6 @@ require (
github.com/google/gnostic-models v0.6.8 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213 // indirect
github.com/loft-sh/agentapi/v3 v3.3.0-ci.1.0.20230921083523-e1d74f6f8fd1 // indirect
github.com/loft-sh/apiserver v0.0.0-20230628051307-f26967fbb40f // indirect
github.com/loft-sh/external-types v0.0.2-0.20230301201552-ec939da949b4 // indirect
github.com/loft-sh/jspolicy v0.1.0 // indirect
Expand Down
10 changes: 2 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -550,8 +550,6 @@ github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de h1:9TO3cAIGXtEhn
github.com/liggitt/tabwriter v0.0.0-20181228230101-89fcab3d43de/go.mod h1:zAbeS9B/r2mtpb6U+EI2rYA5OAXxsYw6wTamcNW+zcE=
github.com/loft-sh/agentapi/v3 v3.3.0-ci.1.0.20230921083523-e1d74f6f8fd1 h1:XE+JbvcExJd45Oh3Jm2d62uPmDP2luPf0mQ3NZZMMuY=
github.com/loft-sh/agentapi/v3 v3.3.0-ci.1.0.20230921083523-e1d74f6f8fd1/go.mod h1:8jmVWFBcLjwh6Tv2KPVxkIjUJpVxUMROcbYYVYxR1pI=
github.com/loft-sh/api/v3 v3.0.0-20230921143328-114580f85fdd h1:8UQwV6TK1QAHlsdrL8we59IKrPH1z8nSO6+mI2lziXs=
github.com/loft-sh/api/v3 v3.0.0-20230921143328-114580f85fdd/go.mod h1:eIbt+Ze6F2fW651JE3VTlFsool+S/hX603aFG5s/AZg=
github.com/loft-sh/api/v3 v3.0.0-20230922094800-6d0c1cbf0fa6 h1:AGmtKdjldgxN4nj6WRSpGe0PKswASDqxnMy1r2ScmVc=
github.com/loft-sh/api/v3 v3.0.0-20230922094800-6d0c1cbf0fa6/go.mod h1:eIbt+Ze6F2fW651JE3VTlFsool+S/hX603aFG5s/AZg=
github.com/loft-sh/apiserver v0.0.0-20230628051307-f26967fbb40f h1:eeLBYlrGOvzJK3h7JYdBGpRvdjzD/sTCVPL2lIQsXlg=
Expand All @@ -560,12 +558,8 @@ github.com/loft-sh/external-types v0.0.2-0.20230301201552-ec939da949b4 h1:eSuBR+
github.com/loft-sh/external-types v0.0.2-0.20230301201552-ec939da949b4/go.mod h1:qnerIOkD67CmTkV8HsXQit6BfB7Qiw45bSUy1oefIXU=
github.com/loft-sh/jspolicy v0.1.0 h1:FNAWR6tRX5NRWxAf9RI/86NRH83NXYbobLHSZyMND74=
github.com/loft-sh/jspolicy v0.1.0/go.mod h1:4Zi38iEB0JvhnkrNHPpoueSUWQ1OlHMNB9JHTGEsPO0=
github.com/loft-sh/loftctl/v3 v3.0.0-20230921143437-669b265e3ecf h1:SwIal5P1coM01bw3OYz0PLokpu4iTaYOMlPH1WfWBjk=
github.com/loft-sh/loftctl/v3 v3.0.0-20230921143437-669b265e3ecf/go.mod h1:I+dMG4zKZWOn+CcteN0cyPGOclHlqqmXBC6THcUwj60=
github.com/loft-sh/loftctl/v3 v3.0.0-20230922094952-2a6aef29f31e h1:OhQRp9uH7U14lYg8yOrnOiVhhxxC9tFdwWSyxoSUJ/I=
github.com/loft-sh/loftctl/v3 v3.0.0-20230922094952-2a6aef29f31e/go.mod h1:g2HZHmpkqtiQGqM8QVRuaCgNDI6IMW6DZQP0cOUgxp8=
github.com/loft-sh/loftctl/v3 v3.0.0-20230922100229-83e8d117af6d h1:bmOCghp4sNtzw0V8xwhMt5myeL+w2qzO3zHeRrwDpRE=
github.com/loft-sh/loftctl/v3 v3.0.0-20230922100229-83e8d117af6d/go.mod h1:g2HZHmpkqtiQGqM8QVRuaCgNDI6IMW6DZQP0cOUgxp8=
github.com/loft-sh/loftctl/v3 v3.0.0-20230922112452-20febcea05a7 h1:lsBF4llFeHcDvYj2TCFVNsdYAPemIXXg7v0w2A6txPw=
github.com/loft-sh/loftctl/v3 v3.0.0-20230922112452-20febcea05a7/go.mod h1:g2HZHmpkqtiQGqM8QVRuaCgNDI6IMW6DZQP0cOUgxp8=
github.com/loft-sh/log v0.0.0-20230824104949-bd516c25712a h1:/gqqjKpcHEdFXIX41lx1Y/FBqT/72gbPpf7sa20tyM8=
github.com/loft-sh/log v0.0.0-20230824104949-bd516c25712a/go.mod h1:YImeRjXH34Yf5E79T7UHBQpDZl9fIaaFRgyZ/bkY+UQ=
github.com/loft-sh/utils v0.0.25 h1:JbbRJfXO1Rd34fQcaoDSmwyPBEzsrLwBSR21C90hHuk=
Expand Down

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

76 changes: 76 additions & 0 deletions 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.

2 changes: 1 addition & 1 deletion vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ github.com/loft-sh/external-types/loft-sh/admin-services/pkg/server
# github.com/loft-sh/jspolicy v0.1.0
## explicit; go 1.16
github.com/loft-sh/jspolicy/pkg/apis/policy/v1beta1
# github.com/loft-sh/loftctl/v3 v3.0.0-20230922100229-83e8d117af6d
# github.com/loft-sh/loftctl/v3 v3.0.0-20230922112452-20febcea05a7
## explicit; go 1.21.1
github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd
github.com/loft-sh/loftctl/v3/cmd/loftctl/cmd/connect
Expand Down

0 comments on commit e05c07a

Please sign in to comment.