html

package
v0.0.15 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 2, 2022 License: MPL-2.0 Imports: 41 Imported by: 0

Documentation

Overview

Package html provides the otf web app, serving up HTML formatted pages and associated assets (CSS, JS, etc).

Index

Constants

View Source
const (
	FlashSuccess flashType = "success"
	FlashError   flashType = "error"
)
View Source
const DefaultGithubHostname = "github.com"
View Source
const DefaultGitlabHostname = "gitlab.com"
View Source
const DefaultPathPrefix = "/"

Variables

View Source
var (
	ErrOAuthCredentialsUnspecified = errors.New("no oauth credentials have been specified")
	ErrOAuthCredentialsIncomplete  = errors.New("must specify both client ID and client secret")
)

Functions

func AddRoutes

func AddRoutes(logger logr.Logger, config *Config, srvConfig *otfhttp.ServerConfig, services otf.Application, router *otfhttp.Router) error

AddRoutes adds routes for the html web app.

func NewGithubEnterpriseClient

func NewGithubEnterpriseClient(hostname string, httpClient *http.Client) (*github.Client, error)

func NewTestGithubServer

func NewTestGithubServer(t *testing.T, user *otf.User) *httptest.Server

Types

type Application

type Application struct {

	// otf service accessors
	otf.Application

	// logger for logging messages
	logr.Logger
	// server-side-events server
	*sse.Server
	// contains filtered or unexported fields
}

Application is the otf web app.

type ApplicationOption

type ApplicationOption func(*Application)

func WithSiteToken

func WithSiteToken(token string) ApplicationOption

type Authenticator

type Authenticator struct {
	Cloud
	otf.Application
}

Authenticator logs people onto the system, synchronising their user account and various organization and team memberships from an external directory.

func NewAuthenticatorsFromConfig

func NewAuthenticatorsFromConfig(app otf.Application, configs ...CloudConfig) ([]*Authenticator, error)

NewAuthenticatorsFromConfig constructs authenticators from the given cloud configurations. If config is unspecified then its corresponding cloud authenticator is skipped.

func (*Authenticator) RequestPath

func (a *Authenticator) RequestPath() string

type Cloud

type Cloud interface {
	NewDirectoryClient(context.Context, DirectoryClientOptions) (DirectoryClient, error)
	CloudConfig
}

type CloudConfig

type CloudConfig interface {
	Valid() error
	NewCloud() (Cloud, error)
	CloudName() string
	Endpoint() (oauth2.Endpoint, error)
	Scopes() []string
	ClientID() string
	ClientSecret() string
	SkipTLSVerification() bool
}

type Config

type Config struct {
	DevMode bool
	// contains filtered or unexported fields
}

Config is the web app configuration.

func NewConfigFromFlags

func NewConfigFromFlags(flags *pflag.FlagSet) *Config

NewConfigFromFlags binds flags to the config. The flagset must be parsed in order for the config to be populated.

type DirectoryClient

type DirectoryClient interface {
	GetUser(ctx context.Context) (*otf.User, error)
}

type DirectoryClientOptions

type DirectoryClientOptions struct {
	Token *oauth2.Token

	*oauth2.Config
}

type GithubCloud

type GithubCloud struct {
	*GithubConfig
}

func (GithubCloud) CloudName

func (g GithubCloud) CloudName() string

func (GithubCloud) Endpoint

func (g GithubCloud) Endpoint() (oauth2.Endpoint, error)

func (GithubCloud) Hostname

func (g GithubCloud) Hostname() string

func (*GithubCloud) NewDirectoryClient

func (g *GithubCloud) NewDirectoryClient(ctx context.Context, opts DirectoryClientOptions) (DirectoryClient, error)

func (GithubCloud) Scopes

func (g GithubCloud) Scopes() []string

func (GithubCloud) SkipTLSVerification

func (g GithubCloud) SkipTLSVerification() bool

type GithubConfig

type GithubConfig struct {
	// contains filtered or unexported fields
}

func NewGithubConfigFromFlags

func NewGithubConfigFromFlags(flags *pflag.FlagSet) *GithubConfig

func (GithubConfig) CloudName

func (g GithubConfig) CloudName() string

func (GithubConfig) Endpoint

func (g GithubConfig) Endpoint() (oauth2.Endpoint, error)

func (GithubConfig) Hostname

func (g GithubConfig) Hostname() string

func (*GithubConfig) NewCloud

func (cfg *GithubConfig) NewCloud() (Cloud, error)

func (GithubConfig) Scopes

func (g GithubConfig) Scopes() []string

func (GithubConfig) SkipTLSVerification

func (g GithubConfig) SkipTLSVerification() bool

type GitlabConfig

type GitlabConfig struct {
	// contains filtered or unexported fields
}

func NewGitlabConfigFromFlags

func NewGitlabConfigFromFlags(flags *pflag.FlagSet) *GitlabConfig

func (GitlabConfig) CloudName

func (g GitlabConfig) CloudName() string

func (GitlabConfig) Endpoint

func (g GitlabConfig) Endpoint() (oauth2.Endpoint, error)

func (GitlabConfig) Hostname

func (g GitlabConfig) Hostname() string

func (*GitlabConfig) NewCloud

func (cfg *GitlabConfig) NewCloud() (Cloud, error)

func (GitlabConfig) Scopes

func (g GitlabConfig) Scopes() []string

func (GitlabConfig) SkipTLSVerification

func (g GitlabConfig) SkipTLSVerification() bool

type ListOptions

type ListOptions struct {
	// The page number to request. The results vary based on the PageSize.
	PageNumber int `schema:"page[number],omitempty"`
	// The number of elements returned in a single page.
	PageSize int `schema:"page[size],omitempty"`
}

ListOptions is used to specify pagination options when making HTTP requests. Pagination allows breaking up large result sets into chunks, or "pages".

type OAuthCredentials

type OAuthCredentials struct {
	// contains filtered or unexported fields
}

func (*OAuthCredentials) AddFlags

func (a *OAuthCredentials) AddFlags(flags *pflag.FlagSet)

func (*OAuthCredentials) ClientID

func (a *OAuthCredentials) ClientID() string

func (*OAuthCredentials) ClientSecret

func (a *OAuthCredentials) ClientSecret() string

func (*OAuthCredentials) Valid

func (a *OAuthCredentials) Valid() error

type UserList

type UserList struct {
	Items []*otf.User
	// contains filtered or unexported fields
}

func (UserList) OrganizationName

func (l UserList) OrganizationName() string

func (UserList) TeamName

func (l UserList) TeamName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL