services

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2025 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CodeProjectExists              = "PROJECT_EXISTS"
	CodeProjectNotFound            = "PROJECT_NOT_FOUND"
	CodeComponentExists            = "COMPONENT_EXISTS"
	CodeComponentNotFound          = "COMPONENT_NOT_FOUND"
	CodeComponentTypeExists        = "COMPONENT_TYPE_EXISTS"
	CodeComponentTypeNotFound      = "COMPONENT_TYPE_NOT_FOUND"
	CodeTraitExists                = "TRAIT_EXISTS"
	CodeTraitNotFound              = "TRAIT_NOT_FOUND"
	CodeOrganizationNotFound       = "ORGANIZATION_NOT_FOUND"
	CodeEnvironmentNotFound        = "ENVIRONMENT_NOT_FOUND"
	CodeEnvironmentExists          = "ENVIRONMENT_EXISTS"
	CodeDataPlaneNotFound          = "DATAPLANE_NOT_FOUND"
	CodeDataPlaneExists            = "DATAPLANE_EXISTS"
	CodeBindingNotFound            = "BINDING_NOT_FOUND"
	CodeDeploymentPipelineNotFound = "DEPLOYMENT_PIPELINE_NOT_FOUND"
	CodeInvalidPromotionPath       = "INVALID_PROMOTION_PATH"
	CodeWorkflowNotFound           = "WORKFLOW_NOT_FOUND"
	CodeInvalidInput               = "INVALID_INPUT"
	CodeInternalError              = "INTERNAL_ERROR"
)

Error codes for API responses

Variables

View Source
var (
	ErrProjectAlreadyExists       = errors.New("project already exists")
	ErrProjectNotFound            = errors.New("project not found")
	ErrComponentAlreadyExists     = errors.New("component already exists")
	ErrComponentNotFound          = errors.New("component not found")
	ErrComponentTypeAlreadyExists = errors.New("component type already exists")
	ErrComponentTypeNotFound      = errors.New("component type not found")
	ErrTraitAlreadyExists         = errors.New("trait already exists")
	ErrTraitNotFound              = errors.New("trait not found")
	ErrOrganizationNotFound       = errors.New("organization not found")
	ErrEnvironmentNotFound        = errors.New("environment not found")
	ErrEnvironmentAlreadyExists   = errors.New("environment already exists")
	ErrDataPlaneNotFound          = errors.New("dataplane not found")
	ErrDataPlaneAlreadyExists     = errors.New("dataplane already exists")
	ErrBindingNotFound            = errors.New("binding not found")
	ErrDeploymentPipelineNotFound = errors.New("deployment pipeline not found")
	ErrInvalidPromotionPath       = errors.New("invalid promotion path")
	ErrWorkflowNotFound           = errors.New("workflow not found")
)

Common service errors

Functions

func GetLatestWorkflowStatus added in v0.4.0

func GetLatestWorkflowStatus(workflowConditions []metav1.Condition) string

GetLatestWorkflowStatus determines the user-friendly status from workflow conditions

Types

type BuildPlaneService

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

BuildPlaneService handles build plane-related business logic

func NewBuildPlaneService

func NewBuildPlaneService(k8sClient client.Client, bpClientMgr *kubernetesClient.KubeMultiClientManager, logger *slog.Logger) *BuildPlaneService

NewBuildPlaneService creates a new build plane service

func (*BuildPlaneService) GetBuildPlane

func (s *BuildPlaneService) GetBuildPlane(ctx context.Context, orgName string) (*openchoreov1alpha1.BuildPlane, error)

GetBuildPlane retrieves the build plane for an organization

func (*BuildPlaneService) GetBuildPlaneClient

func (s *BuildPlaneService) GetBuildPlaneClient(ctx context.Context, orgName string) (client.Client, error)

GetBuildPlaneClient creates and returns a Kubernetes client for the build plane cluster

func (*BuildPlaneService) ListBuildPlanes

func (s *BuildPlaneService) ListBuildPlanes(ctx context.Context, orgName string) ([]models.BuildPlaneResponse, error)

ListBuildPlanes retrieves all build planes for an organization

type BuildService

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

BuildService handles build-related business logic

func NewBuildService

func NewBuildService(k8sClient client.Client, buildPlaneService *BuildPlaneService, bpClientMgr *kubernetesClient.KubeMultiClientManager, logger *slog.Logger) *BuildService

NewBuildService creates a new build service

func (*BuildService) ListBuildTemplates

func (s *BuildService) ListBuildTemplates(ctx context.Context, orgName string) ([]models.BuildTemplateResponse, error)

ListBuildTemplates retrieves cluster workflow templates (argo) available for an organization in the buildplane

func (*BuildService) ListBuilds

func (s *BuildService) ListBuilds(ctx context.Context, orgName, projectName, componentName string) ([]models.BuildResponse, error)

ListBuilds retrieves workflows for a component using spec.owner fields

func (*BuildService) TriggerBuild

func (s *BuildService) TriggerBuild(ctx context.Context, orgName, projectName, componentName, commit string) (*models.BuildResponse, error)

TriggerBuild creates a new workflow from a component's build configuration

type ComponentObserverResponse

type ComponentObserverResponse struct {
	ObserverURL      string                    `json:"observerUrl,omitempty"`
	ConnectionMethod *ObserverConnectionMethod `json:"connectionMethod,omitempty"`
	Message          string                    `json:"message,omitempty"`
}

ComponentObserverResponse represents the response for observer URL requests

type ComponentService

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

ComponentService handles component-related business logic

func NewComponentService

func NewComponentService(k8sClient client.Client, projectService *ProjectService, logger *slog.Logger) *ComponentService

NewComponentService creates a new component service

func (*ComponentService) CreateComponent

func (s *ComponentService) CreateComponent(ctx context.Context, orgName, projectName string, req *models.CreateComponentRequest) (*models.ComponentResponse, error)

CreateComponent creates a new component in the given project

func (*ComponentService) CreateComponentWorkload

func (s *ComponentService) CreateComponentWorkload(ctx context.Context, orgName, projectName, componentName string, workloadSpec *openchoreov1alpha1.WorkloadSpec) (*openchoreov1alpha1.WorkloadSpec, error)

CreateComponentWorkload creates or updates workload data for a specific component

func (*ComponentService) GetBuildObserverURL

func (s *ComponentService) GetBuildObserverURL(ctx context.Context, orgName, projectName, componentName string) (*ComponentObserverResponse, error)

GetBuildObserverURL retrieves the observer URL for component build logs

func (*ComponentService) GetComponent

func (s *ComponentService) GetComponent(ctx context.Context, orgName, projectName, componentName string, additionalResources []string) (*models.ComponentResponse, error)

GetComponent retrieves a specific component

func (*ComponentService) GetComponentBinding

func (s *ComponentService) GetComponentBinding(ctx context.Context, orgName, projectName, componentName, environment string) (*models.BindingResponse, error)

GetComponentBinding retrieves the binding for a component in a specific environment

func (*ComponentService) GetComponentBindings

func (s *ComponentService) GetComponentBindings(ctx context.Context, orgName, projectName, componentName string, environments []string) ([]*models.BindingResponse, error)

GetComponentBindings retrieves bindings for a component in multiple environments If environments is empty, it will get all environments from the project's deployment pipeline

func (*ComponentService) GetComponentObserverURL

func (s *ComponentService) GetComponentObserverURL(ctx context.Context, orgName, projectName, componentName, environmentName string) (*ComponentObserverResponse, error)

GetComponentObserverURL retrieves the observer URL for component runtime logs

func (*ComponentService) GetComponentWorkloads

func (s *ComponentService) GetComponentWorkloads(ctx context.Context, orgName, projectName, componentName string) (interface{}, error)

GetComponentWorkloads retrieves workload data for a specific component

func (*ComponentService) ListComponents

func (s *ComponentService) ListComponents(ctx context.Context, orgName, projectName string) ([]*models.ComponentResponse, error)

ListComponents lists all components in the given project

func (*ComponentService) PromoteComponent

