systemfetcher

package
v0.0.0-...-6d13c91 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LifecycleAttributeName is the lifecycle status attribute of the application in the external source response for applications retrieval.
	LifecycleAttributeName string = "lifecycleStatus"
	// LifecycleDeleted is the string matching the deleted lifecycle state of the application in the external source.
	LifecycleDeleted string = "DELETED"

	// ConcurrentDeleteOperationErrMsg is the error message returned by the Compass Director, when we try to delete an application, which is already undergoing a delete operation.
	ConcurrentDeleteOperationErrMsg = "Concurrent operation [reason=delete operation is in progress]"
)

Variables

View Source
var (
	// ApplicationTemplates contains available Application Templates, should only be used for the unmarshaling of system data
	// It represents a model.ApplicationTemplate with its labels in the form of map[string]*model.Label
	ApplicationTemplates map[TemplateMappingKey]TemplateMapping
	// ApplicationTemplateLabelFilter represent a label for the Application Templates which has a value that
	// should match to the SystemSourceKey's value of the fetched systems
	ApplicationTemplateLabelFilter string
	// SelectFilter represents the select filter that determines which properties of a system will be fetched
	SelectFilter []string
	// SystemSourceKey represents a key for filtering systems
	SystemSourceKey string
)

Functions

func NewJwtTokenClient

func NewJwtTokenClient(keyCache credloader.KeysCache, jwtSelfSignCertSecretName string, client *http.Client) *jwtTokenClient

NewJwtTokenClient creates a jwt token client

func NewOauthClient

func NewOauthClient(oauthCfg oauth.Config, client *http.Client) *oauthClient

NewOauthClient missing docs

func NewOauthMtlsClient

func NewOauthMtlsClient(oauthCfg oauth.Config, certCache auth.CertificateCache, client *http.Client) *oauthMtlsClient

NewOauthMtlsClient missing docs

func NewSystemFetcherAggregatorHTTPHandler

func NewSystemFetcherAggregatorHTTPHandler(opMgr OperationsManager, businessTenantMappingSvc BusinessTenantMappingService, transact persistence.Transactioner, onDemandChannel chan string, workers chan struct{}) *handler

NewSystemFetcherAggregatorHTTPHandler returns a new HTTP handler, responsible for handling HTTP requests

Types

type APIClient

type APIClient interface {
	Do(*http.Request, string) (*http.Response, error)
}

APIClient missing godoc

type APIConfig

type APIConfig struct {
	Endpoint        string        `envconfig:"APP_SYSTEM_INFORMATION_ENDPOINT"`
	FilterCriteria  string        `envconfig:"APP_SYSTEM_INFORMATION_FILTER_CRITERIA"`
	Timeout         time.Duration `envconfig:"APP_SYSTEM_INFORMATION_FETCH_TIMEOUT"`
	PageSize        uint64        `envconfig:"APP_SYSTEM_INFORMATION_PAGE_SIZE"`
	PagingSkipParam string        `envconfig:"APP_SYSTEM_INFORMATION_PAGE_SKIP_PARAM"`
	PagingSizeParam string        `envconfig:"APP_SYSTEM_INFORMATION_PAGE_SIZE_PARAM"`
	SystemSourceKey string        `envconfig:"APP_SYSTEM_INFORMATION_SOURCE_KEY"`
	SystemRPSLimit  uint64        `envconfig:"default=15,APP_SYSTEM_INFORMATION_RPS_LIMIT"`
}

APIConfig missing godoc

type AggregationResource

type AggregationResource struct {
	TenantIDs      []string `json:"tenantIDs"`
	SkipReschedule bool     `json:"skipReschedule"`
}

AggregationResource holds id of tenant for systems fetching

type Authenticator

type Authenticator interface {
	GetAuthorization(ctx context.Context) (string, error)
}

Authenticator missing godoc

type BusinessTenantMappingService

type BusinessTenantMappingService interface {
	List(ctx context.Context) ([]*model.BusinessTenantMapping, error)
	GetTenantByID(ctx context.Context, id string) (*model.BusinessTenantMapping, error)
	GetTenantByExternalID(ctx context.Context, id string) (*model.BusinessTenantMapping, error)
}

BusinessTenantMappingService responsible for the service-layer tenant operations

type Client

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

Client missing godoc

func NewClient

func NewClient(apiConfig APIConfig, client APIClient, tokenClient APIClient) *Client

NewClient missing godoc

func (*Client) FetchSystemsForTenant

func (c *Client) FetchSystemsForTenant(ctx context.Context, tenant *model.BusinessTenantMapping, systemSynchronizationTimestamps map[string]SystemSynchronizationTimestamp) ([]System, error)

FetchSystemsForTenant fetches systems from the service

type Config

