Skip to content

Commit

Permalink
feat(stream): added kinesis stream
Browse files Browse the repository at this point in the history
Signed-off-by: haarchri <chhaar30@googlemail.com>
  • Loading branch information
haarchri committed Oct 4, 2021
1 parent 4745181 commit 80508b5
Show file tree
Hide file tree
Showing 19 changed files with 2,275 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ PROJECT_REPO := github.com/crossplane/$(PROJECT_NAME)
PLATFORMS ?= linux_amd64 linux_arm64

CODE_GENERATOR_COMMIT ?= cac5654b7bb64c8f754ad9af01799ef70d9541b6
GENERATED_SERVICES="apigatewayv2,cloudfront,dynamodb,efs,kafka,kms,lambda,rds,secretsmanager,servicediscovery,sfn,transfer"
GENERATED_SERVICES="apigatewayv2,cloudfront,dynamodb,efs,kafka,kinesis,kms,lambda,rds,secretsmanager,servicediscovery,sfn,transfer"

# kind-related versions
KIND_VERSION ?= v0.11.1
Expand Down
2 changes: 2 additions & 0 deletions apis/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import (
identityv1alpha1 "github.com/crossplane/provider-aws/apis/identity/v1alpha1"
identityv1beta1 "github.com/crossplane/provider-aws/apis/identity/v1beta1"
kafkav1alpha1 "github.com/crossplane/provider-aws/apis/kafka/v1alpha1"
kinesisv1alpha1 "github.com/crossplane/provider-aws/apis/kinesis/v1alpha1"
kmsv1alpha1 "github.com/crossplane/provider-aws/apis/kms/v1alpha1"
lambdav1alpha1 "github.com/crossplane/provider-aws/apis/lambda/v1alpha1"
notificationv1alpha3 "github.com/crossplane/provider-aws/apis/notification/v1alpha1"
Expand Down Expand Up @@ -97,6 +98,7 @@ func init() {
route53resolveralpha1.SchemeBuilder.AddToScheme,
kafkav1alpha1.SchemeBuilder.AddToScheme,
transferv1alpha1.SchemeBuilder.AddToScheme,
kinesisv1alpha1.SchemeBuilder.AddToScheme,
)
}

Expand Down
71 changes: 71 additions & 0 deletions apis/kinesis/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Copyright 2021 The Crossplane Authors.
Licensed 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 v1alpha1

import (
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
)

// CustomStreamParameters contains the additional fields for StreamParameters.
type CustomStreamParameters struct {
// The retention period of the stream, in hours.
// Default: 24 hours
RetentionPeriodHours *int64 `json:"retentionPeriodHours,omitempty"`

KMSKeyARN *string `json:"kmsKeyARN,omitempty"`

KMSKeyARNRef *xpv1.Reference `json:"kmsKeyARNRef,omitempty"`

KMSKeyARNSelector *xpv1.Selector `json:"kmsKeyARNSelector,omitempty"`

// List of shard-level metrics.
//
// The following are the valid shard-level metrics. The value "ALL" enhances
// every metric.
//
// * IncomingBytes
//
// * IncomingRecords
//
// * OutgoingBytes
//
// * OutgoingRecords
//
// * WriteProvisionedThroughputExceeded
//
// * ReadProvisionedThroughputExceeded
//
// * IteratorAgeMilliseconds
//
// * ALL
//
// For more information, see Monitoring the Amazon Kinesis Data Streams Service
// with Amazon CloudWatch (https://docs.aws.amazon.com/kinesis/latest/dev/monitoring-with-cloudwatch.html)
// in the Amazon Kinesis Data Streams Developer Guide.
EnhancedMetrics []*EnhancedMetrics `json:"enhancedMetrics,omitempty"`

Tags []CustomTag `json:"tags,omitempty"`
}

// CustomTag contains the additional fields for Tag.
type CustomTag struct {
// A unique identifier for the tag.
Key string `json:"key"`

// An optional string, typically used to describe or define the tag.
Value string `json:"value,omitempty"`
}
9 changes: 9 additions & 0 deletions apis/kinesis/v1alpha1/generator-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
ignore:
field_paths:
- CreateStreamInput.StreamName
resources:
Stream:
exceptions:
errors:
404:
code: ResourceNotFoundException
63 changes: 63 additions & 0 deletions apis/kinesis/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
Copyright 2021 The Crossplane Authors.
Licensed 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 v1alpha1

import (
"context"

"github.com/pkg/errors"
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/crossplane/crossplane-runtime/pkg/reference"
resource "github.com/crossplane/crossplane-runtime/pkg/resource"

kms "github.com/crossplane/provider-aws/apis/kms/v1alpha1"
)

// ResolveReferences of this Stream
func (mg *Stream) ResolveReferences(ctx context.Context, c client.Reader) error {
r := reference.NewAPIResolver(c, mg)

// Resolve spec.forProvider.kmsKeyARN
rsp, err := r.Resolve(ctx, reference.ResolutionRequest{
CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.KMSKeyARN),
Reference: mg.Spec.ForProvider.KMSKeyARNRef,
Selector: mg.Spec.ForProvider.KMSKeyARNSelector,
To: reference.To{Managed: &kms.Key{}, List: &kms.KeyList{}},
Extract: KMSKeyARN(),
})
if err != nil {
return errors.Wrap(err, "spec.forProvider.kmsKeyARN")
}
mg.Spec.ForProvider.KMSKeyARN = reference.ToPtrValue(rsp.ResolvedValue)
mg.Spec.ForProvider.KMSKeyARNRef = rsp.ResolvedReference
return nil
}

// KMSKeyARN returns the status.atProvider.ARN of an KMSKey.
func KMSKeyARN() reference.ExtractValueFn {
return func(mg resource.Managed) string {
r, ok := mg.(*kms.Key)
if !ok {
return ""
}
if r.Status.AtProvider.ARN == nil {
return ""
}
return *r.Status.AtProvider.ARN
}
}
24 changes: 24 additions & 0 deletions apis/kinesis/v1alpha1/zz_doc.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

83 changes: 83 additions & 0 deletions apis/kinesis/v1alpha1/zz_enums.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 80508b5

Please sign in to comment.