api

package
v0.0.0-...-e7c744b Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: Apache-2.0 Imports: 74 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddResourceGroups

func AddResourceGroups(c *gin.Context)

AddResourceGroups creates a new resource group

func AddSecretTag

func AddSecretTag(c *gin.Context)

AddSecretTag adds a tag to a given secret in Vault

func AddSecrets

func AddSecrets(c *gin.Context)

AddSecrets saves the given secret to vault

func CheckBucket

func CheckBucket(c *gin.Context)

CheckBucket checks if the given there is a bucket exists with the given name

func ContainsString

func ContainsString(sl []string, v string) bool

func CreateBucket

func CreateBucket(c *gin.Context)

CreateBucket creates an objectstore bucket (blob container in case of Azure) and also creates all requirements for them (eg.; ResourceGroup and StorageAccount in case of Azure). These information are also stored to a database.

func DeleteBucket

func DeleteBucket(c *gin.Context)

DeleteBucket deletes object storage buckets (object storage container in case of Azure) that can be accessed with the credentials from the given secret

func DeleteSecretTag

func DeleteSecretTag(c *gin.Context)

DeleteSecretTag removes a tag from a given secret in Vault

func DeleteSecrets

func DeleteSecrets(c *gin.Context)

DeleteSecrets delete a secret with the given secret id

func ErrorResponseFrom

func ErrorResponseFrom(err error) *pkgCommon.ErrorResponse

ErrorResponseFrom translates the given error into a components.ErrorResponse

func GetBucket

func GetBucket(c *gin.Context)

GetBucket handler for retrieving bucket details by name it retrieves all the managed buckets and filters them by name

func GetClusterConfig

func GetClusterConfig(c *gin.Context)

GetClusterConfig gets a cluster config

func GetClusterNodes

func GetClusterNodes(c *gin.Context)

GetClusterNodes Get node information

func GetDeploymentImages

func GetDeploymentImages(c *gin.Context)

GetDeploymentImages list all used images in deployment

func GetK8sConfig

func GetK8sConfig(c *gin.Context) ([]byte, bool)

GetK8sConfig returns the Kubernetes config

func GetPodDetails

func GetPodDetails(c *gin.Context)

GetPodDetails returns all pods with details

func GetReleaseScanLog

func GetReleaseScanLog(c *gin.Context) (map[string]bool, bool)

GetReleaseScanLog will return a ReleaseScanlog

func GetResourceGroups

func GetResourceGroups(c *gin.Context)

GetResourceGroups lists resource groups by secret

func GetSecret

func GetSecret(c *gin.Context)

GetSecret returns a secret by ID

func GetSecretTags

func GetSecretTags(c *gin.Context)

GetSecretTags returns tags of a secret by ID

func GetWhitelistSet

func GetWhitelistSet(c *gin.Context) (map[string]bool, bool)

GetWhitelistSet will return a WhitelistSet

func InstallSecretToCluster

func InstallSecretToCluster(c *gin.Context)

InstallSecretToCluster installs a particular secret to a cluster's namespace.

func InstallSecretsToCluster

func InstallSecretsToCluster(c *gin.Context)

InstallSecretsToCluster add all secrets from a repo to a cluster's namespace combined into one global secret named as the repo

func ListAllBuckets

func ListAllBuckets(c *gin.Context)

ListAllBuckets handles bucket list requests. The handler method directs the flow to the appropriate retrieval strategy based on the request header details

func ListBuckets

func ListBuckets(c *gin.Context)

ListBuckets returns the list of object storage buckets (object storage container in case of Azure) that can be accessed with the credentials from the given secret.

func ListClusterSecrets

func ListClusterSecrets(c *gin.Context)

ListClusterSecrets returns

func ListHelmReleases

func ListHelmReleases(c *gin.Context, releases []intlHelm.Release, releaseMap map[string]bool) []pkgHelm.ListDeploymentResponse

ListHelmReleases list helm releases

func ListImages

func ListImages(c *gin.Context)

ListImages list all used images in cluster