type Config struct {
	DirectorGraphqlURL        string        `envconfig:"APP_DIRECTOR_GRAPHQL_URL"`
	DirectorRequestTimeout    time.Duration `envconfig:"default=30s,APP_DIRECTOR_REQUEST_TIMEOUT"`
	DirectorSkipSSLValidation bool          `envconfig:"default=false,APP_DIRECTOR_SKIP_SSL_VALIDATION"`

	EnableSystemDeletion   bool   `envconfig:"default=true,APP_ENABLE_SYSTEM_DELETION"`
	OperationalMode        string `envconfig:"APP_OPERATIONAL_MODE"`
	AsyncRequestProcessors int    `envconfig:"default=100,APP_ASYNC_REQUEST_PROCESSORS"`
	TemplatesFileLocation  string `envconfig:"optional,APP_TEMPLATES_FILE_LOCATION"`
	VerifyTenant           string `envconfig:"optional,APP_VERIFY_TENANT"`
}

Config holds the configuration available for the SystemFetcher.

type DataLoader

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

DataLoader loads and creates all the necessary data needed by system-fetcher

func NewDataLoader

func NewDataLoader(tx persistence.Transactioner, cfg Config, appTmplSvc appTmplService, intSysSvc intSysSvc, webhookSvc webhookService) *DataLoader

NewDataLoader creates new DataLoader

func (*DataLoader) LoadData

func (d *DataLoader) LoadData(ctx context.Context, readDir func(dirname string) ([]os.DirEntry, error), readFile func(filename string) ([]byte, error)) error

LoadData loads and creates all the necessary data needed by system-fetcher

type DirectorGraphClient

type DirectorGraphClient struct {
	*gcli.Client
	Authenticator Authenticator
}

DirectorGraphClient missing godoc

func (*DirectorGraphClient) DeleteSystemAsync

func (d *DirectorGraphClient) DeleteSystemAsync(ctx context.Context, id, tenantID string) error

DeleteSystemAsync missing godoc

type Expression

type Expression struct {
	Key       string
	Operation string
	Value     string
}

Expression represents the single check expression

type Filter

type Filter struct {
	Expressions []Expression
}

Filter is the set of single expressions which will be concatenated when building the query

type FilterBuilder

type FilterBuilder struct {
	Filters []Filter
}

FilterBuilder builds the filter query from given expressions

func (*FilterBuilder) NewExpression

func (b *FilterBuilder) NewExpression(key, operation, value string) Expression

NewExpression returns new filter expression based on the given arguments

type HeaderTransport

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

HeaderTransport missing godoc

func (*HeaderTransport) RoundTrip

func (ht *HeaderTransport) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip missing godoc

type OperationMaintainer

type OperationMaintainer interface {
	Maintain(ctx context.Context) error
}

OperationMaintainer is responsible for maintaining of different types of operations.

func NewOperationMaintainer

func NewOperationMaintainer(kind model.OperationType, transact persistence.Transactioner, opSvc OperationService, businessTenantMappingSvc BusinessTenantMappingService) OperationMaintainer

NewOperationMaintainer creates OperationMaintainer based on kind

type OperationService

type OperationService interface {
	CreateMultiple(ctx context.Context, in []*model.OperationInput) error
	DeleteMultiple(ctx context.Context, ids []string) error
	ListAllByType(ctx context.Context, opType model.OperationType) ([]*model.Operation, error)
}

OperationService is responsible for the service-layer Operation operations.

type OperationsManager

type OperationsManager interface {
	FindOperationByData(ctx context.Context, data interface{}) (*model.Operation, error)
	CreateOperation(ctx context.Context, in *model.OperationInput) (string, error)
	RescheduleOperation(ctx context.Context, operationID string) error
}

OperationsManager provides methods for operations management

type OperationsProcessor

type OperationsProcessor struct {
	SystemFetcherSvc SystemFetcherService
}

OperationsProcessor defines Open Resource Discovery operation processor

func (*OperationsProcessor) Process

func (p *OperationsProcessor) Process(ctx context.Context, operation *model.Operation) error

Process processes the given operation

type PlaceholderMapping

type PlaceholderMapping struct {
	PlaceholderName string `json:"placeholder_name"`
	SystemKey       string `json:"system_key"`
	Optional        bool   `json:"optional"`
}

PlaceholderMapping is the mapping we have between a placeholder key we use in templates, and input field from the external system provider.

type Renderer

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

Renderer ts the applicaiotn template renderer helper

func NewTemplateRenderer

func NewTemplateRenderer(appTemplateService applicationTemplateService, appConverter applicationConverter, appInputOverride string, mapping []PlaceholderMapping) (*Renderer, error)

NewTemplateRenderer returns a new application input renderer by a given application template.

func (*Renderer) ApplicationRegisterInputFromTemplate

func (r *Renderer) ApplicationRegisterInputFromTemplate(ctx context.Context, sc System) (*model.ApplicationRegisterInput, error)

ApplicationRegisterInputFromTemplate creates ApplicationRegisterInput from System

