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

add common ACK pkg/condition #24

Merged

Conversation

jaypipes
Copy link
Collaborator

@jaypipes jaypipes commented Jun 20, 2021

Adds common resource condition functions to a new pkg/condition:

  • Synced() returns the resource's Condition of type
    ConditionTypeResourceSynced, or nil if the condition isn't found.
  • Terminal() returns the resource's Condition of type
    ConditionTypeTerminal, or nil if the condition isn't found.
  • FirstOfType() returns the first Condition of the specified type, or
    nil if a condition of the type isn't found on the resource.
  • AllOfType() returns a slice of Condition having the specified
    condition type.
  • SetSynced() ensures that a Condition of type
    ConditionTypeResourceSynced is present in the resource's Conditions
    collection and has a specified status, message and reason
  • SetTerminal() ensures that a Condition of type
    ConditionTypeResourceTerminal is present in the resource's Conditions
    collection and has a specified status, message and reason

IMPORTANT COMPATIBILITY NOTE:

Note that the pkg/types.AWSResource interface has been modified to be
a composition of a new pkg/types.ConditionManager interface which
adds a new ReplaceConditions() method that overwrites a resource's
Conditions collection. This is a backwards-incompatible change since the
pkg/types.AWSResource implementations generated by
aws-controllers-k8s/code-generator (the pkg/{RESOURCE/resource.go
files...}) will not include this new ReplaceConditions implementation
and thus won't compile if you attempt to regenerate a controller using
the ACK runtime after this patch is merged. A corresponding patch to the
code-generator is coming that adds the ReplaceCondiions
implementation.

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

@jaypipes jaypipes requested review from surajkota and vijtrip2 June 20, 2021 18:30
@jaypipes jaypipes force-pushed the common-condition-handlers branch from 4db22b4 to 90242d8 Compare June 20, 2021 18:31
@vijtrip2
Copy link
Contributor

/approve


// ManagesConditions describes a thing that can set and retrieve Condition
// objects.
type ManagesConditions interface {
Copy link
Member

Choose a reason for hiding this comment

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

nit: s/ManagesConditions/ConditionsManager/

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nit: s/ManagesConditions/ConditionsManager/

@a-hilaly @RedbackThomson fine, changed the name :)

@a-hilaly
Copy link
Member

/approve

Adds common resource condition functions to a new `pkg/condition`:

- `Synced()` returns the resource's Condition of type
ConditionTypeResourceSynced, or nil if the condition isn't found.
- `Terminal()` returns the resource's Condition of type
ConditionTypeTerminal, or nil if the condition isn't found.
- `FirstOfType()` returns the first Condition of the specified type, or
  nil if a condition of the type isn't found on the resource.
- `AllOfType()` returns a slice of `Condition` having the specified
  condition type.
- `SetSynced()` ensures that a Condition of type
  ConditionTypeResourceSynced is present in the resource's Conditions
  collection and has a specified status, message and reason
- `SetTerminal()` ensures that a Condition of type
  ConditionTypeResourceTerminal is present in the resource's Conditions
  collection and has a specified status, message and reason

IMPORTANT COMPATIBILITY NOTE:

Note that the `pkg/types.AWSResource` interface has been modified to be
a composition of a new `pkg/types.ConditionManager` interface which
adds a new `ReplaceConditions()` method that overwrites a resource's
Conditions collection. This is a backwards-incompatible change since the
`pkg/types.AWSResource` implementations generated by
`aws-controllers-k8s/code-generator` (the `pkg/{RESOURCE/resource.go`
files...}) will not include this new `ReplaceConditions` implementation
and thus won't compile if you attempt to regenerate a controller using
the ACK runtime after this patch is merged. A corresponding patch to the
code-generator is coming that adds the `ReplaceCondiions`
implementation.
@jaypipes jaypipes force-pushed the common-condition-handlers branch from 90242d8 to b3e167d Compare June 21, 2021 22:07
@a-hilaly
Copy link
Member

/lgtm

@ack-bot ack-bot added the lgtm Indicates that a PR is ready to be merged. label Jun 22, 2021
@ack-bot
Copy link
Collaborator

ack-bot commented Jun 22, 2021

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: A-Hilaly, jaypipes, vijtrip2

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,jaypipes,vijtrip2]

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

@ack-bot ack-bot merged commit 932df41 into aws-controllers-k8s:main Jun 22, 2021
ack-bot pushed a commit to aws-controllers-k8s/code-generator that referenced this pull request Jun 23, 2021
Description of changes:
Add the missing `ReplaceConditions` method introduced in aws-controllers-k8s/runtime#24 .
Fix a import path error introduced in #102

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
RedbackThomson added a commit to RedbackThomson/ack-code-generator that referenced this pull request Jun 24, 2021
Description of changes:
Add the missing `ReplaceConditions` method introduced in aws-controllers-k8s/runtime#24 .
Fix a import path error introduced in aws-controllers-k8s#102

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
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