From 3e79652b04352e6a14f8faaa9778aedd0e16ee95 Mon Sep 17 00:00:00 2001 From: Gero Posmyk-Leinemann <32448529+geropl@users.noreply.github.com> Date: Fri, 1 Dec 2023 09:22:08 +0100 Subject: [PATCH] [dev] Add "previewctl get url" (#19167) --- dev/preview/previewctl/cmd/get.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dev/preview/previewctl/cmd/get.go b/dev/preview/previewctl/cmd/get.go index 60d7b5f010d2ae..073b264d3bacbe 100644 --- a/dev/preview/previewctl/cmd/get.go +++ b/dev/preview/previewctl/cmd/get.go @@ -28,6 +28,7 @@ func newGetCmd(logger *logrus.Logger) *cobra.Command { cmd.AddCommand( newGetNameSubCmd(), newGetActiveCmd(logger), + newGetUrlSubCmd(), ) return cmd @@ -52,6 +53,26 @@ func newGetNameSubCmd() *cobra.Command { return cmd } +func newGetUrlSubCmd() *cobra.Command { + cmd := &cobra.Command{ + Use: "url", + Short: "", + RunE: func(cmd *cobra.Command, args []string) error { + previewName, err := preview.GetName(branch) + if err != nil { + return err + } + + previewUrl := fmt.Sprintf("https://%s.preview.gitpod-dev.com", previewName) + fmt.Println(previewUrl) + + return nil + }, + } + + return cmd +} + func newGetActiveCmd(logger *logrus.Logger) *cobra.Command { ctx := context.Background()