vespa

package
v0.0.0-...-686cbea Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 39 Imported by: 0

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

View Source
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
)
View Source
const (
	CURRENT_GCC_TOOLSET = "/opt/rh/gcc-toolset/root/usr/bin"
)

Variables

View Source
var (
	DefaultApplication = ApplicationID{Tenant: "default", Application: "application", Instance: "default"}
	DefaultZone        = ZoneID{Environment: "prod", Region: "default"}
	DefaultDeployment  = Deployment{Application: DefaultApplication, Zone: DefaultZone}
)
View Source
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.

View Source
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.

View Source
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.

View Source
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

func CreateAPIKey() ([]byte, error)

CreateAPIKey creates a EC private key encoded as PEM

func Deactivate

func Deactivate(deployment DeploymentOptions) error

Deactivate given deployment

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 ExportDefaultEnvTo(w io.Writer) error

func ExportDefaultEnvToSh

func ExportDefaultEnvToSh() error

parse default-env.txt, then dump export statements for "sh" to stdout

func ExportSecurityEnvToSh

func ExportSecurityEnvToSh()

func Fetch

func Fetch(deployment DeploymentOptions, path string) (string, error)

func FindAndVerifyVespaHome

func FindAndVerifyVespaHome() string

func FindHome

func FindHome() string

func FindOurHostname

func FindOurHostname() (string, error)

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

func FingerprintMD5(pemPublicKey []byte) (string, error)

FingerprintMD5 returns a MD5 fingerprint of publicKey.

func HasFileUnderVespaHome

func HasFileUnderVespaHome(fn string) (bool, string)

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 IdToURLPath(documentId string) (string, error)

func LoadDefaultEnv

func LoadDefaultEnv() error

backwards-compatible parsing of default-env.txt

func LogLevel

func LogLevel(name string) int

LogLevel returns an int representing a named log level.

func MaybeSwitchUser

func MaybeSwitchUser(action string) error

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

type ApplicationID struct {
	Tenant      string
	Application string
	Instance    string
}

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

type ApplicationPackage struct {
	Path     string
	TestPath string
}

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) Unzip

func (ap *ApplicationPackage) Unzip(test bool) (string, error)

func (*ApplicationPackage) Validate

func (ap *ApplicationPackage) Validate() error

type Authenticator

type Authenticator interface {
	Authenticate(request *http.Request) error
}

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

type CurlWriter struct {
	Writer    io.Writer
	InputFile string
}

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

func ParseLogEntry(s string) (LogEntry, error)

ParseLogEntry parses a Vespa log entry from string s.

func ReadLogEntries

func ReadLogEntries(r io.Reader) ([]LogEntry, error)

ReadLogEntries reads and parses all log entries from reader r.

func (*LogEntry) Format

func (le *LogEntry) Format(dequote bool) string

type LogLinePrepareResponse

type LogLinePrepareResponse struct {
	Time    int64
	Level   string
	Message string
}

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 PackageOptions struct {
	// If true, a Maven-based Vespa application package is required to be compiled
	Compiled bool

	// If true, only consider the source directores of the application package
	SourceOnly bool
}

type PemKeyPair

type PemKeyPair struct {
	Certificate []byte
	PrivateKey  []byte
}

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

func FindService(name string, services []*Service) (*Service, error)

FindService returns the service of given name, found among services, if any.

func (*Service) Description

func (s *Service) Description() string

func (*Service) Do

func (s *Service) Do(request *http.Request, timeout time.Duration) (*http.Response, error)

Do sends request to this service. Authentication of the request happens automatically.

func (*Service) SetClient

func (s *Service) SetClient(client httputil.Client)

SetClient sets a custom HTTP client that this service should use.

func (*Service) Wait

func (s *Service) Wait(timeout time.Duration) error

Wait polls the health check of this service until it succeeds or timeout passes.

type Submission

type Submission struct {
	Risk        int    `json:"risk,omitempty"`
	Commit      string `json:"commit,omitempty"`
	Description string `json:"description,omitempty"`
	AuthorEmail string `json:"authorEmail,omitempty"`
	SourceURL   string `json:"sourceUrl,omitempty"`
}

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 GetSystem

func GetSystem(name string) (System, error)

GetSystem returns the system of given name.

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) IsPublic

func (s System) IsPublic() bool

IsPublic returns whether system s is a public (Vespa Cloud) system.

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)

type ZoneID

type ZoneID struct {
	Environment string
	Region      string
}

func ZoneFromString

func ZoneFromString(s string) (ZoneID, error)

func (ZoneID) String

func (z ZoneID) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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