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 Status conditions for Claim and Composite #146

Merged

Conversation

stevendborrelli
Copy link
Contributor

@stevendborrelli stevendborrelli commented Nov 23, 2024

Description of your changes

Adds the ability to publish status to the Claim or the Composite. Depends on PR #144

apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
kind: ClaimConditions
conditions:
# Guide to ClaimConditions fields:
# Type of the condition, e.g. DatabaseReady.
# 'Healthy', 'Ready' and 'Synced' are reserved for use by Crossplane and this apiVersion: meta.gotemplating.fn.crossplane.io/v1alpha1
kind: ClaimConditions
conditions:
# Guide to ClaimConditions fields:
# Type of the condition, e.g. DatabaseReady.
# 'Healthy', 'Ready' and 'Synced' are reserved for use by Crossplane and this function will raise an error if used
# - type:  
# Status of the condition. String of "True"/"False"/"Unknown"
#   status:
# Machine-readable PascalCase reason, for example "ErrorProvisioning"
#   reason:
# Optional Target. Publish Condition only to the Composite, or the Composite and the Claim (CompositeAndClaim). 
# Defaults to Composite
#   target: 
# Optional message:
#   message: 
- type: TestCondition
  status: "False"
  reason: InstallFail
  message: "failed to install"
  target: CompositeAndClaim
- type: ConditionTrue
  status: "True"
  reason: TrueCondition 
  message: we are true
  target: Composite
- type: DatabaseReady
  status: "True"
  reason: Ready
  message: Database is ready
  target: CompositeAndClaim

Fixes #131

I have:

go test -cover claimconditions.go claimconditions_test.go
ok      command-line-arguments  0.355s  coverage: 96.3% of statements

Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Signed-off-by: Steven Borrelli <[email protected]>
Copy link

@dalton-hill-0 dalton-hill-0 left a comment

Choose a reason for hiding this comment

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

LGTM

claimconditions.go Outdated Show resolved Hide resolved
Signed-off-by: Steven Borrelli <[email protected]>
@stevendborrelli
Copy link
Contributor Author

stevendborrelli commented Nov 25, 2024

Tested in the Composition:

    - type: RDSInstance
      status: {{ (getResourceCondition "Ready" .observed.resources.rdsinstance).Status | toString | quote }}
      reason: {{ (getResourceCondition "Ready" .observed.resources.rdsinstance).Reason }}
      message: {{ (getResourceCondition "Ready" .observed.resources.rdsinstance).Message }}
      target: CompositeAndClaim

Produces the following status in an XR:

    - lastTransitionTime: "2024-11-25T18:06:32Z"
      reason: Available
      status: "True"
      type: RDSInstance

Copy link
Collaborator

@ezgidemirel ezgidemirel left a comment

Choose a reason for hiding this comment

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

Thanks for your PR @stevendborrelli, LGTM!

@ezgidemirel ezgidemirel merged commit 2bcc90e into crossplane-contrib:main Dec 2, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Composition Function Events and Status Conditions
3 participants