PromoteComponent promotes a component from source environment to target environment

func (*ComponentService) UpdateComponentBinding

func (s *ComponentService) UpdateComponentBinding(ctx context.Context, orgName, projectName, componentName, bindingName string, req *models.UpdateBindingRequest) (*models.BindingResponse, error)

UpdateComponentBinding updates a component binding

type ComponentSpecFetcher

type ComponentSpecFetcher interface {
	FetchSpec(ctx context.Context, k8sClient client.Client, namespace, componentName string) (interface{}, error)
	GetTypeName() string
}

ComponentSpecFetcher interface for fetching component-specific specifications

type ComponentSpecFetcherRegistry

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

ComponentSpecFetcherRegistry manages all component spec fetchers

func NewComponentSpecFetcherRegistry

func NewComponentSpecFetcherRegistry() *ComponentSpecFetcherRegistry

NewComponentSpecFetcherRegistry creates a new registry with all fetchers

func (*ComponentSpecFetcherRegistry) GetFetcher

func (r *ComponentSpecFetcherRegistry) GetFetcher(typeName string) (ComponentSpecFetcher, bool)

GetFetcher retrieves a fetcher by type name

func (*ComponentSpecFetcherRegistry) Register

Register adds a fetcher to the registry

type ComponentTypeService added in v0.4.0

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

ComponentTypeService handles ComponentType-related business logic

func NewComponentTypeService added in v0.4.0

func NewComponentTypeService(k8sClient client.Client, logger *slog.Logger) *ComponentTypeService

NewComponentTypeService creates a new ComponentType service

func (*ComponentTypeService) GetComponentType added in v0.4.0

func (s *ComponentTypeService) GetComponentType(ctx context.Context, orgName, ctName string) (*models.ComponentTypeResponse, error)

GetComponentType retrieves a specific ComponentType

func (*ComponentTypeService) GetComponentTypeSchema added in v0.4.0

func (s *ComponentTypeService) GetComponentTypeSchema(ctx context.Context, orgName, ctName string) (*extv1.JSONSchemaProps, error)

GetComponentTypeSchema retrieves the JSON schema for a ComponentType

func (*ComponentTypeService) ListComponentTypes added in v0.4.0

func (s *ComponentTypeService) ListComponentTypes(ctx context.Context, orgName string) ([]*models.ComponentTypeResponse, error)

ListComponentTypes lists all ComponentTypes in the given organization

type DataPlaneService

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

DataPlaneService handles dataplane-related business logic

func NewDataPlaneService

func NewDataPlaneService(k8sClient client.Client, logger *slog.Logger) *DataPlaneService

NewDataPlaneService creates a new dataplane service

func (*DataPlaneService) CreateDataPlane

CreateDataPlane creates a new dataplane

func (*DataPlaneService) GetDataPlane

func (s *DataPlaneService) GetDataPlane(ctx context.Context, orgName, dpName string) (*models.DataPlaneResponse, error)

GetDataPlane retrieves a specific dataplane

func (*DataPlaneService) ListDataPlanes

func (s *DataPlaneService) ListDataPlanes(ctx context.Context, orgName string) ([]*models.DataPlaneResponse, error)

ListDataPlanes lists all dataplanes in the specified organization

type DeploymentPipelineService

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

DeploymentPipelineService handles deployment pipeline-related business logic

func NewDeploymentPipelineService

func NewDeploymentPipelineService(k8sClient client.Client, projectService *ProjectService, logger *slog.Logger) *DeploymentPipelineService

NewDeploymentPipelineService creates a new deployment pipeline service

func (*DeploymentPipelineService) GetProjectDeploymentPipeline

func (s *DeploymentPipelineService) GetProjectDeploymentPipeline(ctx context.Context, orgName, projectName string) (*models.DeploymentPipelineResponse, error)

GetProjectDeploymentPipeline retrieves the deployment pipeline for a given project

type EnvironmentService

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

EnvironmentService handles environment-related business logic

func NewEnvironmentService

func NewEnvironmentService(k8sClient client.Client, logger *slog.Logger) *EnvironmentService

NewEnvironmentService creates a new environment service

func (*EnvironmentService) CreateEnvironment

CreateEnvironment creates a new environment

func (*EnvironmentService) GetEnvironment

func (s *EnvironmentService) GetEnvironment(ctx context.Context, orgName, envName string) (*models.EnvironmentResponse, error)

GetEnvironment retrieves a specific environment

func (*EnvironmentService) ListEnvironments

func (s *EnvironmentService) ListEnvironments(ctx context.Context, orgName string) ([]*models.EnvironmentResponse, error)

ListEnvironments lists all environments in the specified organization

type ObserverConnectionMethod

type ObserverConnectionMethod struct {
	Type        string `json:"type,omitempty"`
	Username    string `json:"username,omitempty"`
	Password    string `json:"password,omitempty"`
	BearerToken string `json:"bearerToken,omitempty"`
}

ObserverConnectionMethod contains the access method for the observer

type OrganizationService

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

OrganizationService handles organization-related business logic

func NewOrganizationService

func NewOrganizationService(k8sClient client.Client, logger *slog.Logger) *OrganizationService

NewOrganizationService creates a new organization service

func (*OrganizationService) GetOrganization

func (s *OrganizationService) GetOrganization(ctx context.Context, orgName string) (*models.OrganizationResponse, error)

GetOrganization retrieves a specific organization

func (*OrganizationService) ListOrganizations

func (s *OrganizationService) ListOrganizations(ctx context.Context) ([]*models.OrganizationResponse, error)

ListOrganizations lists all organizations

type ProjectService

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

ProjectService handles project-related business logic

func NewProjectService

func NewProjectService(k8sClient client.Client, logger *slog.Logger) *ProjectService

NewProjectService creates a new project service

func (*ProjectService) CreateProject

func (s *ProjectService) CreateProject(ctx context.Context, orgName string, req *models.CreateProjectRequest) (*models.ProjectResponse, error)

CreateProject creates a new project in the given organization

func (*ProjectService) GetProject

func (s *ProjectService) GetProject(ctx context.Context, orgName, projectName string) (*models.ProjectResponse, error)

GetProject retrieves a specific project

func (*ProjectService) ListProjects

func (s *ProjectService) ListProjects(ctx context.Context, orgName string) ([]*models.ProjectResponse, error)

ListProjects lists all projects in the given organization

type PromoteComponentPayload

type PromoteComponentPayload struct {
	models.PromoteComponentRequest
	ComponentName string `json:"componentName"`
	ProjectName   string `json:"projectName"`
	OrgName       string `json:"orgName"`
}

type PropertyDescription added in v0.4.0

type PropertyDescription struct {
	Name        string `json:"name"`
	Type        string `json:"type"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required"`
}

PropertyDescription represents a single field/property in the schema

type SchemaExplanation added in v0.4.0

type SchemaExplanation struct {
	Group       string                `json:"group"`
	Kind        string                `json:"kind"`
	Version     string                `json:"version"`
	Field       string                `json:"field,omitempty"`
	Type        string                `json:"type"`
	Description string                `json:"description,omitempty"`
	Properties  []PropertyDescription `json:"properties,omitempty"`
	Required    []string              `json:"required,omitempty"`
}

SchemaExplanation represents the structured schema information

type SchemaService added in v0.4.0

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

SchemaService handles Kubernetes schema explanation operations

func NewSchemaService added in v0.4.0

func NewSchemaService(k8sClient client.Client, logger *slog.Logger) *SchemaService

NewSchemaService creates a new schema service

func (*SchemaService) ExplainSchema added in v0.4.0

func (s *SchemaService) ExplainSchema(ctx context.Context, kind, path string) (*SchemaExplanation, error)

ExplainSchema explains the schema of a Kubernetes resource kind

type ServiceSpecFetcher

type ServiceSpecFetcher struct{}

ServiceSpecFetcher fetches Service specifications

func (*ServiceSpecFetcher) FetchSpec

