github.com/kyma-incubator/compass/components/director@v0.0.0-20230623144113-d764f56ff805/pkg/formationconstraint/join_point_details.go (about) 1 package formationconstraint 2 3 import ( 4 "github.com/kyma-incubator/compass/components/director/internal/model" 5 "github.com/kyma-incubator/compass/components/director/pkg/webhook" 6 ) 7 8 // MatchingDetails contains information used to match the reached join point with the applicable constraints 9 type MatchingDetails struct { 10 ResourceType model.ResourceType 11 ResourceSubtype string 12 } 13 14 // JoinPointDetails provides an interface for join point details 15 type JoinPointDetails interface { 16 GetMatchingDetails() MatchingDetails 17 } 18 19 // CRUDFormationOperationDetails contains details applicable to createFormation and deleteFormation join points 20 type CRUDFormationOperationDetails struct { 21 FormationType string 22 FormationTemplateID string 23 FormationName string 24 TenantID string 25 } 26 27 // GetMatchingDetails returns matching details for CRUDFormationOperationDetails 28 func (d *CRUDFormationOperationDetails) GetMatchingDetails() MatchingDetails { 29 return MatchingDetails{ 30 ResourceType: model.FormationResourceType, 31 ResourceSubtype: d.FormationType, 32 } 33 } 34 35 // AssignFormationOperationDetails contains details applicable to assignFormation join point 36 type AssignFormationOperationDetails struct { 37 ResourceType model.ResourceType 38 ResourceSubtype string 39 ResourceID string 40 FormationType string 41 FormationTemplateID string 42 FormationID string 43 FormationName string 44 TenantID string 45 } 46 47 // GetMatchingDetails returns matching details for AssignFormationOperationDetails 48 func (d *AssignFormationOperationDetails) GetMatchingDetails() MatchingDetails { 49 return MatchingDetails{ 50 ResourceType: d.ResourceType, 51 ResourceSubtype: d.ResourceSubtype, 52 } 53 } 54 55 // UnassignFormationOperationDetails contains details applicable to unassignFormation join point 56 type UnassignFormationOperationDetails struct { 57 ResourceType model.ResourceType 58 ResourceSubtype string 59 ResourceID string 60 FormationType string 61 FormationTemplateID string 62 FormationID string 63 TenantID string 64 } 65 66 // GetMatchingDetails returns matching details for UnassignFormationOperationDetails 67 func (d *UnassignFormationOperationDetails) GetMatchingDetails() MatchingDetails { 68 return MatchingDetails{ 69 ResourceType: d.ResourceType, 70 ResourceSubtype: d.ResourceSubtype, 71 } 72 } 73 74 // GenerateFormationAssignmentNotificationOperationDetails contains details applicable to generate formation assignment notifications join point 75 type GenerateFormationAssignmentNotificationOperationDetails struct { 76 Operation model.FormationOperation 77 FormationID string 78 FormationTemplateID string 79 ResourceType model.ResourceType 80 ResourceSubtype string 81 ResourceID string 82 CustomerTenantContext *webhook.CustomerTenantContext 83 84 // fields used when generating notifications from configuration changed webhooks 85 ApplicationTemplate *webhook.ApplicationTemplateWithLabels 86 Application *webhook.ApplicationWithLabels 87 Runtime *webhook.RuntimeWithLabels 88 RuntimeContext *webhook.RuntimeContextWithLabels 89 Assignment *webhook.FormationAssignment 90 ReverseAssignment *webhook.FormationAssignment 91 92 // fields used when generating notification from application tenant mapping webhooks 93 SourceApplicationTemplate *webhook.ApplicationTemplateWithLabels 94 // SourceApplication is the application that the notification is about 95 SourceApplication *webhook.ApplicationWithLabels 96 TargetApplicationTemplate *webhook.ApplicationTemplateWithLabels 97 // TargetApplication is the application that the notification is for (the one with the webhook / the one receiving the notification) 98 TargetApplication *webhook.ApplicationWithLabels 99 100 TenantID string 101 } 102 103 // GetMatchingDetails returns matching details for GenerateFormationAssignmentNotificationOperationDetails 104 func (d *GenerateFormationAssignmentNotificationOperationDetails) GetMatchingDetails() MatchingDetails { 105 return MatchingDetails{ 106 ResourceType: d.ResourceType, 107 ResourceSubtype: d.ResourceSubtype, 108 } 109 } 110 111 // GenerateFormationNotificationOperationDetails contains details applicable to generate formation notifications join point 112 type GenerateFormationNotificationOperationDetails struct { 113 Operation model.FormationOperation 114 FormationID string 115 FormationName string 116 FormationType string 117 FormationTemplateID string 118 TenantID string 119 CustomerTenantContext *webhook.CustomerTenantContext 120 } 121 122 // GetMatchingDetails returns matching details for GenerateFormationAssignmentNotificationOperationDetails 123 func (d *GenerateFormationNotificationOperationDetails) GetMatchingDetails() MatchingDetails { 124 return MatchingDetails{ 125 ResourceType: model.FormationResourceType, 126 ResourceSubtype: d.FormationType, 127 } 128 } 129 130 // SendNotificationOperationDetails contains details applicable to send notifications join point 131 type SendNotificationOperationDetails struct { 132 ResourceType model.ResourceType 133 ResourceSubtype string 134 Location JoinPointLocation 135 Operation model.FormationOperation 136 Webhook *model.Webhook 137 CorrelationID string 138 TemplateInput webhook.TemplateInput 139 FormationAssignment *model.FormationAssignment 140 ReverseFormationAssignment *model.FormationAssignment 141 Formation *model.Formation 142 } 143 144 // GetMatchingDetails returns matching details for SendNotificationOperationDetails 145 func (d *SendNotificationOperationDetails) GetMatchingDetails() MatchingDetails { 146 return MatchingDetails{ 147 ResourceType: d.ResourceType, 148 ResourceSubtype: d.ResourceSubtype, 149 } 150 } 151 152 // NotificationStatusReturnedOperationDetails contains details applicable to notification status returned join point 153 type NotificationStatusReturnedOperationDetails struct { 154 ResourceType model.ResourceType 155 ResourceSubtype string 156 Location JoinPointLocation 157 Operation model.FormationOperation 158 FormationAssignment *model.FormationAssignment 159 ReverseFormationAssignment *model.FormationAssignment 160 Formation *model.Formation 161 FormationTemplate *model.FormationTemplate 162 } 163 164 // GetMatchingDetails returns matching details for NotificationStatusReturnedOperationDetails 165 func (d *NotificationStatusReturnedOperationDetails) GetMatchingDetails() MatchingDetails { 166 return MatchingDetails{ 167 ResourceType: d.ResourceType, 168 ResourceSubtype: d.ResourceSubtype, 169 } 170 }