func ListManagedBuckets

func ListManagedBuckets(c *gin.Context)

ListManagedBuckets lists managed buckets for the user when no secret is provided

func ListSecrets

func ListSecrets(c *gin.Context)

ListSecrets returns the user all secrets, if the secret type or tag is filled then a filtered response is returned

func MergeSecretInCluster

func MergeSecretInCluster(c *gin.Context)

MergeSecretInCluster installs a particular secret to a cluster's namespace.

func MetaHandler

func MetaHandler(router *gin.Engine, subpath string) gin.HandlerFunc

MetaHandler lists routes with their available methods

func NewImageDeploymentsHandler

func NewImageDeploymentsHandler(releaseLister ReleaseLister, clusterService ClusterService, logger internalCommon.Logger) imageDeploymentsHandler

func OrganizationMiddleware

func OrganizationMiddleware(c *gin.Context)

OrganizationMiddleware parses the organization id from the request, queries it from the database and saves it to the current context.

func UpdateSecrets

func UpdateSecrets(c *gin.Context)

UpdateSecrets updates the given secret in Vault

func ValidateSecret

func ValidateSecret(c *gin.Context)

ValidateSecret validates the given secret

Types

type AnchoreProxy

type AnchoreProxy struct {
	// contains filtered or unexported fields
}

func NewAnchoreProxy

func NewAnchoreProxy(
	basePath string,
	configProvider anchore.ConfigProvider,

	errorHandler common.ErrorHandler,
	logger common.Logger,
) AnchoreProxy

func (AnchoreProxy) Proxy

func (ap AnchoreProxy) Proxy() gin.HandlerFunc

type BucketNotFoundError

type BucketNotFoundError struct {
	// contains filtered or unexported fields
}

SecretNotFoundError signals that a given bucket was not found

func (BucketNotFoundError) Error

func (err BucketNotFoundError) Error() string

Error returns error message as string

func (BucketNotFoundError) NotFound

func (err BucketNotFoundError) NotFound() bool

NotFound signals a not found error

type BucketQueryData

type BucketQueryData struct {
	CloudType      []string
	Include        []string
	StorageAccount []string
	ResourceGroup  []string
}

BucketQueryData encapsulates query parameter data

type BucketResponseItem

type BucketResponseItem struct {
	Name       string                                `json:"name"  binding:"required"`
	Managed    bool                                  `json:"managed" binding:"required"`
	Location   string                                `json:"location,omitempty"`
	Cloud      string                                `json:"cloud,omitempty"`
	Notes      *string                               `json:"notes,omitempty"`
	SecretInfo *secretData                           `json:"secret"`
	Azure      *objectstore.BlobStoragePropsForAzure `json:"aks,omitempty"`
	Status     string                                `json:"status"`
	StatusMsg  string                                `json:"statusMessage"`
}

BucketResponseItem encapsulates bucket and secret details to be returned it's purpose is to properly format the response details - especially the secret details

type ClusterAPI

type ClusterAPI struct {
	// contains filtered or unexported fields
}

ClusterAPI implements the Cluster API actions.

func NewClusterAPI

func NewClusterAPI(
	clusterManager *cluster.Manager,
	clusterGetter common.ClusterGetter,
	workflowClient client.Client,
	logger logrus.FieldLogger,
	errorHandler emperror.Handler,
	externalBaseURL string,
	externalBaseURLInsecure bool,
	clusterCreators ClusterCreators,
	clusterUpdaters ClusterUpdaters,
	clientFactory common.DynamicClientFactory,
	helmService cluster.HelmService,
	authConfig auth.Config,
	distributionConfig cmd.DistributionConfig,
	clientSecretGetter clusterAuth.ClusterClientSecretGetter,
) *ClusterAPI

NewClusterAPI returns a new ClusterAPI instance.

func (*ClusterAPI) ClusterCheck

func (a *ClusterAPI) ClusterCheck(c *gin.Context)

ClusterCheck checks the cluster ready

func (*ClusterAPI) CreateCluster

