common

package
v2.21.9 Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckClusterVersionSkew

func CheckClusterVersionSkew(ctx context.Context, userInfoGetter provider.UserInfoGetter, clusterProvider provider.ClusterProvider, cluster *kubermaticv1.Cluster, projectID string) ([]string, error)

CheckClusterVersionSkew returns a list of machines and/or machine deployments that are running kubelet at a version incompatible with the cluster's control plane.

func ConvertInternalEventToExternal

func ConvertInternalEventToExternal(event corev1.Event) apiv1.Event

ConvertInternalEventToExternal converts Kubernetes Events to Kubermatic ones (used in the API).

func ConvertInternalProjectToExternal

func ConvertInternalProjectToExternal(kubermaticProject *kubermaticv1.Project, projectOwners []apiv1.User, clustersNumber int) *apiv1.Project

func ConvertInternalSSHKeysToExternal

func ConvertInternalSSHKeysToExternal(internalKeys []*kubermaticv1.UserSSHKey) []*apiv1.SSHKey

func DecodeClusterID

func DecodeClusterID(c context.Context, r *http.Request) (string, error)

func DecodeDcReq

func DecodeDcReq(c context.Context, r *http.Request) (interface{}, error)

func DecodeEmptyReq added in v2.16.3

func DecodeEmptyReq(c context.Context, r *http.Request) (interface{}, error)

func DecodeGetClusterReq

func DecodeGetClusterReq(c context.Context, r *http.Request) (interface{}, error)

func DecodeGetProject

func DecodeGetProject(c context.Context, r *http.Request) (interface{}, error)

func DecodeNamespace added in v2.21.0

func DecodeNamespace(c context.Context, r *http.Request) (string, error)

DecodeNamespace decodes the namespace out of http.Request's path.

func DecodeProjectRequest

func DecodeProjectRequest(c context.Context, r *http.Request) (interface{}, error)

func DecodeSSHKeyID added in v2.16.3

func DecodeSSHKeyID(c context.Context, r *http.Request) (string, error)

func FilterEventsByType

func FilterEventsByType(events []apiv1.Event, eventType string) []apiv1.Event

FilterEventsByType filters Kubernetes Events based on their type. Empty type string will return all of them.

func ForwardPort

func ForwardPort(log *zap.SugaredLogger, forwarder *portforward.PortForwarder) error

func GetClusterClient

func GetClusterClient(ctx context.Context, userInfoGetter provider.UserInfoGetter, clusterProvider provider.ClusterProvider, cluster *kubermaticv1.Cluster, projectID string) (ctrlruntimeclient.Client, error)

func GetEvents

func GetEvents(ctx context.Context, client ctrlruntimeclient.Client, obj metav1.Object, objNamespace string) ([]apiv1.Event, error)

GetEvents returns events related to an object in a given namespace.

func GetOwnersForProject

func GetOwnersForProject(ctx context.Context, userInfo *provider.UserInfo, project *kubermaticv1.Project, memberProvider provider.ProjectMemberProvider, userProvider provider.UserProvider) ([]apiv1.User, error)

func GetPortForwarder

func GetPortForwarder(
	ctx context.Context,
	coreClient corev1interface.CoreV1Interface,
	cfg *rest.Config,
	namespace string,
	labelSelector string,
	containerPort int,
) (*portforward.PortForwarder, chan struct{}, error)

While it is tempting to write our own roundTripper to do all the reading/writing in memory instead of opening a TCP port it has some drawbacks:

func GetProject

func GetProject(ctx context.Context, userInfoGetter provider.UserInfoGetter, projectProvider provider.ProjectProvider, privilegedProjectProvider provider.PrivilegedProjectProvider, projectID string, options *provider.ProjectGetOptions) (*kubermaticv1.Project, error)

func GetReadyPod

func GetReadyPod(ctx context.Context, client corev1interface.PodInterface, labelSelector string) (*corev1.Pod, error)

GetReadyPod returns a pod matching provided label selector if it is posting ready status, error otherwise. Namespace can be ensured by creating proper PodInterface client.

func IsBringYourOwnProvider

func IsBringYourOwnProvider(spec kubermaticv1.CloudSpec) (bool, error)

IsBringYourOwnProvider determines whether the spec holds BringYourOwn provider.

func KubernetesErrorToHTTPError

func KubernetesErrorToHTTPError(err error) error

kubernetesErrorToHTTPError constructs HTTPError only if the given err is of type *StatusError. Otherwise unmodified err will be returned to the caller.

func WaitForPortForwarder

func WaitForPortForwarder(duration time.Duration, p *portforward.PortForwarder, errChan <-chan error) error

