Documentation
¶
Index ¶
- Variables
- func BulkAssembly(req m.BulkCreateRequest, tenant *m.Tenant, user *m.User) (*m.BulkCreateOutput, error)
- func DeleteCascade(tenantId *int64, userId *int64, resourceType string, resourceId int64, ...) error
- func EmitAvailabilityStatusNotification(id *identity.Identity, emailNotificationInfo *m.EmailNotificationInfo, ...) error
- func FeatureEnabled(feature string) bool
- func ForwadableHeaders(c echo.Context) ([]kafka.Header, error)
- func RaiseEvent(eventType string, resource model.Event, headers []kafka.Header) error
- func RequestAvailabilityCheck(c echo.Context, source *m.Source, headers []kafka.Header)
- func SendBulkMessages(out *m.BulkCreateOutput, headers []kafka.Header, identity string)
- func SendSuperKeyCreateRequest(application *m.Application, headers []kafka.Header) error
- func SendSuperKeyDeleteRequest(application *m.Application, headers []kafka.Header) error
- func UpdateSourceFromApplicationAvailabilityStatus(application *m.Application, previousStatus string) error
- func ValidateApplicationAuthenticationCreateRequest(appAuth *m.ApplicationAuthenticationCreateRequest) error
- func ValidateApplicationCreateRequest(requestParams *dao.RequestParams, appReq *m.ApplicationCreateRequest) error
- func ValidateApplicationEditRequest(editReq *m.ApplicationEditRequest) error
- func ValidateAuthenticationCreationRequest(auth *model.AuthenticationCreateRequest) error
- func ValidateAuthenticationEditRequest(auth *model.AuthenticationEditRequest) error
- func ValidateEndpointCreateRequest(dao dao.EndpointDao, ecr *model.EndpointCreateRequest) error
- func ValidateEndpointEditRequest(dao dao.EndpointDao, sourceId int64, editRequest *model.EndpointEditRequest) error
- func ValidateRhcConnectionRequest(req *model.RhcConnectionCreateRequest) error
- func ValidateSecretCreationRequest(requestParams *dao.RequestParams, auth model.SecretCreateRequest) error
- func ValidateSourceCreationRequest(sourceDao dao.SourceDao, req *model.SourceCreateRequest) error
- func ValidateSourceEditRequest(dao dao.SourceDao, editRequest *model.SourceEditRequest) error
- type AvailabilityStatusNotifier
- type FeatureFlagListener
- func (l FeatureFlagListener) OnCount(_ string, _ bool)
- func (l FeatureFlagListener) OnError(err error)
- func (l FeatureFlagListener) OnReady()
- func (l FeatureFlagListener) OnRegistered(_ unleash.ClientData)
- func (l FeatureFlagListener) OnSent(_ unleash.MetricsData)
- func (l FeatureFlagListener) OnWarning(warning error)
- type Notifier
Constants ¶
This section is empty.
Variables ¶
var AppTypeDao = dao.GetApplicationTypeDao(nil)
by default we'll be using an empty instance of the appType dao - replacing it in tests.
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 FeatureEnabled ¶
func ForwadableHeaders ¶
ForwadableHeaders fetches the required identity headers from the request that are needed to forward along:
- x-rh-identity -- a generated one if it wasn't passed along (e.g. psk)
- x-rh-sources-account-number -- always passed if present, and used for generation.
- x-rh-sources-org-id -- always passed if present, and used for generation.
func RaiseEvent ¶
RaiseEvent raises an event with the provided resource.
func RequestAvailabilityCheck ¶
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)
Source Files
¶
- application_authentication_validation.go
- application_validation.go
- authentication_validation.go
- availability_check.go
- bulk_create.go
- endpoint_validation.go
- events.go
- feature_flags.go
- notifications.go
- rhc_connection_validation.go
- secret_validation.go
- source_validation.go
- subresource_destroyer.go
- superkey.go
- superkey_helpers.go
- update_resource.go