func (a *ClusterAPI) CreateCluster(c *gin.Context)

CreateCluster creates a K8S cluster in the cloud.

func (*ClusterAPI) GetBootstrapInfo

func (a *ClusterAPI) GetBootstrapInfo(c *gin.Context)

GetBootstrapInfo

func (*ClusterAPI) GetCluster

func (a *ClusterAPI) GetCluster(c *gin.Context)

GetCluster fetches a K8S cluster in the cloud

func (*ClusterAPI) GetClusters

func (a *ClusterAPI) GetClusters(c *gin.Context)

GetClusters fetches all the K8S clusters from the cloud.

func (*ClusterAPI) ProxyToCluster

func (a *ClusterAPI) ProxyToCluster(c *gin.Context)

ProxyToCluster sets up a proxy and forwards all requests to the cluster's API server.

func (*ClusterAPI) ReRunPostHooks

func (a *ClusterAPI) ReRunPostHooks(c *gin.Context)

ReRunPostHooks reruns cluster posthooks.

func (*ClusterAPI) UpdateCluster

func (a *ClusterAPI) UpdateCluster(c *gin.Context)

UpdateCluster updates a K8S cluster in the cloud (e.g. autoscale)

func (*ClusterAPI) UpdateNodePools

func (a *ClusterAPI) UpdateNodePools(c *gin.Context)

UpdateNodePools updates node pools

type ClusterAuthAPI

type ClusterAuthAPI struct {
	// contains filtered or unexported fields
}

func NewClusterAuthAPI

func NewClusterAuthAPI(
	clusterGetter common.ClusterGetter,
	clusterAuthService auth.ClusterAuthService,
	tokenSigningKey string,
	issuerURL string,
	insecureSkipVerify bool,
	redirectURI string,
) (*ClusterAuthAPI, error)

func (*ClusterAuthAPI) RegisterRoutes

func (api *ClusterAuthAPI) RegisterRoutes(clusterRouter gin.IRouter, authRouter gin.IRouter)

type ClusterCreators

type ClusterCreators struct {
	PKEOnAzure   azureDriver.ClusterCreator
	EKSAmazon    eksdriver.EksClusterCreator
	PKEOnVsphere vsphereDriver.VspherePKEClusterCreator
}

type ClusterDeleters

type ClusterDeleters struct {
	PKEOnAzure azureDriver.ClusterDeleter
	EKSAmazon  eksdriver.EKSClusterDeleter
}

type ClusterService

type ClusterService interface {
	// Retrieves the kuebernetes configuration as a slice of bytes
	GetKubeConfig(ctx context.Context, clusterID uint) ([]byte, error)
}

Cluster collects operations to extract cluster related information

type ClusterUpdaters

type ClusterUpdaters struct {
	PKEOnAzure   azureDriver.ClusterUpdater
	EKSAmazon    eksdriver.EksClusterUpdater
	PKEOnVsphere vsphereDriver.ClusterUpdater
}

type CreateAmazonObjectStoreBucketProperties

type CreateAmazonObjectStoreBucketProperties struct {
	Location string `json:"location" binding:"required"`
}

CreateAmazonObjectStoreBucketProperties describes the properties of S3 bucket creation request

type CreateAzureObjectStoreBucketProperties

type CreateAzureObjectStoreBucketProperties struct {
	Location       string `json:"location" binding:"required"`
	StorageAccount string `json:"storageAccount"`
	ResourceGroup  string `json:"resourceGroup"`
}

CreateAzureObjectStoreBucketProperties describes an Azure ObjectStore Container Creation request

type CreateBucketRequest

type CreateBucketRequest struct {
	SecretId   string `json:"secretId"`
	SecretName string `json:"secretName"`
	Name       string `json:"name" binding:"required"`
	Properties struct {
		Amazon *CreateAmazonObjectStoreBucketProperties `json:"amazon,omitempty"`
		Azure  *CreateAzureObjectStoreBucketProperties  `json:"azure,omitempty"`
		Google *CreateGoogleObjectStoreBucketProperties `json:"google,omitempty"`
	} `json:"properties" binding:"required"`
}

