Documentation
¶
Overview ¶
Package http provides an HTTP interface allowing HTTP clients to interact with OTF.
Index ¶
- Constants
- func Absolute(r *http.Request, path string) string
- func ExternalHost(r *http.Request) string
- func GetHealthz(w http.ResponseWriter, r *http.Request)
- func MarshalPayload(w io.Writer, r *http.Request, models interface{}) error
- func SanitizeAddress(address string) (string, error)
- func SanitizeHostname(hostname string) (string, error)
- type AgentToken
- type AnsiStripper
- type Client
- type ClientFactory
- type Config
- type ConfigOption
- type ConfigurationVersion
- type ConfigurationVersionList
- type Entitlements
- type Healthz
- type Organization
- type OrganizationList
- type RegistrySession
- type RetryLogHook
- type Route
- type Router
- func (r *Router) DEL(path string, h http.HandlerFunc) *mux.Route
- func (r *Router) GET(path string, h http.HandlerFunc) *mux.Route
- func (r *Router) Headers(pairs ...string) *Route
- func (r *Router) PST(path string, h http.HandlerFunc) *mux.Route
- func (r *Router) PTC(path string, h http.HandlerFunc) *mux.Route
- func (r *Router) PUT(path string, h http.HandlerFunc) *mux.Route
- func (r *Router) PathPrefix(prefix string) *Route
- func (r *Router) Sub(group func(r *Router))
- type Run
- type RunList
- type Server
- func (s *Server) ApplyRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) CancelRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateAgentToken(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateConfigurationVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateRegistrySession(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateVariable(w http.ResponseWriter, r *http.Request)
- func (s *Server) CreateWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) CurrentStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteVariable(w http.ResponseWriter, r *http.Request)
- func (s *Server) DeleteWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) DiscardRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) DownloadConfigurationVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) DownloadStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) ForceCancelRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetApply(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetConfigurationVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetCurrentAgent(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetCurrentUser(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetEntitlements(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRun(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetRunsQueue(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetStateVersion(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetVariable(w http.ResponseWriter, r *http.Request)
- func (s *Server) GetWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListConfigurationVersions(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListOrganizations(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListRuns(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListStateVersions(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListVariables(w http.ResponseWriter, r *http.Request)
- func (s *Server) ListWorkspaces(w http.ResponseWriter, r *http.Request)
- func (s *Server) LockWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) Start(ctx context.Context, ln net.Listener) (err error)
- func (s *Server) UnlockWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateOrganization(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateVariable(w http.ResponseWriter, r *http.Request)
- func (s *Server) UpdateWorkspace(w http.ResponseWriter, r *http.Request)
- func (s *Server) UploadConfigurationVersion() http.HandlerFunc
- func (s *Server) WellKnown(w http.ResponseWriter, r *http.Request)
- type ServerConfig
- type Signer
- type StateVersion
- type StateVersionList
- type User
- type Variable
- type VariableList
- type Verifier
- type WebRoute
- type WellKnown
- type Workspace
- type WorkspaceList
Constants ¶
const ( // DefaultBasePath on which the API is served. DefaultBasePath = "/api/v2/" // PingEndpoint is a no-op API endpoint used to configure the rate limiter PingEndpoint = "ping" )
const (
DefaultAddress = "localhost:8080"
)
Variables ¶
This section is empty.
Functions ¶
func Absolute ¶ added in v0.0.19
Absolute returns an absolute URL for the given path. It uses the http request to determine the correct hostname and scheme to use. Handles situations where otf is sitting behind a reverse proxy, using the X-Forwarded-* headers the proxy sets.
func ExternalHost ¶ added in v0.0.19
ExternalHost uses the incoming HTTP request to determine the host:port on which this server can be reached externally by clients and the internet.
func GetHealthz ¶ added in v0.0.12
func GetHealthz(w http.ResponseWriter, r *http.Request)
func MarshalPayload ¶
MarshalPayload marshals the models object into a JSON-API response.
func SanitizeAddress ¶ added in v0.0.8
SanitizeAddress ensures address is in format https://<host>:<port>
func SanitizeHostname ¶ added in v0.0.8
SanitizeHostname ensures hostname is in the format <host>:<port>
Types ¶
type AgentToken ¶ added in v0.0.12
type AgentToken struct {
*otf.AgentToken
}
func (*AgentToken) ToJSONAPI ¶ added in v0.0.12
func (t *AgentToken) ToJSONAPI() any
ToJSONAPI assembles a JSON-API DTO.
type AnsiStripper ¶ added in v0.0.11
AnsiStripper strips ANSI codes and makes the stripped output available via Read()
func NewAnsiStripper ¶ added in v0.0.11
func NewAnsiStripper(input io.Reader) *AnsiStripper
NewAnsiStripper constructs an ANSI stripper, stripping ANSI codes from the input stream.
type Client ¶ added in v0.0.8
type Client interface { otf.Application }
Client implements all the application services, for client-side usage.
type ClientFactory ¶ added in v0.0.8
ClientFactory implementations of capable of constructing new OTF clients
type Config ¶ added in v0.0.8
type Config struct { // The address of the Terraform Enterprise API. Address string // The base path on which the API is served. BasePath string // API token used to access the Terraform Enterprise API. Token string // Headers that will be added to every request. Headers http.Header // A custom HTTP client to use. HTTPClient *http.Client // RetryLogHook is invoked each time a request is retried. RetryLogHook RetryLogHook // contains filtered or unexported fields }
Config provides configuration details to the API client.
func NewConfig ¶ added in v0.0.8
func NewConfig(opts ...ConfigOption) (*Config, error)
NewConfig constructs a new http client config. Options are only applied when NewClient() is called.
type ConfigOption ¶ added in v0.0.8
type ConfigurationVersion ¶ added in v0.0.8
type ConfigurationVersion struct { *otf.ConfigurationVersion *Server }
func (*ConfigurationVersion) ToJSONAPI ¶ added in v0.0.12
func (cv *ConfigurationVersion) ToJSONAPI() any
ToJSONAPI assembles a JSONAPI DTO.
type ConfigurationVersionList ¶ added in v0.0.8
type ConfigurationVersionList struct { *otf.ConfigurationVersionList *Server }
func (*ConfigurationVersionList) ToJSONAPI ¶ added in v0.0.12
func (l *ConfigurationVersionList) ToJSONAPI() any
ToJSONAPI assembles a JSONAPI DTO
type Entitlements ¶ added in v0.0.12
type Entitlements struct {
*otf.Entitlements
}
func (*Entitlements) ToJSONAPI ¶ added in v0.0.12
func (e *Entitlements) ToJSONAPI() any
ToJSONAPI assembles a JSONAPI DTO
type Organization ¶ added in v0.0.8
type Organization struct {
*otf.Organization
}
func (*Organization) ToJSONAPI ¶ added in v0.0.12
func (org *Organization) ToJSONAPI() any
ToJSONAPI assembles a JSONAPI DTO
type OrganizationList ¶ added in v0.0.8
type OrganizationList struct {
*otf.OrganizationList
}
func (*OrganizationList) ToJSONAPI ¶ added in v0.0.12
func (l *OrganizationList) ToJSONAPI() any
ToJSONAPI assembles a JSON-API DTO.
type RegistrySession ¶ added in v0.0.19
type RegistrySession struct {
*otf.RegistrySession
}
func (*RegistrySession) ToJSONAPI ¶ added in v0.0.19
func (t *RegistrySession) ToJSONAPI() any
ToJSONAPI assembles a JSON-API DTO.
type RetryLogHook ¶ added in v0.0.8
RetryLogHook allows a function to run before each retry.
type Route ¶ added in v0.0.12
Route wraps mux's Route, adding various helper methods
func (*Route) PathPrefix ¶ added in v0.0.12
type Router ¶ added in v0.0.12
Router wraps mux's Router, adding various helper methods
func (*Router) DEL ¶ added in v0.0.12
DEL is a helper method for a mux handler with a delete method. Shortened name so that it lines up nicely with get when reading the routing code.
func (*Router) PST ¶ added in v0.0.12
PST is a helper method for a mux handler with a post method. Shortened to PST so that it lines up nicely with get when reading the routing code.
func (*Router) PTC ¶ added in v0.0.12
PTC is a helper method for a mux handler with a patch method. Shortened name so that it lines up nicely with get when reading the routing code.
func (*Router) PathPrefix ¶ added in v0.0.12
type Server ¶
type Server struct { ServerConfig logr.Logger // provides access to otf services otf.Application CacheService *bigcache.BigCache // the http router, exported so that other pkgs can add routes *Router *surl.Signer // contains filtered or unexported fields }
Server provides an HTTP/S server
func NewServer ¶
func NewServer(logger logr.Logger, cfg ServerConfig, app otf.Application, db otf.DB, cache *bigcache.BigCache) (*Server, error)
NewServer is the constructor for Server
func (*Server) CreateAgentToken ¶ added in v0.0.12
func (s *Server) CreateAgentToken(w http.ResponseWriter, r *http.Request)
func (*Server) CreateConfigurationVersion ¶
func (s *Server) CreateConfigurationVersion(w http.ResponseWriter, r *http.Request)
func (*Server) CreateOrganization ¶
func (s *Server) CreateOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) CreateRegistrySession ¶ added in v0.0.19
func (s *Server) CreateRegistrySession(w http.ResponseWriter, r *http.Request)
func (*Server) CreateStateVersion ¶
func (s *Server) CreateStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) CreateVariable ¶ added in v0.0.20
func (s *Server) CreateVariable(w http.ResponseWriter, r *http.Request)
func (*Server) CreateWorkspace ¶
func (s *Server) CreateWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) CurrentStateVersion ¶
func (s *Server) CurrentStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteOrganization ¶
func (s *Server) DeleteOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteVariable ¶ added in v0.0.20
func (s *Server) DeleteVariable(w http.ResponseWriter, r *http.Request)
func (*Server) DeleteWorkspace ¶
func (s *Server) DeleteWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) DiscardRun ¶
func (s *Server) DiscardRun(w http.ResponseWriter, r *http.Request)
func (*Server) DownloadConfigurationVersion ¶ added in v0.0.12
func (s *Server) DownloadConfigurationVersion(w http.ResponseWriter, r *http.Request)
func (*Server) DownloadStateVersion ¶
func (s *Server) DownloadStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) ForceCancelRun ¶
func (s *Server) ForceCancelRun(w http.ResponseWriter, r *http.Request)
func (*Server) GetConfigurationVersion ¶
func (s *Server) GetConfigurationVersion(w http.ResponseWriter, r *http.Request)
func (*Server) GetCurrentAgent ¶ added in v0.0.12
func (s *Server) GetCurrentAgent(w http.ResponseWriter, r *http.Request)
func (*Server) GetCurrentUser ¶ added in v0.0.12
func (s *Server) GetCurrentUser(w http.ResponseWriter, r *http.Request)
func (*Server) GetEntitlements ¶
func (s *Server) GetEntitlements(w http.ResponseWriter, r *http.Request)
func (*Server) GetOrganization ¶
func (s *Server) GetOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) GetRunsQueue ¶ added in v0.0.12
func (s *Server) GetRunsQueue(w http.ResponseWriter, r *http.Request)
func (*Server) GetStateVersion ¶
func (s *Server) GetStateVersion(w http.ResponseWriter, r *http.Request)
func (*Server) GetVariable ¶ added in v0.0.20
func (s *Server) GetVariable(w http.ResponseWriter, r *http.Request)
func (*Server) GetWorkspace ¶
func (s *Server) GetWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) ListConfigurationVersions ¶
func (s *Server) ListConfigurationVersions(w http.ResponseWriter, r *http.Request)
func (*Server) ListOrganizations ¶
func (s *Server) ListOrganizations(w http.ResponseWriter, r *http.Request)
func (*Server) ListStateVersions ¶
func (s *Server) ListStateVersions(w http.ResponseWriter, r *http.Request)
func (*Server) ListVariables ¶ added in v0.0.20
func (s *Server) ListVariables(w http.ResponseWriter, r *http.Request)
func (*Server) ListWorkspaces ¶
func (s *Server) ListWorkspaces(w http.ResponseWriter, r *http.Request)
func (*Server) LockWorkspace ¶
func (s *Server) LockWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) Start ¶ added in v0.0.19
Start starts serving http traffic on the given listener and waits until the server exits due to error or the context is cancelled.
func (*Server) UnlockWorkspace ¶
func (s *Server) UnlockWorkspace(w http.ResponseWriter, r *http.Request)
func (*Server) UpdateOrganization ¶
func (s *Server) UpdateOrganization(w http.ResponseWriter, r *http.Request)
func (*Server) UpdateVariable ¶ added in v0.0.20
func (s *Server) UpdateVariable(w http.ResponseWriter, r *http.Request)
func (*Server) UpdateWorkspace ¶
func (s *Server) UpdateWorkspace(w http.ResponseWriter, r *http.Request)
UpdateWorkspace updates a workspace.
TODO: support updating workspace's vcs repo.
func (*Server) UploadConfigurationVersion ¶
func (s *Server) UploadConfigurationVersion() http.HandlerFunc
type ServerConfig ¶ added in v0.0.12
type ServerConfig struct { SSL bool CertFile, KeyFile string EnableRequestLogging bool SiteToken string // site admin token Secret string // Secret for signing MaxConfigSize int64 // Maximum permitted config upload size in bytes }
ServerConfig is the http server config
func (*ServerConfig) Validate ¶ added in v0.0.12
func (cfg *ServerConfig) Validate() error
type StateVersion ¶ added in v0.0.8
type StateVersion struct {
*otf.StateVersion
}
func (*StateVersion) ToJSONAPI ¶ added in v0.0.12
func (sv *StateVersion) ToJSONAPI() any
ToJSONAPI assembles a JSON-API DTO.
type StateVersionList ¶ added in v0.0.8
type StateVersionList struct {
*otf.StateVersionList
}
func (*StateVersionList) ToJSONAPI ¶ added in v0.0.12
func (l *StateVersionList) ToJSONAPI() any
ToJSONAPI assembles a JSON-API DTO.
type VariableList ¶ added in v0.0.20
type VariableList struct {
// contains filtered or unexported fields
}
VariableList assembles a workspace list JSONAPI DTO
func (*VariableList) ToJSONAPI ¶ added in v0.0.20
func (l *VariableList) ToJSONAPI() any
type Workspace ¶ added in v0.0.8
type Workspace struct { otf.Application *otf.Workspace // contains filtered or unexported fields }
Workspace assembles a workspace JSONAPI DTO
type WorkspaceList ¶ added in v0.0.8
type WorkspaceList struct { otf.Application *otf.WorkspaceList // contains filtered or unexported fields }
WorkspaceList assembles a workspace list JSONAPI DTO
func (*WorkspaceList) ToJSONAPI ¶ added in v0.0.12
func (l *WorkspaceList) ToJSONAPI() any
Source Files
¶
- agent_token.go
- agent_token_client.go
- ansi_stripper.go
- apply.go
- client.go
- client_config.go
- client_factory.go
- configuration_version.go
- configuration_version_client.go
- configuration_version_test_helper.go
- events.go
- events_client.go
- healthz.go
- http.go
- jsonapi.go
- log_client.go
- logs.go
- middleware.go
- middleware_test_helper.go
- module.go
- organization.go
- organization_client.go
- plan.go
- registry_session.go
- registry_session_client.go
- router.go
- run.go
- run_client.go
- server.go
- signed_urls.go
- state_version.go
- state_version_client.go
- test_helpers.go
- user.go
- variable.go
- variable_client.go
- webhook.go
- well_known.go
- workspace.go
- workspace_client.go
Directories
¶
Path | Synopsis |
---|---|
Package decode contains decoders for various HTTP artefacts
|
Package decode contains decoders for various HTTP artefacts |
Package dto provides DTO models for serialization/deserialization to/from JSON-API
|
Package dto provides DTO models for serialization/deserialization to/from JSON-API |
Package html provides the otf web app, serving up HTML formatted pages and associated assets (CSS, JS, etc).
|
Package html provides the otf web app, serving up HTML formatted pages and associated assets (CSS, JS, etc). |
paths
Package paths provides rails-style path helpers for use with the web app.
|
Package paths provides rails-style path helpers for use with the web app. |