Skip to content

Commit

Permalink
fix: minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed Jul 26, 2023
1 parent fa0d339 commit 9ecf468
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions cmd/cloudx/client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,14 @@ func (h *CommandHelper) HasValidContext() (*AuthContext, bool, error) {

sess, _, err := client.FrontendApi.ToSession(h.Ctx).XSessionToken(c.SessionToken).Execute()
if err != nil {
if h.IsQuiet {
return nil, false, errors.WithStack(ErrNoConfigQuiet)
}
return nil, false, nil
} else if sess == nil {
if h.IsQuiet {
return nil, false, errors.WithStack(ErrNoConfigQuiet)
}
return nil, false, nil
}
return c, true, nil
Expand Down
14 changes: 7 additions & 7 deletions cmd/cloudx/proxy/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,39 +266,39 @@ func run(cmd *cobra.Command, conf *config, version string, name string) error {
})

if conf.isTunnel {
_, _ = fmt.Fprintf(os.Stderr, `To access Ory's APIs, use URL
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), `To access Ory's APIs, use URL
%s
%[1]s
and configure your SDKs to point to it, for example in JavaScript:
import { V0alpha2Api, Configuration } from '@ory/client'
const ory = new V0alpha2Api(new Configuration({
basePath: 'http://localhost:4000',
basePath: '%[1]s',
baseOptions: {
withCredentials: true
}
}))
`, conf.publicURL.String())
} else {
_, _ = fmt.Fprintf(os.Stderr, `To access your application via the Ory Proxy, open:
_, _ = fmt.Fprintf(cmd.ErrOrStderr(), `To access your application via the Ory Proxy, open:
%s
`, conf.publicURL.String())
}

if !conf.noOpen {
// #nosec G204 - this is ok
if err := exec.Command("open", conf.publicURL.String()).Run(); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Unable to automatically open the proxy URL in your browser. Please open it manually!")
if err := exec.Command("open", fmt.Sprintf("%q", conf.publicURL.String())).Run(); err != nil {
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), "Unable to automatically open the proxy URL in your browser. Please open it manually!")
}
}

if err := graceful.Graceful(func() error {
return server.ListenAndServe()
}, func(ctx context.Context) error {
_, _ = fmt.Fprintf(os.Stderr, "http server was shutdown gracefully\n")
_, _ = fmt.Fprintln(cmd.ErrOrStderr(), "http server was shutdown gracefully")
if err := server.Shutdown(ctx); err != nil {
return err
}
Expand Down

0 comments on commit 9ecf468

Please sign in to comment.