CreateBucketRequest to create bucket

type CreateBucketResponse

type CreateBucketResponse struct {
	BucketName string `json:"name"`
	CloudType  string `json:"cloud"`
}

CreateBucketResponse describes a storage bucket creation response

type CreateGoogleObjectStoreBucketProperties

type CreateGoogleObjectStoreBucketProperties struct {
	Location string `json:"location,required"`
}

CreateGoogleObjectStoreBucketProperties describes Google Object Store Bucket creation request

type CreateResourceGroupRequest

type CreateResourceGroupRequest struct {
	Name     string `json:"name" binding:"required"`
	Location string `json:"location" binding:"required"`
	SecretId string `json:"secretId" binding:"required"`
}

CreateResourceGroupRequest describes the resource group create request

type CreateResourceGroupResponse

type CreateResourceGroupResponse struct {
	Name string `json:"name" binding:"required"`
}

CreateResourceGroupResponse describes the resource group create response

type EndpointLister

type EndpointLister struct {
	// contains filtered or unexported fields
}

func MakeEndpointLister

func MakeEndpointLister(clusterService ClusterService, releaseChecker ReleaseChecker, logger common.Logger) EndpointLister

func (EndpointLister) ListEndpoints

func (el EndpointLister) ListEndpoints(c *gin.Context)

ListEndpoints lists service public endpoints

type GetClusterNodePool

type GetClusterNodePool struct {
	Autoscaling     bool                           `json:"autoscaling"`
	Count           int                            `json:"count,omitempty"`
	InstanceType    string                         `json:"instanceType,omitempty"`
	SpotPrice       string                         `json:"spotPrice,omitempty"`
	Preemptible     bool                           `json:"preemptible,omitempty"`
	MinCount        int                            `json:"minCount,omitempty"`
	MaxCount        int                            `json:"maxCount,omitempty"`
	Image           string                         `json:"image,omitempty"`
	Version         string                         `json:"version,omitempty"`
	ResourceSummary map[string]NodeResourceSummary `json:"resourceSummary,omitempty"`
	Labels          map[string]string              `json:"labels,omitempty"`
	Vcpu            int                            `json:"vcpu,omitempty"`
	Ram             int                            `json:"ram,omitempty"`
	Template        string                         `json:"template,omitempty"`

	CreatedAt   time.Time `json:"createdAt,omitempty"`
	CreatorName string    `json:"creatorName,omitempty"`
	CreatorID   uint      `json:"creatorId,omitempty"`
}

GetClusterNodePool describes a cluster's node pool.

type GetClusterResponse

type GetClusterResponse struct {
	ID            uint   `json:"id"`
	Status        string `json:"status"`
	StatusMessage string `json:"statusMessage,omitempty"`
	Name          string `json:"name"`

	// If region not available fall back to Location
	Region       string `json:"region,omitempty"`
	Location     string `json:"location"`
	Cloud        string `json:"cloud"`
	Distribution string `json:"distribution"`
	Spot         bool   `json:"spot,omitempty"`
	OIDC         OIDC   `json:"oidc"`

	Logging      bool `json:"logging"`
	Monitoring   bool `json:"monitoring"`
	SecurityScan bool `json:"securityscan"`

	// TODO: keep one of the following?
	Version       string `json:"version,omitempty"`
	MasterVersion string `json:"masterVersion,omitempty"`

	SecretID   string `json:"secretId"`
	SecretName string `json:"secretName"`

	Endpoint     string                        `json:"endpoint,omitempty"`
	NodePools    map[string]GetClusterNodePool `json:"nodePools,omitempty"`
	TotalSummary *ResourceSummary              `json:"totalSummary,omitempty"`

	CreatedAt   time.Time `json:"createdAt,omitempty"`
	CreatorName string    `json:"creatorName,omitempty"`
	CreatorID   uint      `json:"creatorId,omitempty"`
}

GetClusterResponse contains the details of a cluster.

type InstallSecretRequest

