MCPcopy Index your code
hub / github.com/coder/coder / existsCmd

Method existsCmd

cli/connect.go:23–46  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21}
22
23func (*RootCmd) existsCmd() *serpent.Command {
24 cmd := &serpent.Command{
25 Use: "exists <hostname>",
26 Short: "Checks if the given hostname exists via Coder Connect.",
27 Long: "This command is designed to be used in scripts to check if the given hostname exists via Coder " +
28 "Connect. It prints no output. It returns exit code 0 if it does exist and code 1 if it does not.",
29 Middleware: serpent.Chain(
30 serpent.RequireNArgs(1),
31 ),
32 Handler: func(inv *serpent.Invocation) error {
33 hostname := inv.Args[0]
34 exists, err := workspacesdk.ExistsViaCoderConnect(inv.Context(), hostname)
35 if err != nil {
36 return err
37 }
38 if !exists {
39 // we don't want to print any output, since this command is designed to be a check in scripts / SSH config.
40 return ErrSilent
41 }
42 return nil
43 },
44 }
45 return cmd
46}

Callers 1

connectCmdMethod · 0.95

Calls 2

ExistsViaCoderConnectFunction · 0.92
ContextMethod · 0.65

Tested by

no test coverage detected