mirror of
https://github.com/zalando/postgres-operator.git
synced 2026-10-04 18:33:48 +02:00
move FES to v1
This commit is contained in:
+21
-21
@@ -7,7 +7,7 @@ import (
|
||||
"strings"
|
||||
|
||||
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
||||
zalandov1alpha1 "github.com/zalando/postgres-operator/pkg/apis/zalando.org/v1alpha1"
|
||||
zalandov1 "github.com/zalando/postgres-operator/pkg/apis/zalando.org/v1"
|
||||
"github.com/zalando/postgres-operator/pkg/util"
|
||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||
"github.com/zalando/postgres-operator/pkg/util/k8sutil"
|
||||
@@ -18,7 +18,7 @@ func (c *Cluster) createStreams(appId string) {
|
||||
c.setProcessName("creating streams")
|
||||
|
||||
var (
|
||||
fes *zalandov1alpha1.FabricEventStream
|
||||
fes *zalandov1.FabricEventStream
|
||||
err error
|
||||
)
|
||||
|
||||
@@ -34,7 +34,7 @@ func (c *Cluster) createStreams(appId string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) updateStreams(newEventStreams *zalandov1alpha1.FabricEventStream) error {
|
||||
func (c *Cluster) updateStreams(newEventStreams *zalandov1.FabricEventStream) error {
|
||||
c.setProcessName("updating event streams")
|
||||
|
||||
_, err := c.KubeClient.FabricEventStreams(newEventStreams.Namespace).Update(context.TODO(), newEventStreams, metav1.UpdateOptions{})
|
||||
@@ -84,7 +84,7 @@ func (c *Cluster) syncPostgresConfig() error {
|
||||
for _, stream := range c.Spec.Streams {
|
||||
slot := map[string]string{
|
||||
"database": stream.Database,
|
||||
"plugin": "wal2json",
|
||||
"plugin": "pgoutput",
|
||||
"type": "logical",
|
||||
}
|
||||
slotName := constants.EventStreamSourceSlotPrefix + "_" + stream.Database + "_" + stream.ApplicationId
|
||||
@@ -128,8 +128,8 @@ func (c *Cluster) syncPostgresConfig() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Cluster) generateFabricEventStream(appId string) *zalandov1alpha1.FabricEventStream {
|
||||
eventStreams := make([]zalandov1alpha1.EventStream, 0)
|
||||
func (c *Cluster) generateFabricEventStream(appId string) *zalandov1.FabricEventStream {
|
||||
eventStreams := make([]zalandov1.EventStream, 0)
|
||||
|
||||
for _, stream := range c.Spec.Streams {
|
||||
if stream.ApplicationId != appId {
|
||||
@@ -140,17 +140,17 @@ func (c *Cluster) generateFabricEventStream(appId string) *zalandov1alpha1.Fabri
|
||||
streamFlow := getEventStreamFlow(stream, table.PayloadColumn)
|
||||
streamSink := getEventStreamSink(stream, table.EventType)
|
||||
|
||||
eventStreams = append(eventStreams, zalandov1alpha1.EventStream{
|
||||
eventStreams = append(eventStreams, zalandov1.EventStream{
|
||||
EventStreamFlow: streamFlow,
|
||||
EventStreamSink: streamSink,
|
||||
EventStreamSource: streamSource})
|
||||
}
|
||||
}
|
||||
|
||||
return &zalandov1alpha1.FabricEventStream{
|
||||
return &zalandov1.FabricEventStream{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: constants.EventStreamSourceCRDKind,
|
||||
APIVersion: "zalando.org/v1alpha1",
|
||||
APIVersion: "zalando.org/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: c.Name + "-" + appId,
|
||||
@@ -159,17 +159,17 @@ func (c *Cluster) generateFabricEventStream(appId string) *zalandov1alpha1.Fabri
|
||||
// make cluster StatefulSet the owner (like with connection pooler objects)
|
||||
OwnerReferences: c.ownerReferences(),
|
||||
},
|
||||
Spec: zalandov1alpha1.FabricEventStreamSpec{
|
||||
Spec: zalandov1.FabricEventStreamSpec{
|
||||
ApplicationId: appId,
|
||||
EventStreams: eventStreams,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) getEventStreamSource(stream acidv1.Stream, tableName, idColumn string) zalandov1alpha1.EventStreamSource {
|
||||
func (c *Cluster) getEventStreamSource(stream acidv1.Stream, tableName, idColumn string) zalandov1.EventStreamSource {
|
||||
table, schema := getTableSchema(tableName)
|
||||
streamFilter := stream.Filter[tableName]
|
||||
return zalandov1alpha1.EventStreamSource{
|
||||
return zalandov1.EventStreamSource{
|
||||
Type: constants.EventStreamSourcePGType,
|
||||
Schema: schema,
|
||||
EventStreamTable: getOutboxTable(table, idColumn),
|
||||
@@ -181,15 +181,15 @@ func (c *Cluster) getEventStreamSource(stream acidv1.Stream, tableName, idColumn
|
||||
}
|
||||
}
|
||||
|
||||
func getEventStreamFlow(stream acidv1.Stream, payloadColumn string) zalandov1alpha1.EventStreamFlow {
|
||||
return zalandov1alpha1.EventStreamFlow{
|
||||
func getEventStreamFlow(stream acidv1.Stream, payloadColumn string) zalandov1.EventStreamFlow {
|
||||
return zalandov1.EventStreamFlow{
|
||||
Type: constants.EventStreamFlowPgGenericType,
|
||||
PayloadColumn: payloadColumn,
|
||||
}
|
||||
}
|
||||
|
||||
func getEventStreamSink(stream acidv1.Stream, eventType string) zalandov1alpha1.EventStreamSink {
|
||||
return zalandov1alpha1.EventStreamSink{
|
||||
func getEventStreamSink(stream acidv1.Stream, eventType string) zalandov1.EventStreamSink {
|
||||
return zalandov1.EventStreamSink{
|
||||
Type: constants.EventStreamSinkNakadiType,
|
||||
EventType: eventType,
|
||||
MaxBatchSize: stream.BatchSize,
|
||||
@@ -207,18 +207,18 @@ func getTableSchema(fullTableName string) (tableName, schemaName string) {
|
||||
return tableName, schemaName
|
||||
}
|
||||
|
||||
func getOutboxTable(tableName, idColumn string) zalandov1alpha1.EventStreamTable {
|
||||
return zalandov1alpha1.EventStreamTable{
|
||||
func getOutboxTable(tableName, idColumn string) zalandov1.EventStreamTable {
|
||||
return zalandov1.EventStreamTable{
|
||||
Name: tableName,
|
||||
IDColumn: idColumn,
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Cluster) getStreamConnection(database, user, appId string) zalandov1alpha1.Connection {
|
||||
return zalandov1alpha1.Connection{
|
||||
func (c *Cluster) getStreamConnection(database, user, appId string) zalandov1.Connection {
|
||||
return zalandov1.Connection{
|
||||
Url: fmt.Sprintf("jdbc:postgresql://%s.%s/%s?user=%s&ssl=true&sslmode=require", c.Name, c.Namespace, database, user),
|
||||
SlotName: constants.EventStreamSourceSlotPrefix + "_" + database + "_" + strings.Replace(appId, "-", "_", -1),
|
||||
DBAuth: zalandov1alpha1.DBAuth{
|
||||
DBAuth: zalandov1.DBAuth{
|
||||
Type: constants.EventStreamSourceAuthType,
|
||||
Name: c.credentialSecretNameForCluster(user, c.Name),
|
||||
UserKey: "username",
|
||||
|
||||
+14
-14
@@ -11,8 +11,8 @@ import (
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
acidv1 "github.com/zalando/postgres-operator/pkg/apis/acid.zalan.do/v1"
|
||||
"github.com/zalando/postgres-operator/pkg/apis/zalando.org/v1alpha1"
|
||||
fakezalandov1alpha1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/fake"
|
||||
v1 "github.com/zalando/postgres-operator/pkg/apis/zalando.org/v1"
|
||||
fakezalandov1 "github.com/zalando/postgres-operator/pkg/generated/clientset/versioned/fake"
|
||||
"github.com/zalando/postgres-operator/pkg/util"
|
||||
"github.com/zalando/postgres-operator/pkg/util/config"
|
||||
"github.com/zalando/postgres-operator/pkg/util/constants"
|
||||
@@ -24,11 +24,11 @@ import (
|
||||
)
|
||||
|
||||
func newFakeK8sStreamClient() (k8sutil.KubernetesClient, *fake.Clientset) {
|
||||
zalandoClientSet := fakezalandov1alpha1.NewSimpleClientset()
|
||||
zalandoClientSet := fakezalandov1.NewSimpleClientset()
|
||||
clientSet := fake.NewSimpleClientset()
|
||||
|
||||
return k8sutil.KubernetesClient{
|
||||
FabricEventStreamsGetter: zalandoClientSet.ZalandoV1alpha1(),
|
||||
FabricEventStreamsGetter: zalandoClientSet.ZalandoV1(),
|
||||
PostgresqlsGetter: zalandoClientSet.AcidV1(),
|
||||
PodsGetter: clientSet.CoreV1(),
|
||||
StatefulSetsGetter: clientSet.AppsV1(),
|
||||
@@ -79,10 +79,10 @@ var (
|
||||
},
|
||||
}
|
||||
|
||||
fes = &v1alpha1.FabricEventStream{
|
||||
fes = &v1.FabricEventStream{
|
||||
TypeMeta: metav1.TypeMeta{
|
||||
Kind: "FabricEventStream",
|
||||
APIVersion: "zalando.org/v1alpha1",
|
||||
APIVersion: "zalando.org/v1",
|
||||
},
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fesName,
|
||||
@@ -96,23 +96,23 @@ var (
|
||||
},
|
||||
},
|
||||
},
|
||||
Spec: v1alpha1.FabricEventStreamSpec{
|
||||
Spec: v1.FabricEventStreamSpec{
|
||||
ApplicationId: appId,
|
||||
EventStreams: []v1alpha1.EventStream{
|
||||
EventStreams: []v1.EventStream{
|
||||
{
|
||||
EventStreamFlow: v1alpha1.EventStreamFlow{
|
||||
EventStreamFlow: v1.EventStreamFlow{
|
||||
PayloadColumn: "b_payload",
|
||||
Type: constants.EventStreamFlowPgGenericType,
|
||||
},
|
||||
EventStreamSink: v1alpha1.EventStreamSink{
|
||||
EventStreamSink: v1.EventStreamSink{
|
||||
EventType: "stream_type_a",
|
||||
MaxBatchSize: uint32(100),
|
||||
Type: constants.EventStreamSinkNakadiType,
|
||||
},
|
||||
EventStreamSource: v1alpha1.EventStreamSource{
|
||||
EventStreamSource: v1.EventStreamSource{
|
||||
Filter: "[?(@.source.txId > 500 && @.source.lsn > 123456)]",
|
||||
Connection: v1alpha1.Connection{
|
||||
DBAuth: v1alpha1.DBAuth{
|
||||
Connection: v1.Connection{
|
||||
DBAuth: v1.DBAuth{
|
||||
Name: fmt.Sprintf("fes-user.%s.credentials.postgresql.acid.zalan.do", clusterName),
|
||||
PasswordKey: "password",
|
||||
Type: constants.EventStreamSourceAuthType,
|
||||
@@ -122,7 +122,7 @@ var (
|
||||
SlotName: fmt.Sprintf("%s_%s_%s", constants.EventStreamSourceSlotPrefix, dbName, strings.Replace(appId, "-", "_", -1)),
|
||||
},
|
||||
Schema: "data",
|
||||
EventStreamTable: v1alpha1.EventStreamTable{
|
||||
EventStreamTable: v1.EventStreamTable{
|
||||
IDColumn: "b_id",
|
||||
Name: "bar",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user