Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions event-gateway/gateway-controller/cmd/controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ import (

eventgateway "github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/api/eventgateway"
eventgatewayconfig "github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/config"
"github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/controlplanehooks"
"github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/dbschema"
"github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/eventlistener"
"github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/handler"
"github.com/wso2/api-platform/event-gateway/gateway-controller/pkg/hubtopic"
Expand Down Expand Up @@ -201,6 +203,14 @@ func main() {
}
defer db.Close()

// websub_apis, webbroker_apis, and webhook_secrets are event-gateway-specific
// tables that core's own schema scripts do not define. Apply them against the
// same database connection core just opened.
if err := dbschema.Apply(context.Background(), db.GetDB(), cfg.Controller.Storage.Type); err != nil {
log.Error("Failed to initialize event-gateway database schema", slog.Any("error", err))
os.Exit(1)
}

var eventHubInstance eventhub.EventHub
var eventHubStorage storage.Storage
ehBackendCfg := toBackendConfig(cfg)
Expand Down Expand Up @@ -471,6 +481,7 @@ func main() {
lazyResourceXDSManager, templateDefinitions, subscriptionSnapshotManager, eventHubInstance,
secretsService, webhookSecretStore, webhookSecretSnapshotManager,
)
cpClient.SetControlPlaneEventGatewayHooks(controlplanehooks.Hooks{})
if err := cpClient.Start(); err != nil {
log.Error("Failed to start control plane client", slog.Any("error", err))
}
Expand Down
134 changes: 134 additions & 0 deletions event-gateway/gateway-controller/pkg/controlplanehooks/events.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
/*
* Copyright (c) 2026, WSO2 LLC. (https://www.wso2.com).
*
* WSO2 LLC. licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

// Package controlplanehooks implements gateway-controller (core)'s
// controlplane.ControlPlaneEventGatewayHooks interface, moved out of core's
// pkg/controlplane/client.go and pkg/controlplane/events.go.
package controlplanehooks

import "time"

// WebSubAPIDeployedEventPayload represents the payload of a WebSub API deployment event.
type WebSubAPIDeployedEventPayload struct {
APIID string `json:"apiId"`
DeploymentID string `json:"deploymentId"`
PerformedAt time.Time `json:"performedAt"`
}

// WebSubAPIDeployedEvent represents the complete WebSub API deployment event.
type WebSubAPIDeployedEvent struct {
Type string `json:"type"`
Payload WebSubAPIDeployedEventPayload `json:"payload"`
Timestamp string `json:"timestamp"`
CorrelationID string `json:"correlationId"`
}

// WebSubAPIUndeployedEventPayload represents the payload of a WebSub API undeployment event.
type WebSubAPIUndeployedEventPayload struct {
APIID string `json:"apiId"`
DeploymentID string `json:"deploymentId"`
PerformedAt time.Time `json:"performedAt"`
}

// WebSubAPIUndeployedEvent represents the complete WebSub API undeployment event.
type WebSubAPIUndeployedEvent struct {
Type string `json:"type"`
Payload WebSubAPIUndeployedEventPayload `json:"payload"`
Timestamp string `json:"timestamp"`
CorrelationID string `json:"correlationId"`
}

// WebSubAPIDeletedEventPayload represents the payload of a WebSub API deletion event.
type WebSubAPIDeletedEventPayload struct {
APIID string `json:"apiId"`
}

// WebSubAPIDeletedEvent represents the complete WebSub API deletion event.
type WebSubAPIDeletedEvent struct {
Type string `json:"type"`
Payload WebSubAPIDeletedEventPayload `json:"payload"`
Timestamp string `json:"timestamp"`
CorrelationID string `json:"correlationId"`
}

// WebBrokerAPIDeployedEventPayload represents the payload of a WebBroker API deployment event.
type WebBrokerAPIDeployedEventPayload struct {
APIID string `json:"apiId"`
DeploymentID string `json:"deploymentId"`
PerformedAt time.Time `json:"performedAt"`
}

// WebBrokerAPIDeployedEvent represents the complete WebBroker API deployment event.
type WebBrokerAPIDeployedEvent struct {
Type string `json:"type"`
Payload WebBrokerAPIDeployedEventPayload `json:"payload"`
Timestamp string `json:"timestamp"`
CorrelationID string `json:"correlationId"`
}

// WebBrokerAPIUndeployedEventPayload represents the payload of a WebBroker API undeployment event.
type WebBrokerAPIUndeployedEventPayload struct {
APIID string `json:"apiId"`
DeploymentID string `json:"deploymentId"`
PerformedAt time.Time `json:"performedAt"`
}

// WebBrokerAPIUndeployedEvent represents the complete WebBroker API undeployment event.
type WebBrokerAPIUndeployedEvent struct {
Type string `json:"type"`
Payload WebBrokerAPIUndeployedEventPayload `json:"payload"`
Timestamp string `json:"timestamp"`
CorrelationID string `json:"correlationId"`
}

// WebBrokerAPIDeletedEventPayload represents the payload of a WebBroker API deletion event.
type WebBrokerAPIDeletedEventPayload struct {
APIID string `json:"apiId"`
}

// WebBrokerAPIDeletedEvent represents the complete WebBroker API deletion event.
type WebBrokerAPIDeletedEvent struct {
Type string `json:"type"`
Payload WebBrokerAPIDeletedEventPayload `json:"payload"`
Timestamp string `json:"timestamp"`
CorrelationID string `json:"correlationId"`
}

// platformHmacSecretEventPayload is the payload for websub.hmacsecret.* events.
type platformHmacSecretEventPayload struct {
ArtifactUUID string `json:"artifactUuid"`
SecretName string `json:"secretName"`
}

// platformHmacSecretInfo is the per-secret DTO returned by the internal HMAC endpoint.
type platformHmacSecretInfo struct {
Name string `json:"name"`
Secret string `json:"secret"`
}

// platformHmacSecretsResponse is the response body from GET /websub-apis/:id/secrets.
type platformHmacSecretsResponse struct {
ArtifactID string `json:"artifactId"`
Secrets []platformHmacSecretInfo `json:"secrets"`
}

// hmacSecretInfo is the internal view of a platform-managed HMAC secret.
type hmacSecretInfo struct {
Name string
Plaintext string
}
Loading
Loading