WaitForPortForwarder waits until started port forwarder is ready, or emits an error to provided errChan.

func WriteHTTPError

func WriteHTTPError(log *zap.SugaredLogger, w http.ResponseWriter, err error)

WriteHTTPError writes an http error out. If debug is enabled, it also gets logged.

Types

type CredentialsData

type CredentialsData struct {
	Ctx               context.Context
	KubermaticCluster *kubermaticv1.Cluster
	Client            ctrlruntimeclient.Client
}

func (CredentialsData) Cluster

func (d CredentialsData) Cluster() *kubermaticv1.Cluster

func (CredentialsData) GetGlobalSecretKeySelectorValue

func (d CredentialsData) GetGlobalSecretKeySelectorValue(configVar *providerconfig.GlobalSecretKeySelector, key string) (string, error)

type DCReq

type DCReq struct {
	ProjectReq
	// in: path
	// required: true
	DC string `json:"dc"`
}

DCReq represent a request for datacenter specific data in a given project.

func (DCReq) GetSeedCluster

func (req DCReq) GetSeedCluster() apiv1.SeedCluster

GetSeedCluster returns the SeedCluster object.

type GetClusterReq

type GetClusterReq struct {
	DCReq
	// in: path
	// required: true
	ClusterID string `json:"cluster_id"`
}

GetClusterReq defines HTTP request for deleteCluster and getClusterKubeconfig endpoints swagger:parameters getCluster getClusterKubeconfig getOidcClusterKubeconfig listAWSSizesNoCredentials getClusterHealth getClusterUpgrades getClusterMetrics getClusterNodeUpgrades listGCPZonesNoCredentials listGCPNetworksNoCredentials listAWSZonesNoCredentials listAWSSubnetsNoCredentials listAlibabaInstanceTypesNoCredentials listNamespace

type GetProjectRq

type GetProjectRq struct {
	ProjectReq
}

GetProjectRq defines HTTP request for getProject endpoint swagger:parameters getProject getUsersForProject listClustersForProject listServiceAccounts getProjectQuota listGroupProjectBinding

type OIDCConfiguration

type OIDCConfiguration struct {
	// URL holds OIDC Issuer URL address
	URL string
	// ClientID holds OIDC ClientID
	ClientID string
	// ClientSecret holds OIDC ClientSecret
	ClientSecret string
	// CookieHashKey is required, used to authenticate the cookie value using HMAC
	// It is recommended to use a key with 32 or 64 bytes.
	CookieHashKey string
	// CookieSecureMode if true then cookie received only with HTTPS otherwise with HTTP.
	CookieSecureMode bool
	// OfflineAccessAsScope if true then "offline_access" scope will be used
	// otherwise 'access_type=offline" query param will be passed
	OfflineAccessAsScope bool
}

OIDCConfiguration is a struct that holds OIDC provider configuration data, read from command line arguments.

type ProjectIDGetter

type ProjectIDGetter interface {
	GetProjectID() string
}

ProjectIDGetter knows how to get project ID from the request.

type ProjectReq

type ProjectReq struct {
	// in: path
	// required: true
	ProjectID string `json:"project_id"`
}

ProjectReq represents a request for project-specific data.

func (ProjectReq) GetProjectID

func (pr ProjectReq) GetProjectID() string

GetProjectID returns the ID of a requested project.

type ResourceMetricsInfo

type ResourceMetricsInfo struct {
	Name      string
	Metrics   corev1.ResourceList
	Available corev1.ResourceList
}

ResourceMetricsInfo is a struct that holds the node metrics.

type ServerMetrics

type ServerMetrics struct {
	HTTPRequestsTotal          *prometheus.CounterVec
	HTTPRequestsDuration       *prometheus.HistogramVec
	InitNodeDeploymentFailures *prometheus.CounterVec
}

ServerMetrics defines metrics used by the API.

type SupportManager added in v2.18.0

type SupportManager interface {
	GetIncompatibilities() []*version.ProviderIncompatibility
}

type UpdateManager

type UpdateManager interface {
	GetVersions() ([]*version.Version, error)
	GetVersionsForProvider(kubermaticv1.ProviderType, ...kubermaticv1.ConditionType) ([]*version.Version, error)
	GetDefault() (*version.Version, error)
	GetPossibleUpdates(from string, provider kubermaticv1.ProviderType, condition ...kubermaticv1.ConditionType) ([]*version.Version, error)
}

UpdateManager specifies a set of methods to handle cluster versions & updates.

type UserIDGetter

type UserIDGetter interface {
	GetUserID() string
}

UserIDGetter knows how to get user ID from the request.

Jump to

Keyboard shortcuts

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