Skip to content

Commit

Permalink
(fix) double resources generated for firehose
Browse files Browse the repository at this point in the history
Signed-off-by: domeneen <[email protected]>

bug with external name firehose fixed

Signed-off-by: domeneen <[email protected]>

quick fixes on deliverystream setup

Signed-off-by: domeneen <[email protected]>

gci applied

Signed-off-by: domeneen <[email protected]>
  • Loading branch information
nilde authored and domeneen committed Oct 17, 2023
1 parent e8da856 commit c76bc0d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/firehose/deliverystream.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ spec:
forProvider:
region: us-east-1
deliveryStreamName: firehose-deliverystream
deliveryStreamType: KinesisStreamAsSource
deliveryStreamType: DirectPut
extendedS3DestinationConfiguration:
roleARN: arn:aws:iam::000000000000:role/Firehose-Example-Role
bucketARN: arn:aws:s3:::bucket-example
Expand Down
21 changes: 12 additions & 9 deletions pkg/controller/firehose/deliverystream/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package deliverystream
import (
"context"

"github.com/aws/aws-sdk-go/aws"
svcsdk "github.com/aws/aws-sdk-go/service/firehose"
xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
"github.com/crossplane/crossplane-runtime/pkg/connection"
"github.com/crossplane/crossplane-runtime/pkg/controller"
"github.com/crossplane/crossplane-runtime/pkg/event"
Expand All @@ -29,10 +29,9 @@ import (
"github.com/crossplane/crossplane-runtime/pkg/resource"
ctrl "sigs.k8s.io/controller-runtime"

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

svcapitypes "github.com/crossplane-contrib/provider-aws/apis/firehose/v1alpha1"
"github.com/crossplane-contrib/provider-aws/apis/v1alpha1"
awsclients "github.com/crossplane-contrib/provider-aws/pkg/clients"
"github.com/crossplane-contrib/provider-aws/pkg/features"
)

Expand All @@ -58,6 +57,10 @@ func SetupDeliveryStream(mgr ctrl.Manager, o controller.Options) error {

reconcilerOpts := []managed.ReconcilerOption{
managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), opts: opts}),
managed.WithReferenceResolver(managed.NewAPISimpleReferenceResolver(mgr.GetClient())),
managed.WithInitializers(
managed.NewDefaultProviderConfig(mgr.GetClient()),
managed.NewNameAsExternalName(mgr.GetClient())),
managed.WithPollInterval(o.PollInterval),
managed.WithLogger(o.Logger.WithValues("controller", name)),
managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))),
Expand All @@ -81,17 +84,17 @@ func SetupDeliveryStream(mgr ctrl.Manager, o controller.Options) error {
}

func preObserve(_ context.Context, cr *svcapitypes.DeliveryStream, obj *svcsdk.DescribeDeliveryStreamInput) error {
obj.DeliveryStreamName = aws.String(meta.GetExternalName(cr))
obj.DeliveryStreamName = awsclients.String(meta.GetExternalName(cr))
return nil
}

func preCreate(_ context.Context, cr *svcapitypes.DeliveryStream, obj *svcsdk.CreateDeliveryStreamInput) error {
obj.DeliveryStreamName = aws.String(meta.GetExternalName(cr))
obj.DeliveryStreamName = awsclients.String(meta.GetExternalName(cr))
return nil
}

func preDelete(_ context.Context, cr *svcapitypes.DeliveryStream, obj *svcsdk.DeleteDeliveryStreamInput) (bool, error) {
obj.DeliveryStreamName = aws.String(meta.GetExternalName(cr))
obj.DeliveryStreamName = awsclients.String(meta.GetExternalName(cr))
return false, nil
}

Expand All @@ -100,7 +103,7 @@ func postObserve(_ context.Context, cr *svcapitypes.DeliveryStream, obj *svcsdk.
return managed.ExternalObservation{}, err
}

switch aws.StringValue(obj.DeliveryStreamDescription.DeliveryStreamStatus) {
switch awsclients.StringValue(obj.DeliveryStreamDescription.DeliveryStreamStatus) {
case string(svcapitypes.DeliveryStreamStatus_SDK_ACTIVE):
cr.SetConditions(xpv1.Available())
case string(svcapitypes.DeliveryStreamStatus_SDK_CREATING):
Expand All @@ -110,7 +113,7 @@ func postObserve(_ context.Context, cr *svcapitypes.DeliveryStream, obj *svcsdk.
}

obs.ConnectionDetails = managed.ConnectionDetails{
"arn": []byte(aws.StringValue(obj.DeliveryStreamDescription.DeliveryStreamARN)),
"arn": []byte(awsclients.StringValue(obj.DeliveryStreamDescription.DeliveryStreamARN)),
"name": []byte(meta.GetExternalName(cr)),
}

Expand All @@ -121,6 +124,6 @@ func postCreate(_ context.Context, cr *svcapitypes.DeliveryStream, obj *svcsdk.C
if err != nil {
return managed.ExternalCreation{}, err
}
meta.SetExternalName(cr, cr.Name)

return managed.ExternalCreation{ExternalNameAssigned: true}, nil
}
3 changes: 1 addition & 2 deletions pkg/controller/firehose/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ limitations under the License.
package firehose

import (
ctrl "sigs.k8s.io/controller-runtime"

"github.com/crossplane/crossplane-runtime/pkg/controller"
ctrl "sigs.k8s.io/controller-runtime"

"github.com/crossplane-contrib/provider-aws/pkg/controller/firehose/deliverystream"
"github.com/crossplane-contrib/provider-aws/pkg/utils/setup"
Expand Down

0 comments on commit c76bc0d

Please sign in to comment.