service

package
v0.0.0-...-f47fe49 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

by default we'll be using an empty instance of the appType dao - replacing it in tests.

View Source
var Producer = func() events.Sender { return events.EventStreamProducer{Sender: &events.EventStreamSender{}} }

Producer instance used to send messages - default just an empty instance of the struct.

Functions

func BulkAssembly

func BulkAssembly(req m.BulkCreateRequest, tenant *m.Tenant, user *m.User) (*m.BulkCreateOutput, error)

Oh boy. The big one.

So basically this function goes through a the parsed BulkCreateRequest model and creates the resources in this order:

1. Sources 2. Endpoints/Applications

It dynamically looks up both the SourceType as well as ApplicationType if given the *_type_name paremeters.

3. Saving the Authentications 4. Saving the ApplicationAuthentications if necessary

func DeleteCascade

func DeleteCascade(tenantId *int64, userId *int64, resourceType string, resourceId int64, headers []kafka.Header) error

DeleteCascade removes the resource type and all its dependants, raising an event for every deleted resource. Returns an error when the resources and its dependants could not be successfully removed.

- In the case of the resource being a "Source", it removes its applications, its endpoints and its Red Hat Connector connections. - In the other cases, it removes the resource itself.

In both cases the authentications are fetched for every single resource and sub resource, and they get deleted in batch.

In the case of not being able to delete authentications, we simply log the error and leave them dangling, since we might either have a database or Vault backing our authentications, and we might need manual action to remove the ones that were left undeleted. In the case of a database it is true that it could be wrapped in a transaction, but with Vault that is not possible. What if we start deleting authentications and then some of them error out? We would be able to recover the database data, but some of their authentications would be gone, therefore leaving the resource in an inconsistent state.

Plus, it's not the client's fault that we weren't able to delete the authentications, so by taking this approach the clients don't keep an "unremovable" resource because of some failure in deleting the authentications.

Finally, those authentications are safely encrypted so they can stay in their datastores until we manually remove them.

func EmitAvailabilityStatusNotification

func EmitAvailabilityStatusNotification(id *identity.Identity, emailNotificationInfo *m.EmailNotificationInfo, guidPrefix string) error

func FeatureEnabled

func FeatureEnabled(feature string) bool

func ForwadableHeaders

func ForwadableHeaders(c echo.Context) ([]kafka.Header, error)

ForwadableHeaders fetches the required identity headers from the request that are needed to forward along:

  1. x-rh-identity -- a generated one if it wasn't passed along (e.g. psk)
  2. x-rh-sources-account-number -- always passed if present, and used for generation.
  3. x-rh-sources-org-id -- always passed if present, and used for generation.

func RaiseEvent

func RaiseEvent(eventType string, resource model.Event, headers []kafka.Header) error

RaiseEvent raises an event with the provided resource.

func RequestAvailabilityCheck

func RequestAvailabilityCheck(c echo.Context, source *m.Source, headers []kafka.Header)

requests both types of availability checks for a source

func SendBulkMessages

func SendBulkMessages(out *m.BulkCreateOutput, headers []kafka.Header, identity string)

send all the messages on the event-stream for what we created. this involves doing some checks for superkey related things etc.

func SendSuperKeyCreateRequest

func SendSuperKeyCreateRequest(application *m.Application, headers []kafka.Header) error

func SendSuperKeyDeleteRequest

func SendSuperKeyDeleteRequest(application *m.Application, headers []kafka.Header) error

func UpdateSourceFromApplicationAvailabilityStatus

func UpdateSourceFromApplicationAvailabilityStatus(application *m.Application, previousStatus string) error

func ValidateApplicationAuthenticationCreateRequest

func ValidateApplicationAuthenticationCreateRequest(appAuth *m.ApplicationAuthenticationCreateRequest) error

func ValidateApplicationCreateRequest

func ValidateApplicationCreateRequest(requestParams *dao.RequestParams, appReq *m.ApplicationCreateRequest) error

Go through and validate the application create request.

Really not much here other than validating the application type is compatible with the specified source type.

func ValidateApplicationEditRequest

func ValidateApplicationEditRequest(editReq *m.ApplicationEditRequest) error

ValidateApplicationEditRequest validates that the edit request received for an application is valid.

func ValidateAuthenticationCreationRequest

func ValidateAuthenticationCreationRequest(auth *model.AuthenticationCreateRequest) error

func ValidateAuthenticationEditRequest

func ValidateAuthenticationEditRequest(auth *model.AuthenticationEditRequest) error

func ValidateEndpointCreateRequest

func ValidateEndpointCreateRequest(dao dao.EndpointDao, ecr *model.EndpointCreateRequest) error

func ValidateEndpointEditRequest

func ValidateEndpointEditRequest(dao dao.EndpointDao, sourceId int64, editRequest *model.EndpointEditRequest) error

func ValidateRhcConnectionRequest

func ValidateRhcConnectionRequest(req *model.RhcConnectionCreateRequest) error

ValidateRhcConnectionRequest validates that the incoming input is valid.

func ValidateSecretCreationRequest

func ValidateSecretCreationRequest(requestParams *dao.RequestParams, auth model.SecretCreateRequest) error

func ValidateSourceCreationRequest

func ValidateSourceCreationRequest(sourceDao dao.SourceDao, req *model.SourceCreateRequest) error

ValidateSourceCreationRequest validates that the required fields of the SourceCreateRequest request hold proper values. In the specific case of the UUID, if an empty or nil one is provided, a new random UUID is generated and appended to the request.

func ValidateSourceEditRequest

func ValidateSourceEditRequest(dao dao.SourceDao, editRequest *model.SourceEditRequest) error

Types

type AvailabilityStatusNotifier

type AvailabilityStatusNotifier struct {
}

func (*AvailabilityStatusNotifier) EmitAvailabilityStatusNotification

func (producer *AvailabilityStatusNotifier) EmitAvailabilityStatusNotification(id *identity.Identity, emailNotificationInfo *m.EmailNotificationInfo, sourceIdentification string) error

type FeatureFlagListener

type FeatureFlagListener struct{}

func (FeatureFlagListener) OnCount

func (l FeatureFlagListener) OnCount(_ string, _ bool)

func (FeatureFlagListener) OnError

func (l FeatureFlagListener) OnError(err error)

func (FeatureFlagListener) OnReady

func (l FeatureFlagListener) OnReady()

func (FeatureFlagListener) OnRegistered

func (l FeatureFlagListener) OnRegistered(_ unleash.ClientData)

func (FeatureFlagListener) OnSent

func (l FeatureFlagListener) OnSent(_ unleash.MetricsData)

func (FeatureFlagListener) OnWarning

func (l FeatureFlagListener) OnWarning(warning error)

type Notifier

type Notifier interface {
	EmitAvailabilityStatusNotification(xRhIdentity *identity.Identity, emailNotificationInfo *m.EmailNotificationInfo, guidPrefix string) error
}
var (
	NotificationProducer Notifier
)

Jump to

Keyboard shortcuts

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