Skip to content

Commit

Permalink
docs: enable example templating (#314)
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik authored Jan 8, 2024
1 parent 9f2333f commit d65f6d0
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions cmd/cloudx/client/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,8 +235,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
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ require (
github.com/ory/go-acc v0.2.9-0.20230103102148-6b1c9a70dbbe // indirect
github.com/ory/go-convenience v0.1.0 // indirect
github.com/ory/keto/proto v0.11.1-alpha.0 // indirect
github.com/ory/kratos-client-go v1.0.0 // indirect
github.com/ory/kratos-client-go v0.13.1 // indirect
github.com/ory/mail/v3 v3.0.0 // indirect
github.com/ory/nosurf v1.2.7 // indirect
github.com/pborman/uuid v1.2.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -908,8 +908,8 @@ github.com/ory/keto/proto v0.11.1-alpha.0.0.20231229091411-ac44cabd79b7 h1:qHgWD
github.com/ory/keto/proto v0.11.1-alpha.0.0.20231229091411-ac44cabd79b7/go.mod h1:6RagCXA7X1hhFSVjcy13ruIo8Dq/nj4J0mcN92qL+hY=
github.com/ory/kratos v1.0.1-0.20240103153653-435d97e85f5e h1:tqYHVTlQ2a4pFESq/miUEnkyFQwB83apJOhSrdcjaas=
github.com/ory/kratos v1.0.1-0.20240103153653-435d97e85f5e/go.mod h1:8CnmDmBUkWeGSd9fB9MG+sH5Y8msJVVl+avY2TZgTDI=
github.com/ory/kratos-client-go v1.0.0 h1:mm32FMJrt4pBv2KEuhuNtiewJApc8c1Kmz0+WFHhOMA=
github.com/ory/kratos-client-go v1.0.0/go.mod h1:a2Tl4cgQAxsjR59w3EfnH5hengabjXUHiEVDzdqiZI0=
github.com/ory/kratos-client-go v0.13.1 h1:o+pFV9ZRMFSBa4QeNJYbJeLz036UWU4p+7yfKghK+0E=
github.com/ory/kratos-client-go v0.13.1/go.mod h1:hkrFJuHSBQw+qN6Ks0faOAYhAKwtpjvhCZzsQ7g/Ufc=
github.com/ory/mail v2.3.1+incompatible/go.mod h1:87D9/1gB6ewElQoN0lXJ0ayfqcj3cW3qCTXh+5E9mfU=
github.com/ory/mail/v3 v3.0.0 h1:8LFMRj473vGahFD/ntiotWEd4S80FKYFtiZTDfOQ+sM=
github.com/ory/mail/v3 v3.0.0/go.mod h1:JGAVeZF8YAlxbaFDUHqRZAKBCSeW2w1vuxf28hFbZAw=
Expand Down

0 comments on commit d65f6d0

Please sign in to comment.