func (*Renderer) GenerateAppRegisterInput

func (r *Renderer) GenerateAppRegisterInput(ctx context.Context, sc System, appTemplate *model.ApplicationTemplate, overridePlaceholders bool) (*model.ApplicationRegisterInput, error)

GenerateAppRegisterInput creates a ApplicationRegisterInput based on an ApplicationTemplate

type System

type System struct {
	SystemPayload   map[string]interface{}
	TemplateID      string                           `json:"-"`
	StatusCondition model.ApplicationStatusCondition `json:"-"`
}

System missing godoc

func (*System) EnhanceWithTemplateID

func (s *System) EnhanceWithTemplateID() (System, error)

EnhanceWithTemplateID tries to find an Application Template ID for the system and attach it to the object.

func (*System) UnmarshalJSON

func (s *System) UnmarshalJSON(data []byte) error

UnmarshalJSON missing godoc

type SystemFetcher

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

SystemFetcher is responsible for synchronizing the existing applications in Compass and a pre-defined external source.

func NewSystemFetcher

func NewSystemFetcher(tx persistence.Transactioner, ts tenantService, ss systemsService, sSync SystemsSyncService, tr TemplateRenderer, sac systemsAPIClient, directorClient directorClient, config Config) *SystemFetcher

NewSystemFetcher returns a new SystemFetcher.

func (*SystemFetcher) ProcessTenant

func (s *SystemFetcher) ProcessTenant(ctx context.Context, tenantID string) error

ProcessTenant performs resync of systems for provided tenant

func (*SystemFetcher) SetTemplateRenderer

func (s *SystemFetcher) SetTemplateRenderer(templateRenderer TemplateRenderer)

SetTemplateRenderer replaces the current template renderer

func (*SystemFetcher) UpsertSystemsSyncTimestampsForTenant

func (s *SystemFetcher) UpsertSystemsSyncTimestampsForTenant(ctx context.Context, tenant string, timestamps map[string]SystemSynchronizationTimestamp) error

UpsertSystemsSyncTimestampsForTenant updates the synchronization timestamps of the systems for each tenant or creates new ones if they don't exist in the database

type SystemFetcherOperationData

type SystemFetcherOperationData struct {
	TenantID string `json:"tenantID"`
}

SystemFetcherOperationData represents system fetcher operation data.

func NewSystemFetcherOperationData

func NewSystemFetcherOperationData(tenantID string) *SystemFetcherOperationData

NewSystemFetcherOperationData creates new SystemFetcherOperationData.

func ParseSystemFetcherOperationData

func ParseSystemFetcherOperationData(data []byte) (*SystemFetcherOperationData, error)

ParseSystemFetcherOperationData creates new SystemFetcherOperationData from byte array.

func (*SystemFetcherOperationData) Equal

Equal returns true if current data content is the same as other's data content

func (*SystemFetcherOperationData) GetData

func (b *SystemFetcherOperationData) GetData() (string, error)

GetData builds system fetcher operation data

type SystemFetcherOperationMaintainer

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

SystemFetcherOperationMaintainer consists of various resource services responsible for operations creation.

func (*SystemFetcherOperationMaintainer) Maintain

Maintain is responsible to create all missing and remove all obsolete operations

type SystemFetcherService

type SystemFetcherService interface {
	ProcessTenant(ctx context.Context, tenantID string) error
	SetTemplateRenderer(templateRenderer TemplateRenderer)
}

SystemFetcherService responsible for the service-layer operations of system fetcher

type SystemSynchronizationTimestamp

type SystemSynchronizationTimestamp struct {
	ID                string
	LastSyncTimestamp time.Time
}

SystemSynchronizationTimestamp represents the last synchronization time of a system

type SystemsSyncService

type SystemsSyncService interface {
	ListByTenant(ctx context.Context, tenant string) ([]*model.SystemSynchronizationTimestamp, error)
	Upsert(ctx context.Context, in *model.SystemSynchronizationTimestamp) error
}

SystemsSyncService is the service for managing systems synchronization timestamps

type TemplateMapping

type TemplateMapping struct {
	AppTemplate *model.ApplicationTemplate
	Labels      map[string]*model.Label
	Renderer    TemplateRenderer
}

TemplateMapping holds data for Application Templates and their Labels

type TemplateMappingKey

type TemplateMappingKey struct {
	Label  string
	Region string
}

TemplateMappingKey is a mapping for regional Application Templates

type TemplateRenderer

type TemplateRenderer interface {
	GenerateAppRegisterInput(ctx context.Context, sc System, appTemplate *model.ApplicationTemplate, overridePlaceholders bool) (*model.ApplicationRegisterInput, error)
	ApplicationRegisterInputFromTemplate(ctx context.Context, sc System) (*model.ApplicationRegisterInput, error)
}

TemplateRenderer is a service for go templating on Application Input JSON

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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