Documentation ¶
Overview ¶
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
Index ¶
- Constants
- Variables
- func Activate(sessionID int64, deployment DeploymentOptions) error
- func CheckCorrectUser()
- func CreateAPIKey() ([]byte, error)
- func Deactivate(deployment DeploymentOptions) error
- func ECPrivateKeyFrom(pemPrivateKey []byte) (*ecdsa.PrivateKey, error)
- func ExportDefaultEnvTo(w io.Writer) error
- func ExportDefaultEnvToSh() error
- func ExportSecurityEnvToSh()
- func Fetch(deployment DeploymentOptions, path string) (string, error)
- func FindAndVerifyVespaHome() string
- func FindHome() string
- func FindOurHostname() (string, error)
- func FindVespaUidAndGid() (userId, groupId int)
- func FindVespaUser() string
- func FingerprintMD5(pemPublicKey []byte) (string, error)
- func HasFileUnderVespaHome(fn string) (bool, string)
- func HasOnlyIpV6() bool
- func IdToURLPath(documentId string) (string, error)
- func LoadDefaultEnv() error
- func LogLevel(name string) int
- func MaybeSwitchUser(action string) error
- func PEMPublicKeyFrom(privateKey *ecdsa.PrivateKey) ([]byte, error)
- func RunPreStart() error
- func Submit(opts DeploymentOptions, submission Submission) (int64, error)
- type APIOptions
- type ApplicationID
- type ApplicationPackage
- func (ap *ApplicationPackage) HasCertificate() bool
- func (ap *ApplicationPackage) HasDeploymentSpec() bool
- func (ap *ApplicationPackage) HasTests() bool
- func (ap *ApplicationPackage) IsJava() bool
- func (ap *ApplicationPackage) IsZip() bool
- func (ap *ApplicationPackage) Unzip(test bool) (string, error)
- func (ap *ApplicationPackage) Validate() error
- type Authenticator
- type CloudDeploymentOptions
- type CurlWriter
- type Deployment
- type DeploymentOptions
- type LogEntry
- type LogLinePrepareResponse
- type LogOptions
- type PackageOptions
- type PemKeyPair
- type PrepareResult
- type RequestSigner
- type Service
- type Submission
- type System
- func (s System) ConsoleRunURL(deployment Deployment, run int64) string
- func (s System) DeployURL(deployment Deployment) string
- func (s System) DeploymentURL(deployment Deployment) string
- func (s System) IsPublic() bool
- func (s System) RunURL(deployment Deployment, id int64) string
- func (s System) RunsURL(deployment Deployment) string
- func (s System) SubmitURL(deployment Deployment) string
- type TLSOptions
- type Target
- type VespaTlsConfig
- type ZoneID
Constants ¶
const ( // A target for a local Vespa service TargetLocal = "local" // A target for a Vespa service at a custom URL TargetCustom = "custom" // A Vespa Cloud target TargetCloud = "cloud" // A hosted Vespa target TargetHosted = "hosted" // LatestDeployment waits for a deployment to converge to latest generation LatestDeployment int64 = -1 // AnyDeployment waits for a deployment to converge on any generation AnyDeployment int64 = -2 )
const (
CURRENT_GCC_TOOLSET = "/opt/rh/gcc-toolset/root/usr/bin"
)
const ENV_CHECK = envvars.VESPA_ALREADY_SWITCHED_USER_TO
Variables ¶
var ( DefaultApplication = ApplicationID{Tenant: "default", Application: "application", Instance: "default"} DefaultZone = ZoneID{Environment: "prod", Region: "default"} DefaultDeployment = Deployment{Application: DefaultApplication, Zone: DefaultZone} )
var CDSystem = System{ Name: "cd", URL: "https://api-cd.vespa.ouryahoo.com:4443", ConsoleURL: "https://console-cd.vespa.ouryahoo.com", DefaultZone: ZoneID{Environment: "dev", Region: "cd-us-west-1"}, AthenzDomain: "vespa.vespa.cd", EndpointDomain: "cd.vespa.oath.cloud", }
CDSystem represents the CD variant of the hosted Vespa system.
var MainSystem = System{ Name: "main", URL: "https://api.vespa.ouryahoo.com:4443", ConsoleURL: "https://console.vespa.ouryahoo.com", DefaultZone: ZoneID{Environment: "dev", Region: "us-east-1"}, AthenzDomain: "vespa.vespa", EndpointDomain: "vespa.oath.cloud", }
MainSystem represents the main hosted Vespa system.
var PublicCDSystem = System{ Name: "publiccd", URL: "https://api-ctl.cd.vespa-cloud.com:4443", ConsoleURL: "https://console.cd.vespa-cloud.com", DefaultZone: ZoneID{Environment: "dev", Region: "aws-us-east-1c"}, EndpointDomain: "cd.vespa-app.cloud", }
PublicCDSystem represents the CD variant of the Vespa Cloud system.
var PublicSystem = System{ Name: "public", URL: "https://api-ctl.vespa-cloud.com:4443", ConsoleURL: "https://console.vespa-cloud.com", DefaultZone: ZoneID{Environment: "dev", Region: "aws-us-east-1c"}, EndpointDomain: "vespa-app.cloud", }
PublicSystem represents the main Vespa Cloud system.
Functions ¶
func Activate ¶
func Activate(sessionID int64, deployment DeploymentOptions) error
Activate deployment with sessionID from a past prepare
func CheckCorrectUser ¶
func CheckCorrectUser()
func CreateAPIKey ¶
CreateAPIKey creates a EC private key encoded as PEM
func ECPrivateKeyFrom ¶
func ECPrivateKeyFrom(pemPrivateKey []byte) (*ecdsa.PrivateKey, error)
ECPrivateKeyFrom reads an EC private key (in raw or PKCS8 format) from the PEM-encoded pemPrivateKey.
func ExportDefaultEnvTo ¶
func ExportDefaultEnvToSh ¶
func ExportDefaultEnvToSh() error
parse default-env.txt, then dump export statements for "sh" to stdout
func ExportSecurityEnvToSh ¶
func ExportSecurityEnvToSh()
func FindAndVerifyVespaHome ¶
func FindAndVerifyVespaHome() string
func FindOurHostname ¶
Find a good name for the host we're running on. We need something that *other* hosts can use for connnecting back to our services, preferably the canonical DNS name. If automatic detection fails, "localhost" will be returned, so single-node setups still have a good chance of working. Use the enviroment variable VESPA_HOSTNAME to override.
func FindVespaUidAndGid ¶
func FindVespaUidAndGid() (userId, groupId int)
func FindVespaUser ¶
func FindVespaUser() string
Which user should vespa services run as? If current user is root, we want to change to some non-privileged user. Should be run after LoadDefaultEnv() which possibly loads VESPA_USER Which user should vespa services run as? If current user is root, we want to change to some non-privileged user. Should be run after LoadDefaultEnv() which possibly loads VESPA_USER
func FingerprintMD5 ¶
FingerprintMD5 returns a MD5 fingerprint of publicKey.
func HasFileUnderVespaHome ¶
func HasOnlyIpV6 ¶
func HasOnlyIpV6() bool
detect if this host is IPv6-only, in which case we want to pass the flag "-Djava.net.preferIPv6Addresses=true" to any java command
func IdToURLPath ¶
func MaybeSwitchUser ¶
re-execute a vespa-wrapper action after switching to the vespa user (used by vespa-start-configserver and vespa-start-services)
func PEMPublicKeyFrom ¶
func PEMPublicKeyFrom(privateKey *ecdsa.PrivateKey) ([]byte, error)
PEMPublicKeyFrom extracts the public key from privateKey encoded as PEM.
func RunPreStart ¶
func RunPreStart() error
func Submit ¶
func Submit(opts DeploymentOptions, submission Submission) (int64, error)
Types ¶
type APIOptions ¶
type APIOptions struct { System System TLSOptions TLSOptions APIKey []byte }
CloudOptions configures URL and authentication for a cloud target.
type ApplicationID ¶
func ApplicationFromString ¶
func ApplicationFromString(s string) (ApplicationID, error)
func (ApplicationID) SerializedForm ¶
func (a ApplicationID) SerializedForm() string
func (ApplicationID) String ¶
func (a ApplicationID) String() string
type ApplicationPackage ¶
func FindApplicationPackage ¶
func FindApplicationPackage(zipOrDir string, options PackageOptions) (ApplicationPackage, error)
FindApplicationPackage finds the path to an application package from the zip file or directory zipOrDir. If requirePackaging is true, the application package is required to be packaged with mvn package.
Package to use is preferred in this order: 1. Given path, if it's a zip 2. target/application 3. src/main/application 4. Given path, if it contains services.xml
func (*ApplicationPackage) HasCertificate ¶
func (ap *ApplicationPackage) HasCertificate() bool
func (*ApplicationPackage) HasDeploymentSpec ¶
func (ap *ApplicationPackage) HasDeploymentSpec() bool
func (*ApplicationPackage) HasTests ¶
func (ap *ApplicationPackage) HasTests() bool
func (*ApplicationPackage) IsJava ¶
func (ap *ApplicationPackage) IsJava() bool
func (*ApplicationPackage) IsZip ¶
func (ap *ApplicationPackage) IsZip() bool
func (*ApplicationPackage) Validate ¶
func (ap *ApplicationPackage) Validate() error
type Authenticator ¶
Authenticator authenticates the given HTTP request.
type CloudDeploymentOptions ¶
type CloudDeploymentOptions struct { Deployment Deployment TLSOptions TLSOptions CustomURL string ClusterURLs map[string]string // Endpoints keyed on cluster name }
CloudDeploymentOptions configures the deployment to manage through a cloud target.
type CurlWriter ¶
CurlWriter configures printing of Curl-equivalent commands for HTTP requests passing through a Service.
type Deployment ¶
type Deployment struct { System System Application ApplicationID Zone ZoneID }
func (Deployment) String ¶
func (d Deployment) String() string
type DeploymentOptions ¶
type DeploymentOptions struct { Target Target ApplicationPackage ApplicationPackage Version version.Version }
func (DeploymentOptions) String ¶
func (d DeploymentOptions) String() string
type LogEntry ¶
type LogEntry struct { Time time.Time Host string Service string Component string Level string Message string }
LogEntry represents a Vespa log entry.
func ParseLogEntry ¶
ParseLogEntry parses a Vespa log entry from string s.
func ReadLogEntries ¶
ReadLogEntries reads and parses all log entries from reader r.
type LogLinePrepareResponse ¶
type LogOptions ¶
type LogOptions struct { From time.Time To time.Time Follow bool Dequote bool Writer io.Writer Level int }
LogOptions configures the log output to produce when writing log messages.
type PackageOptions ¶
type PemKeyPair ¶
PemKeyPair represents a PEM-encoded private key and X509 certificate.
func CreateKeyPair ¶
func CreateKeyPair() (PemKeyPair, error)
CreateKeyPair creates a key pair containing a private key and self-signed X509 certificate.
func (*PemKeyPair) WriteCertificateFile ¶
func (kp *PemKeyPair) WriteCertificateFile(certificateFile string, overwrite bool) error
WriteCertificateFile writes the certificate contained in this key pair to certificateFile.
func (*PemKeyPair) WritePrivateKeyFile ¶
func (kp *PemKeyPair) WritePrivateKeyFile(privateKeyFile string, overwrite bool) error
WritePrivateKeyFile writes the private key contained in this key pair to privateKeyFile.
type PrepareResult ¶
type PrepareResult struct { // Session or Run ID ID int64 LogLines []LogLinePrepareResponse }
func Deploy ¶
func Deploy(deployment DeploymentOptions) (PrepareResult, error)
Deploy deploys an application.
func Prepare ¶
func Prepare(deployment DeploymentOptions) (PrepareResult, error)
Prepare deployment and return the session ID
type RequestSigner ¶
type RequestSigner struct { KeyID string PemPrivateKey []byte // contains filtered or unexported fields }
func NewRequestSigner ¶
func NewRequestSigner(keyID string, pemPrivateKey []byte) *RequestSigner
NewRequestSigner creates a new signer using the EC pemPrivateKey. keyID names the key used to sign requests.
func (*RequestSigner) Authenticate ¶
func (rs *RequestSigner) Authenticate(request *http.Request) error
func (*RequestSigner) SignRequest ¶
func (rs *RequestSigner) SignRequest(request *http.Request) error
SignRequest signs the given HTTP request using the private key in rs
type Service ¶
type Service struct { BaseURL string Name string TLSOptions TLSOptions CurlWriter CurlWriter // contains filtered or unexported fields }
Service represents a Vespa service.
func FindService ¶
FindService returns the service of given name, found among services, if any.
func (*Service) Description ¶
func (*Service) Do ¶
Do sends request to this service. Authentication of the request happens automatically.
type Submission ¶
type System ¶
type System struct { Name string // URL is the API URL for this system. URL string ConsoleURL string // DefaultZone is default zone to use in manual deployments to this system. DefaultZone ZoneID // AthenzDomain is the Athenz domain used by this system. This is empty for systems not using Athenz for tenant // authentication. AthenzDomain string // EndpointDomain is the domain used for application endpoints in this system EndpointDomain string }
System represents a Vespa system.
func (System) ConsoleRunURL ¶
func (s System) ConsoleRunURL(deployment Deployment, run int64) string
ConsoleRunURL returns the console URL for a deployment job run in this system.
func (System) DeployURL ¶
func (s System) DeployURL(deployment Deployment) string
DeployURL returns the API URL to use for deploying to this system.
func (System) DeploymentURL ¶
func (s System) DeploymentURL(deployment Deployment) string
DeploymentURL returns the API URL of given deployment.
func (System) RunURL ¶
func (s System) RunURL(deployment Deployment, id int64) string
RunURL returns the API URL for a given deployment job run.
func (System) RunsURL ¶
func (s System) RunsURL(deployment Deployment) string
RunsURL returns the API URL listing all runs for given deployment.
func (System) SubmitURL ¶
func (s System) SubmitURL(deployment Deployment) string
SubmitURL returns the API URL for submitting an application package for production deployment.
type TLSOptions ¶
type TLSOptions struct { CACertificate []byte KeyPair []tls.Certificate TrustAll bool CACertificateFile string CertificateFile string PrivateKeyFile string }
TLSOptions holds the client certificate to use for cloud API or service requests.
type Target ¶
type Target interface { // Type returns this target's type, e.g. local or cloud. Type() string // IsCloud returns whether this target is Vespa Cloud or hosted Vespa IsCloud() bool // Deployment returns the deployment managed by this target. Deployment() Deployment // DeployService returns the service providing the deploy API on this target. DeployService() (*Service, error) // ContainerServices returns all container services of the current deployment. If timeout is positive, wait for // services to be discovered. ContainerServices(timeout time.Duration) ([]*Service, error) // AwaitDeployment waits for a deployment identified by id to succeed. It returns the id that succeeded, or an // error. The exact meaning of id depends on the implementation. AwaitDeployment(id int64, timeout time.Duration) (int64, error) // PrintLog writes the logs of this deployment using given options to control output. PrintLog(options LogOptions) error // CheckVersion verifies whether clientVersion is compatible with this target. CheckVersion(clientVersion version.Version) error }
Target represents a Vespa platform, running named Vespa services.
func CloudTarget ¶
func CloudTarget(httpClient httputil.Client, apiAuth Authenticator, deploymentAuth Authenticator, apiOptions APIOptions, deploymentOptions CloudDeploymentOptions, logOptions LogOptions, retryInterval time.Duration) (Target, error)
CloudTarget creates a Target for the Vespa Cloud or hosted Vespa platform.
func CustomTarget ¶
func CustomTarget(httpClient httputil.Client, baseURL string, tlsOptions TLSOptions, retryInterval time.Duration) Target
CustomTarget creates a Target for a Vespa platform running at baseURL.
func LocalTarget ¶
func LocalTarget(httpClient httputil.Client, tlsOptions TLSOptions, retryInterval time.Duration) Target
LocalTarget creates a target for a Vespa platform running locally.
type VespaTlsConfig ¶
type VespaTlsConfig struct { DisableHostnameValidation bool `json:"disable-hostname-validation"` Files struct { PrivateKey string `json:"private-key"` CaCertificates string `json:"ca-certificates"` Certificates string `json:"certificates"` } `json:"files"` }
func LoadTlsConfig ¶
func LoadTlsConfig() (*VespaTlsConfig, error)