type InstallSecretRequest struct {
	SourceSecretName string                                  `json:"sourceSecretName,omitempty"`
	Namespace        string                                  `json:"namespace"`
	Spec             map[string]InstallSecretRequestSpecItem `json:"spec,omitempty"`
}

Models copied from generated client package. TODO: import these from a generated server model package

type InstallSecretRequestSpecItem

type InstallSecretRequestSpecItem struct {
	Source    string            `json:"source,omitempty"`
	SourceMap map[string]string `json:"sourceMap,omitempty"`
	Value     string            `json:"value,omitempty"`
}

type InstallSecretResponse

type InstallSecretResponse struct {
	Name string `json:"name"`
}

type InstallSecretsToClusterRequest

type InstallSecretsToClusterRequest struct {
	Namespace string                  `json:"namespace" binding:"required"`
	Query     secret.ListSecretsQuery `json:"query" binding:"required"`
}

InstallSecretsToClusterRequest describes an InstallSecretToCluster request

type LabelValidator

type LabelValidator interface {
	// ValidateKey validates a label key.
	ValidateKey(key string) error

	// ValidateValue validates a label value.
	ValidateValue(value string) error
}

LabelValidator validates Kubernetes object labels.

type NetworkAPI

type NetworkAPI struct {
	// contains filtered or unexported fields
}

NetworkAPI implements network functions

func NewNetworkAPI

func NewNetworkAPI(logger logrus.FieldLogger) *NetworkAPI

NewNetworkAPI returns a new NetworkAPI instance

func (*NetworkAPI) ListRouteTables

func (a *NetworkAPI) ListRouteTables(ctx *gin.Context)

ListRouteTables lists all route tables of the specified VPC network

func (*NetworkAPI) ListVPCNetworks

func (a *NetworkAPI) ListVPCNetworks(ctx *gin.Context)

ListVPCNetworks lists all VPC networks of the specified organization

func (*NetworkAPI) ListVPCSubnets

func (a *NetworkAPI) ListVPCSubnets(ctx *gin.Context)

ListVPCSubnets lists all subnetworks of the specified VPC network

type NetworkInfo

type NetworkInfo struct {
	CIDRs []string `json:"cidrs" binding:"required"`
	ID    string   `json:"id" binding:"required"`
	Name  string   `json:"name,omitempty"`
}

NetworkInfo encapsulates VPC network information to be returned

type NodeResourceSummary

type NodeResourceSummary struct {
	ResourceSummary

	Status string `json:"status,omitempty"`
}

type NodepoolManagerAPI

type NodepoolManagerAPI struct {
	// contains filtered or unexported fields
}

NodePoolManagerAPI implements the Node pool Label Management API actions.

func NewNodepoolManagerAPI

func NewNodepoolManagerAPI(
	clusterGetter common.ClusterGetter,
	clientFactory common.DynamicClientFactory,
	labelValidator LabelValidator,
	logger logrus.FieldLogger,
	errorHandler emperror.Handler,
) *NodepoolManagerAPI

NewNodepoolManagerAPI returns a new NodepoolManagerAPI instance.

func (*NodepoolManagerAPI) GetNodepoolLabelSets

func (n *NodepoolManagerAPI) GetNodepoolLabelSets(c *gin.Context)

type OIDC

type OIDC struct {
	Enabled      bool   `json:"enabled"`
	IdpURL       string `json:"idpUrl,omitempty"`
	ClientID     string `json:"clientId,omitempty"`
	ClientSecret string `json:"clientSecret,omitempty"`
}

type OrganizationAPI

type OrganizationAPI struct {
	// contains filtered or unexported fields
}

OrganizationAPI implements organization functions.

func NewOrganizationAPI

func NewOrganizationAPI(organizationSyncer auth.OIDCOrganizationSyncer, refreshTokenStore auth.RefreshTokenStore, helmConfig helm.Config) *OrganizationAPI

NewOrganizationAPI returns a new OrganizationAPI instance.

func (*OrganizationAPI) DeleteOrganization