func (f *ServiceSpecFetcher) FetchSpec(ctx context.Context, k8sClient client.Client, namespace, componentName string) (interface{}, error)

func (*ServiceSpecFetcher) GetTypeName

func (f *ServiceSpecFetcher) GetTypeName() string

type Services

type Services struct {
	ProjectService            *ProjectService
	ComponentService          *ComponentService
	ComponentTypeService      *ComponentTypeService
	WorkflowService           *WorkflowService
	TraitService              *TraitService
	OrganizationService       *OrganizationService
	EnvironmentService        *EnvironmentService
	DataPlaneService          *DataPlaneService
	BuildService              *BuildService
	BuildPlaneService         *BuildPlaneService
	DeploymentPipelineService *DeploymentPipelineService
	SchemaService             *SchemaService
	// contains filtered or unexported fields
}

func NewServices

func NewServices(k8sClient client.Client, k8sBPClientMgr *kubernetesClient.KubeMultiClientManager, logger *slog.Logger) *Services

NewServices creates and initializes all services

func (*Services) GetKubernetesClient

func (s *Services) GetKubernetesClient() client.Client

GetKubernetesClient returns the Kubernetes client for direct API operations

type TraitService added in v0.4.0

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

TraitService handles Trait-related business logic

func NewTraitService added in v0.4.0

func NewTraitService(k8sClient client.Client, logger *slog.Logger) *TraitService

NewTraitService creates a new Trait service

func (*TraitService) GetTrait added in v0.4.0

func (s *TraitService) GetTrait(ctx context.Context, orgName, traitName string) (*models.TraitResponse, error)

GetTrait retrieves a specific Trait

func (*TraitService) GetTraitSchema added in v0.4.0

func (s *TraitService) GetTraitSchema(ctx context.Context, orgName, traitName string) (*extv1.JSONSchemaProps, error)

GetTraitSchema retrieves the JSON schema for an Trait

func (*TraitService) ListTraits added in v0.4.0

func (s *TraitService) ListTraits(ctx context.Context, orgName string) ([]*models.TraitResponse, error)

ListTraits lists all Traits in the given organization

type WebApplicationSpecFetcher

type WebApplicationSpecFetcher struct{}

WebApplicationSpecFetcher fetches WebApplication specifications

func (*WebApplicationSpecFetcher) FetchSpec

func (f *WebApplicationSpecFetcher) FetchSpec(ctx context.Context, k8sClient client.Client, namespace, componentName string) (interface{}, error)

func (*WebApplicationSpecFetcher) GetTypeName

func (f *WebApplicationSpecFetcher) GetTypeName() string

type WorkflowService added in v0.4.0

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

WorkflowService handles Workflow-related business logic

func NewWorkflowService added in v0.4.0

func NewWorkflowService(k8sClient client.Client, logger *slog.Logger) *WorkflowService

NewWorkflowService creates a new Workflow service

func (*WorkflowService) GetWorkflow added in v0.4.0

func (s *WorkflowService) GetWorkflow(ctx context.Context, orgName, wfName string) (*models.WorkflowResponse, error)

GetWorkflow retrieves a specific Workflow

func (*WorkflowService) GetWorkflowSchema added in v0.4.0

func (s *WorkflowService) GetWorkflowSchema(ctx context.Context, orgName, wfName string) (*extv1.JSONSchemaProps, error)

GetWorkflowSchema retrieves the JSON schema for a Workflow

func (*WorkflowService) ListWorkflows added in v0.4.0

func (s *WorkflowService) ListWorkflows(ctx context.Context, orgName string) ([]*models.WorkflowResponse, error)

ListWorkflows lists all Workflows in the given organization

type WorkloadSpecFetcher

type WorkloadSpecFetcher struct{}

func (*WorkloadSpecFetcher) FetchSpec

func (f *WorkloadSpecFetcher) FetchSpec(ctx context.Context, k8sClient client.Client, namespace, componentName string) (interface{}, error)

func (*WorkloadSpecFetcher) GetTypeName

func (f *WorkloadSpecFetcher) GetTypeName() string

Jump to

Keyboard shortcuts

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