forked from crossplane/function-template-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fn.go
57 lines (47 loc) · 1.94 KB
/
fn.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"context"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/dynamodb"
"github.com/aws/aws-sdk-go-v2/service/kinesis"
ctrl "sigs.k8s.io/controller-runtime"
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/errors"
"github.com/crossplane/crossplane-runtime/pkg/meta"
"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
cpresource "github.com/crossplane/crossplane-runtime/pkg/resource"
)
type Composition struct{}
func (c *Composition) Compose(ctx context.Context, mg cpresource.Managed, clm cpresource.Claim) (cpresource.Composed, error) {
// Compose the desired DynamoDB table and Kinesis stream based on the claim
dynamoDBTable, err := composeDynamoDBTable(ctx, mg, clm)
if err != nil {
return cpresource.Composed{}, err
}
kinesisStream, err := composeKinesisStream(ctx, mg, clm)
if err != nil {
return cpresource.Composed{}, err
}
return cpresource.Composed{
Resources: []cpresource.ComposedResource{
dynamoDBTable,
kinesisStream,
},
}, nil
}
func composeDynamoDBTable(ctx context.Context, mg cpresource.Managed, clm cpresource.Claim) (cpresource.ComposedResource, error) {
// Implement the logic to compose the desired DynamoDB table based on the claim
return cpresource.ComposedResource{}, nil
}
func composeKinesisStream(ctx context.Context, mg cpresource.Managed, clm cpresource.Claim) (cpresource.ComposedResource, error) {
// Implement the logic to compose the desired Kinesis stream based on the claim
return cpresource.ComposedResource{}, nil
}
func (c *Composition) Render(ctx context.Context, mg cpresource.Managed, res cpresource.Composed) error {
// Render the composed resources to the managed resource
return nil
}
func (c *Composition) Observe(ctx context.Context, mg cpresource.Managed) (cpresource.Managed, error) {
// Observe the current state of the DynamoDB table and Kinesis stream
return mg, nil
}