Documentation
¶
Overview ¶
Package html provides the otf web app, serving up HTML formatted pages and associated assets (CSS, JS, etc).
Index ¶
- Constants
- Variables
- func AddRoutes(logger logr.Logger, opts ApplicationOptions) error
- func Error(w http.ResponseWriter, err string, code int)
- func FlashError(w http.ResponseWriter, msg string)
- func FlashSuccess(w http.ResponseWriter, msg string)
- func NewViewEngine(devmode bool) (*viewEngine, error)
- type Application
- type ApplicationOptions
- type Authenticator
- type NewOAuthClientConfig
- type OAuthClient
- func (a *OAuthClient) CallbackHandler(r *http.Request) (*oauth2.Token, error)
- func (a *OAuthClient) CallbackPath() string
- func (a *OAuthClient) NewClient(ctx context.Context, token *oauth2.Token) (cloud.Client, error)
- func (a *OAuthClient) RequestHandler(w http.ResponseWriter, r *http.Request)
- func (a *OAuthClient) RequestPath() string
- func (a *OAuthClient) String() string
Constants ¶
const ( FlashSuccessType flashType = "success" FlashErrorType flashType = "error" )
const DefaultPathPrefix = "/"
Variables ¶
var ErrOAuthCredentialsIncomplete = errors.New("must specify both client ID and client secret")
Functions ¶
func AddRoutes ¶
func AddRoutes(logger logr.Logger, opts ApplicationOptions) error
AddRoutes adds routes for the html web app.
func NewViewEngine ¶ added in v0.0.27
Types ¶
type Application ¶
type Application struct {
otf.Application // otf service accessors
logr.Logger // logger for logging messages
*sse.Server // server-side-events server
// contains filtered or unexported fields
}
Application is the otf web app.
func (Application) Render ¶ added in v0.0.27
func (ve Application) Render(name string, w http.ResponseWriter, r *http.Request, content interface{})
Render the view using the template. Note this should be the last thing called in a handler because it writes an HTTP5xx to the response if there is an error.
type ApplicationOptions ¶ added in v0.0.19
type ApplicationOptions struct {
DevMode bool
CloudConfigs []*cloud.CloudOAuthConfig // for configuring authenticators
*otfhttp.ServerConfig
*otfhttp.Router
otf.Application
otf.VariableService
}
ApplicationOptions are options for configuring the web app
type Authenticator ¶
type Authenticator struct {
otf.Application
// contains filtered or unexported fields
}
Authenticator logs people onto the system using an OAuth handshake with an Identity provider before synchronising their user account and various organization and team memberships from the provider.
type NewOAuthClientConfig ¶ added in v0.0.19
type NewOAuthClientConfig struct {
*cloud.CloudOAuthConfig
// contains filtered or unexported fields
}
NewOAuthClientConfig is configuration for constructing an OAuth client
type OAuthClient ¶ added in v0.0.19
OAuthClient performs the client role in an oauth handshake, requesting authorization from the user to access their account details on a particular cloud.
func NewOAuthClient ¶ added in v0.0.19
func NewOAuthClient(cfg NewOAuthClientConfig) (*OAuthClient, error)
func (*OAuthClient) CallbackHandler ¶ added in v0.0.19
func (*OAuthClient) CallbackPath ¶ added in v0.0.19
func (a *OAuthClient) CallbackPath() string
func (*OAuthClient) NewClient ¶ added in v0.0.19
NewClient constructs a cloud client configured with the given oauth token for authentication.
func (*OAuthClient) RequestHandler ¶ added in v0.0.19
func (a *OAuthClient) RequestHandler(w http.ResponseWriter, r *http.Request)
RequestHandler initiates the oauth flow, redirecting user to the auth server
func (*OAuthClient) RequestPath ¶ added in v0.0.19
func (a *OAuthClient) RequestPath() string
func (*OAuthClient) String ¶ added in v0.0.19
func (a *OAuthClient) String() string
String provides a human-readable identifier for the oauth client, using the name of its underlying cloud provider