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

Method ensureClientURL

cli/root.go:603–621  ·  view source on GitHub ↗

ensureClientURL loads the client URL from the config file if it wasn't provided via --url or CODER_URL.

()

Source from the content-addressed store, hash-verified

601// ensureClientURL loads the client URL from the config file if it
602// wasn't provided via --url or CODER_URL.
603func (r *RootCmd) ensureClientURL() error {
604 if r.clientURL != nil && r.clientURL.String() != "" {
605 return nil
606 }
607 rawURL, err := r.createConfig().URL().Read()
608 // If the configuration files are absent, the user is logged out.
609 if os.IsNotExist(err) {
610 binPath, err := os.Executable()
611 if err != nil {
612 binPath = "coder"
613 }
614 return xerrors.Errorf(notLoggedInMessage, binPath)
615 }
616 if err != nil {
617 return err
618 }
619 r.clientURL, err = url.Parse(strings.TrimSpace(rawURL))
620 return err
621}
622
623// ensureTLSConfig loads the TLS configuration from files if specified.
624// The resulting config is used for both API requests and DERP connections.

Callers 2

loginTokenMethod · 0.95
InitClientMethod · 0.95

Calls 6

createConfigMethod · 0.95
ReadMethod · 0.65
ParseMethod · 0.65
StringMethod · 0.45
URLMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected