Documentation ¶
Index ¶
- Constants
- func ClampMax(b []byte) string
- func GetFirstValueFromPromQuery(body []byte) (float64, error)
- func GetResultSizeFromPromQuery(body []byte) (int, error)
- func Ptr[T any](v T) *T
- type Client
- func (c *Client) Create(o client.Object) (err error)
- func (c *Client) CreateClusterRoleBinding(namespace, serviceAccount, clusterRole string) (func(), error)
- func (c *Client) CreateServiceAccount(namespace, serviceAccount string) (func(), error)
- func (c *Client) Delete(o client.Object) (err error)
- func (c *Client) ForwardPort(serviceName, namespaceName string, port int) (string, func(), error)
- func (c *Client) Get(o client.Object) (err error)
- func (c *Client) GetServiceAccountToken(namespace, name string) (string, error)
- func (c *Client) List(o client.ObjectList, opts ...client.ListOption) (err error)
- func (c *Client) Update(o client.Object) (err error)
- func (c *Client) WaitForConfigMapContainString(cm *corev1.ConfigMap, key, substr string) error
- func (c *Client) WaitForDeploymentCondition(dep *appsv1.Deployment, condition func(*appsv1.Deployment) (bool, error)) error
- func (c *Client) WaitForDeploymentRollout(dep *appsv1.Deployment) error
- func (c *Client) WaitForObjectCreated(obj client.Object) error
- func (c *Client) WaitForSecretCreated(secret *corev1.Secret) error
- func (c *Client) WaitForServiceCreated(service *corev1.Service) error
- type ClientOptions
- type HTTPSClient
- type HeaderInjector
- type PrometheusClient
- func (c *PrometheusClient) Do(method string, path string, body []byte) (*http.Response, error)
- func (c *PrometheusClient) PrometheusLabel(label string) ([]byte, error)
- func (c *PrometheusClient) PrometheusQuery(query string) ([]byte, error)
- func (c *PrometheusClient) PrometheusQueryWithStatus(query string, status int) ([]byte, error)
- func (c *PrometheusClient) PrometheusTargets() ([]byte, error)
- func (c *PrometheusClient) WaitForQueryReturn(query string, timeout time.Duration, validate func(float64) error) error
- func (c *PrometheusClient) WaitForQueryReturnEmpty(query string, timeout time.Duration) error
- func (c *PrometheusClient) WaitForQueryReturnGreaterEqualOne(query string, timeout time.Duration) error
- func (c *PrometheusClient) WaitForQueryReturnOne(query string, timeout time.Duration) error
- type QueryParameterInjector
- type WrapTransporter
Constants ¶
const ( // DefaultTimeout is the default timeout for client operations DefaultClientTimeout = 30 * time.Second // DefaultPollInterval is the default interval for polling DefaultPollInterval = 5 * time.Second // DefaultPollTimeout is the default timeout for polling DefaultPollTimeout = 10 * time.Minute )
const ( // OLSNameSpace is the namespace where the operator is deployed OLSNameSpace = "openshift-lightspeed" // OperatorDeploymentName is the name of the operator deployment OperatorDeploymentName = "lightspeed-operator-controller-manager" // LLMTokenEnvVar is the environment variable containing the LLM API token LLMTokenEnvVar = "LLM_TOKEN" // LLMTokenFirstSecretName is the name of the first secret containing the LLM API token LLMTokenFirstSecretName = "llm-token-first" // #nosec G101 // LLMTokenSecondSecretName is the name of the second secret containing the LLM API token LLMTokenSecondSecretName = "llm-token-second" // #nosec G101 // LLMApiTokenFileName LLMApiTokenFileName = "apitoken" // LLMDefaultProvider LLMDefaultProvider = "openai" // LLMProviderEnvVar is the environment variable containing the LLM provider LLMProviderEnvVar = "LLM_PROVIDER" // LLMTypeEnvVar is the environment variable containing the LLM type LLMTypeEnvVar = "LLM_TYPE" // LLMDefaultType is the default LLM type LLMDefaultType = "openai" // OpenAIDefaultModel is the default model to use OpenAIDefaultModel = "gpt-3.5-turbo" // OpenAIAlternativeModel is the alternative model to test model change OpenAIAlternativeModel = "gpt-4-1106-preview" // LLMModelEnvVar is the environment variable containing the LLM model LLMModelEnvVar = "LLM_MODEL" // OLSCRName is the name of the OLSConfig CR OLSCRName = "cluster" // AppServerDeploymentName is the name of the OLS application server deployment AppServerDeploymentName = "lightspeed-app-server" // AppServerServiceName is the name of the OLS application server service AppServerServiceName = "lightspeed-app-server" // AppServerServiceHTTPSPort is the port number of the OLS application server service AppServerServiceHTTPSPort = 8443 // ConsolePluginServiceName is the name of the OLS console plugin deployment ConsolePluginDeploymentName = "lightspeed-console-plugin" // ConsolePluginServiceName is the name of the OLS console plugin service ConsolePluginServiceName = "lightspeed-console-plugin" // ConsoleUIPluginName is the name of the OLS console plugin ConsoleUIPluginName = "lightspeed-console-plugin" // ConsoleUIConfigMapName is the name of the console UI nginx configmap ConsoleUIConfigMapName = "lightspeed-console-plugin" // OLSConsolePluginServiceHTTPSPort is the port number of the OLS console plugin service OLSConsolePluginServiceHTTPSPort = 9443 // AppServerConfigMapName is the name of the OLS application server config map AppServerConfigMapName = "olsconfig" // AppServerConfigMapKey is the key of config file in the OLS application server config map AppServerConfigMapKey = "olsconfig.yaml" // AppServerTLSSecretName is the name of the OLS application server TLS secret AppServerTLSSecretName = "lightspeed-tls" // #nosec G101 // ConditionTimeoutEnvVar is the environment variable containing the condition check timeout in seconds ConditionTimeoutEnvVar = "CONDITION_TIMEOUT" // TestCACert is for testing additional CA certificate TestCACert = `` /* 1513-byte string literal not displayed */ // OLSAppCertsMountRoot is the directory hosting the cert files in the container OLSAppCertsMountRoot = "/etc/certs" // AdditionalCAVolumeName is the name of the additional CA volume in the app server container AdditionalCAVolumeName = "additional-ca" // AppAdditionalCACertDir is the directory for storing additional CA certificates in the app server container under OLSAppCertsMountRoot AppAdditionalCACertDir = "ols-additional-ca" // AdditionalCAHashKey is the key of the hash value of the additional CA certificates AdditionalCAHashKey = "hash/additionalca" // CertBundleVolumeName is the name of the volume for the certificate bundle CertBundleVolumeName = "cert-bundle" // CertBundleDir is the path of the volume for the certificate bundle CertBundleDir = "cert-bundle" )
const MaxLength = 1000
MaxLength is the maximum string length returned by ClampMax().
Variables ¶
This section is empty.
Functions ¶
func GetFirstValueFromPromQuery ¶
GetFirstValueFromPromQuery takes a query api response body and returns the value of the first timeseries. If body contains multiple timeseries GetFirstValueFromPromQuery errors.
func GetResultSizeFromPromQuery ¶
GetResultSizeFromPromQuery takes a query api response body and returns the size of the result vector.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func GetClient ¶
func GetClient(options *ClientOptions) (*Client, error)
func (*Client) CreateClusterRoleBinding ¶
func (*Client) CreateServiceAccount ¶
func (*Client) ForwardPort ¶
func (*Client) GetServiceAccountToken ¶
func (*Client) List ¶
func (c *Client) List(o client.ObjectList, opts ...client.ListOption) (err error)
func (*Client) WaitForConfigMapContainString ¶
func (*Client) WaitForDeploymentCondition ¶
func (c *Client) WaitForDeploymentCondition(dep *appsv1.Deployment, condition func(*appsv1.Deployment) (bool, error)) error
func (*Client) WaitForDeploymentRollout ¶
func (c *Client) WaitForDeploymentRollout(dep *appsv1.Deployment) error
func (*Client) WaitForObjectCreated ¶
func (*Client) WaitForSecretCreated ¶
type ClientOptions ¶
type ClientOptions struct {
// contains filtered or unexported fields
}
type HTTPSClient ¶
type HTTPSClient struct {
// contains filtered or unexported fields
}
func NewHTTPSClient ¶
func NewHTTPSClient(host, serverName string, caCertificate, clientCert, clientKey []byte) *HTTPSClient
type HeaderInjector ¶
HeaderInjector injects a fixed HTTP header into the inbound request.
func (*HeaderInjector) WrapTransport ¶
func (h *HeaderInjector) WrapTransport(rt http.RoundTripper) http.RoundTripper
WrapTransport implements the WrapTransporter interface.
type PrometheusClient ¶
type PrometheusClient struct {
// contains filtered or unexported fields
}
PrometheusClient provides access to the Prometheus, Thanos & Alertmanager API.
func NewPrometheusClient ¶
func NewPrometheusClient(host, token string, wts ...WrapTransporter) *PrometheusClient
NewPrometheusClient creates and returns a new PrometheusClient.
func NewPrometheusClientFromRoute ¶
func NewPrometheusClientFromRoute( ctx context.Context, routeClient routev1.RouteV1Interface, namespace, name string, token string, ) (*PrometheusClient, error)
NewPrometheusClientFromRoute creates and returns a new PrometheusClient from the given OpenShift route.
func (*PrometheusClient) Do ¶
Do sends an HTTP request to the remote endpoint and returns the response.
func (*PrometheusClient) PrometheusLabel ¶
func (c *PrometheusClient) PrometheusLabel(label string) ([]byte, error)
PrometheusLabel runs an HTTP GET request against the Prometheus label API and returns the response body.
func (*PrometheusClient) PrometheusQuery ¶
func (c *PrometheusClient) PrometheusQuery(query string) ([]byte, error)
PrometheusQuery runs an HTTP GET request against the Prometheus query API and returns the response body.
func (*PrometheusClient) PrometheusQueryWithStatus ¶
func (c *PrometheusClient) PrometheusQueryWithStatus(query string, status int) ([]byte, error)
func (*PrometheusClient) PrometheusTargets ¶
func (c *PrometheusClient) PrometheusTargets() ([]byte, error)
PrometheusTargets runs an HTTP GET request against the Prometheus targets API and returns the response body.
func (*PrometheusClient) WaitForQueryReturn ¶
func (c *PrometheusClient) WaitForQueryReturn(query string, timeout time.Duration, validate func(float64) error) error
WaitForQueryReturn waits for a given PromQL query for a given time interval and validates the **first and only** result with the given validate function.
func (*PrometheusClient) WaitForQueryReturnEmpty ¶
func (c *PrometheusClient) WaitForQueryReturnEmpty(query string, timeout time.Duration) error
WaitForQueryReturnEmpty waits for a given PromQL query return an empty response for a given time interval
func (*PrometheusClient) WaitForQueryReturnGreaterEqualOne ¶
func (c *PrometheusClient) WaitForQueryReturnGreaterEqualOne(query string, timeout time.Duration) error
WaitForQueryReturnGreaterEqualOne see WaitForQueryReturn.
func (*PrometheusClient) WaitForQueryReturnOne ¶
func (c *PrometheusClient) WaitForQueryReturnOne(query string, timeout time.Duration) error
WaitForQueryReturnOne see WaitForQueryReturn.
type QueryParameterInjector ¶
QueryParameterInjector injects a fixed query parameter into the inbound request. It is typically used when querying kube-rbac-proxy.
func (*QueryParameterInjector) WrapTransport ¶
func (qp *QueryParameterInjector) WrapTransport(rt http.RoundTripper) http.RoundTripper
WrapTransport implements the WrapTransporter interface.
type WrapTransporter ¶
type WrapTransporter interface {
WrapTransport(rt http.RoundTripper) http.RoundTripper
}
WrapTransporter wraps an http.RoundTripper with another.