Skip to content

Commit

Permalink
Add console cli cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
oanatmaria committed Oct 3, 2023
1 parent c95260b commit d436561
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require (
github.com/aserto-dev/runtime v0.54.2
github.com/aserto-dev/self-decision-logger v0.0.4
github.com/aserto-dev/service-host v0.0.5
github.com/cli/browser v1.2.0
github.com/fatih/color v1.15.0
github.com/fullstorydev/grpcurl v1.8.7
github.com/google/uuid v1.3.1
Expand Down
5 changes: 5 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ github.com/aserto-dev/go-directory v0.21.8-0.20230913224642-68ab4803494f h1:0hnP
github.com/aserto-dev/go-directory v0.21.8-0.20230913224642-68ab4803494f/go.mod h1:ZsHSXALiP6F49/+zKDZP6GIcAWyYX95lkSVxM+8Jwno=
github.com/aserto-dev/go-directory-cli v0.20.14-0.20230913232053-927068a67595 h1:t/L3jN8AhLQsqbJq7AD/zFMNQDH3sT+lKiM7VoIfMk4=
github.com/aserto-dev/go-directory-cli v0.20.14-0.20230913232053-927068a67595/go.mod h1:+tWMBAzEd+TW7m0PEhVYTX50h4Nju1au+J151yeEUdA=
github.com/aserto-dev/go-edge-ds v0.21.10-0.20230918210437-130da75a4874 h1:q+IqDuGTfH0GF6+rtGkqaxNsWZwa/Cb/ScOZyShq8R0=
github.com/aserto-dev/go-edge-ds v0.21.10-0.20230918210437-130da75a4874/go.mod h1:CupD7d2BmNksBgJO/wogA62TM5TBqiy1atVBRlddqeQ=
github.com/aserto-dev/go-grpc v0.8.57 h1:CjQVxZ2HkBvJrfCtaDeq2kZSn2yLmRel5kHCVzqRMLs=
github.com/aserto-dev/go-grpc v0.8.57/go.mod h1:2FcclMDheTsEvYCY72o+EwTaoO0ti3/it4G6xIlzNIM=
github.com/aserto-dev/go-http-metrics v0.10.1-20221024-1 h1:nONd24V5nyJ0IIw8QE+OKv30YuHOTNbJ4FsvczLaM8o=
Expand Down Expand Up @@ -117,6 +119,8 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
github.com/cli/browser v1.2.0 h1:yvU7e9qf97kZqGFX6n2zJPHsmSObY9ske+iCvKelvXg=
github.com/cli/browser v1.2.0/go.mod h1:xFFnXLVcAyW9ni0cuo6NnrbCP75JxJ0RO7VtCBiH/oI=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
Expand Down Expand Up @@ -660,6 +664,7 @@ golang.org/x/sys v0.0.0-20210225134936-a50acf3fe073/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210616045830-e2b7044e8c71/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211025201205-69cdffdb9359/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/cmd/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ type CLI struct {
Update UpdateCmd `cmd:"" help:"update topaz container version"`
Uninstall UninstallCmd `cmd:"" help:"uninstall topaz container"`
Version VersionCmd `cmd:"" help:"version information"`
Console ConsoleCmd `cmd:"" help:"opens the console in the browser"`
NoCheck bool `name:"no-check" env:"TOPAZ_NO_CHECK" help:"disable local container status check"`
}

Expand Down
22 changes: 22 additions & 0 deletions pkg/cli/cmd/console.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package cmd

import (
"strings"

"github.com/aserto-dev/topaz/pkg/cli/cc"
"github.com/cli/browser"
)

type ConsoleCmd struct {
ConsoleAdress string `arg:"" default:"https://localhost:8080/ui/directory" help:"gateway address of the console service"`
}

func (cmd *ConsoleCmd) Run(c *cc.CommonCtx) error {
if !strings.HasSuffix(cmd.ConsoleAdress, "/ui/directory") {
cmd.ConsoleAdress = cmd.ConsoleAdress + "/ui/directory"
}
if !strings.HasPrefix(cmd.ConsoleAdress, "https://") {
cmd.ConsoleAdress = "https://" + cmd.ConsoleAdress
}
return browser.OpenURL(cmd.ConsoleAdress)
}

0 comments on commit d436561

Please sign in to comment.