func (a *OrganizationAPI) DeleteOrganization(c *gin.Context)

DeleteOrganization deletes an organization by id.

func (*OrganizationAPI) GetOrganizations

func (a *OrganizationAPI) GetOrganizations(c *gin.Context)

GetOrganizations returns all organizations the user belongs to or a specific one from those by id.

func (*OrganizationAPI) SyncOrganizations

func (a *OrganizationAPI) SyncOrganizations(c *gin.Context)

SyncOrganizations synchronizes github organizations.

type ReleaseChecker

type ReleaseChecker interface {
	CheckRelease(ctx context.Context, organizationID uint, clusterID uint, releaseName string, options intlHelm.Options) (string, error)
}

type ReleaseLister

type ReleaseLister interface {
	// ListReleases lists helm releases for the given input parameters
	ListReleases(ctx context.Context, organizationID uint, clusterID uint, releaseFilter helm.ReleaseFilter, options helm.Options) ([]helm.Release, error)
}

ReleaseLister helm operation abstraction interface

type Resource

type Resource struct {
	Capacity    string `json:"capacity,omitempty"`
	Allocatable string `json:"allocatable,omitempty"`
	Limit       string `json:"limit,omitempty"`
	Request     string `json:"request,omitempty"`
}

Resource describes a resource summary with capacity/request/limit/allocatable

type ResourceSummary

type ResourceSummary struct {
	CPU    *Resource `json:"cpu,omitempty"`
	Memory *Resource `json:"memory,omitempty"`
}

ResourceSummary describes a node's resource summary with CPU and Memory capacity/request/limit/allocatable

type RouteTableInfo

type RouteTableInfo struct {
	ID   string `json:"id" binding:"required"`
	Name string `json:"name,omitempty"`
}

RouteTableInfo encapsulates VPC route table information to be returned

type ScanLogHandler

type ScanLogHandler interface {
	ListScanLogs(c *gin.Context)
	GetScanLogs(c *gin.Context)
}

type SecretNotFoundError

type SecretNotFoundError struct {
	// contains filtered or unexported fields
}

SecretNotFoundError signals that a given secret was not found

func (SecretNotFoundError) Error

func (err SecretNotFoundError) Error() string

Error returns error message as string

type SecurityHandler

type SecurityHandler interface {
	WhitelistHandler
	ScanLogHandler
}

SecurityHandler defines security related handler functions intended to be used for defining routes

func NewSecurityApiHandlers

func NewSecurityApiHandlers(
	clusterGetter apiCommon.ClusterGetter,
	errorHandler internalCommon.ErrorHandler,
	logger internalCommon.Logger,
) SecurityHandler

type SubnetInfo

type SubnetInfo struct {
	CIDRs    []string `json:"cidrs" binding:"required"`
	ID       string   `json:"id" binding:"required"`
	Location string   `json:"location,omitempty"`
	Name     string   `json:"name,omitempty"`
}

SubnetInfo encapsulates VPC subnetwork information to be returned

type UpdateClusterResponse

type UpdateClusterResponse struct {
	Status int `json:"status"`
}

UpdateClusterResponse describes Pipeline's UpdateCluster API response

type UserAPI

type UserAPI struct {
	// contains filtered or unexported fields
}

UserAPI implements user functions.

func NewUserAPI

func NewUserAPI(db *gorm.DB, log logrus.FieldLogger, errorHandler emperror.Handler) *UserAPI

NewUserAPI returns a new UserAPI instance.

func (*UserAPI) GetCurrentUser

func (a *UserAPI) GetCurrentUser(c *gin.Context)

GetCurrentUser responds with the authenticated user

func (*UserAPI) GetUsers

func (a *UserAPI) GetUsers(c *gin.Context)

GetUsers gets a user or lists all users from an organization depending on the presence of the id parameter.

type WhitelistHandler

type WhitelistHandler interface {
	GetWhiteLists(c *gin.Context)
	CreateWhiteList(c *gin.Context)
	DeleteWhiteList(c *gin.Context)
}

Jump to

Keyboard shortcuts

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