Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add Rule resource #7

Merged
merged 7 commits into from
Feb 7, 2023
Merged

Conversation

embano1
Copy link
Member

@embano1 embano1 commented Feb 1, 2023

Description of changes: Add Rule resource.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@ack-prow ack-prow bot requested review from a-hilaly and RedbackThomson February 1, 2023 15:51
Copy link
Contributor

@jaypipes jaypipes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really great work on this @embano1! You're definitely getting the hang of ACK development! :)

A few relatively minor suggestions inline but nothing big.

Best,
-jay

pkg/resource/rule/hooks.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks_tags.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks_tags.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks_targets.go Outdated Show resolved Hide resolved
templates/hooks/rule/sdk_file_end.go.tpl Outdated Show resolved Hide resolved
templates/hooks/rule/sdk_file_end.go.tpl Outdated Show resolved Hide resolved
templates/hooks/rule/sdk_file_end.go.tpl Outdated Show resolved Hide resolved
@embano1
Copy link
Member Author

embano1 commented Feb 2, 2023

Really great work on this @embano1! You're definitely getting the hang of ACK development! :)

YOU BET!

Thx for your great detailed reviews! Next resources already waiting for your 🦅 👁️ :D

Copy link

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly comments regarding initialism casing and code layout. I have no qualms with the logic itself though, it's great!

apis/v1alpha1/generator.yaml Outdated Show resolved Hide resolved
apis/v1alpha1/types.go Outdated Show resolved Hide resolved
apis/v1alpha1/types.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks.go Outdated Show resolved Hide resolved
pkg/resource/rule/hooks_tags.go Show resolved Hide resolved
templates/hooks/rule/sdk_create_pre_build_request.go.tpl Outdated Show resolved Hide resolved
@embano1
Copy link
Member Author

embano1 commented Feb 3, 2023

@RedbackThomson addressed all comments in a squashed commit.

@embano1
Copy link
Member Author

embano1 commented Feb 3, 2023

Thx @jaypipes. Will wait for your PR to merge then rebase and regenerate.

@RedbackThomson
Copy link

Thx @jaypipes. Will wait for your PR to merge then rebase and regenerate.

The initialisms PR is already merged, and the code-generator updated with that commit - aws-controllers-k8s/code-generator#400 :)

@a-hilaly a-hilaly force-pushed the rule branch 15 times, most recently from 566f3b0 to 7ff7a61 Compare February 7, 2023 14:05
@a-hilaly
Copy link
Member

a-hilaly commented Feb 7, 2023

@jaypipes @RedbackThomson Comments addressed and tests are passing PTAL

Copy link

@RedbackThomson RedbackThomson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ready to ship :)

apis/v1alpha1/event_bus.go Show resolved Hide resolved
replacements = REPLACEMENT_VALUES.copy()
replacements["BUS_NAME"] = eb_cr["spec"]["name"]
replacements["RULE_NAME"] = resource_name
replacements["EVENT_PATTERN"] = "{\\\"detail-type\\\":[\\\"ack-event\\\"]}"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Could make this easier using json.dumps:

Suggested change
replacements["EVENT_PATTERN"] = "{\\\"detail-type\\\":[\\\"ack-event\\\"]}"
replacements["EVENT_PATTERN"] = json.dumps({
"detail-type": ["ack-event"]
})

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh god, thank you!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't work since, this is directory going to the resource yaml file..

Copy link

@RedbackThomson RedbackThomson Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll need to wrap the YAML file variable with double quotes, so that it doesn't try to unwrap it as an object:

eventPattern: "$EVENT_PATTERN"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did:

apiVersion: eventbridge.services.k8s.aws/v1alpha1
kind: Rule
metadata:
  name: $RULE_NAME
spec:
  name: $RULE_NAME
  eventBusName: $BUS_NAME
  eventPattern: "$EVENT_PATTERN"
  tags:
  - key: env
    value: testing

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me give a shot and see if it will work with single quote, i can submit a new PR or fix in the next one

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah I'm seeing this in the EKS controller advanced configuration PR as well. We just need some combination of single quotes and double quotes that don't cause string escape issues 👍🏼

@ack-prow ack-prow bot added the approved label Feb 7, 2023
Signed-off-by: Amine Hilaly <hilalyamine@gmail.com>
Copy link
Member

@a-hilaly a-hilaly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@ack-prow ack-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 7, 2023
@ack-prow
Copy link

ack-prow bot commented Feb 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, embano1, RedbackThomson

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [A-Hilaly,RedbackThomson]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ack-prow ack-prow bot merged commit 282994c into aws-controllers-k8s:main Feb 7, 2023
@embano1 embano1 deleted the rule branch February 7, 2023 20:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm Indicates that a PR is ready to be merged.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants