Skip to content

Commit

Permalink
apis: Add detail subcondition type to DetailedCondition
Browse files Browse the repository at this point in the history
Adds a details subcodition array to the DetailedCondition allowing
for more information to be exposed to users via an HTTPProxy
Conditions struct. Things like fqdn, included paths or headers
can be written to child proxies allowing users to understand
what has been included to them from a parent resource.

Updates projectcontour#2495

Signed-off-by: Steve Sloka <slokas@vmware.com>
  • Loading branch information
stevesloka committed Nov 17, 2020
1 parent 8fbbac6 commit b444690
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 0 deletions.
5 changes: 5 additions & 0 deletions apis/projectcontour/v1/detailedconditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ type DetailedCondition struct {
// An empty slice here indicates no warnings.
// +optional
Warnings []SubCondition `json:"warnings,omitempty"`
// Details contains a slice of relevant detail subconditions for this object.
//
// Subconditions expose detailed information about the object.
// +optional
Details []SubCondition `json:"infos,omitempty"`
}

const ValidConditionType string = "Valid"
13 changes: 13 additions & 0 deletions apis/projectcontour/v1/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,19 @@ func (dc *DetailedCondition) AddError(errorType, reason, message string) {
})
}

// AddDetail adds an info-level Subcondition to the DetailedCondition.
// If a SubCondition with the given detailType exists, will overwrite the details.
func (dc *DetailedCondition) AddDetail(detailType, reason, message string) {
message = truncateLongMessage(message)

dc.Details = append(dc.Details, SubCondition{
Type: detailType,
Status: ConditionTrue,
Message: message,
Reason: reason,
})
}

// AddErrorf adds an error-level Subcondition to the DetailedCondition, using
// fmt.Sprintf on the formatmsg and args params.
// If a SubCondition with the given errorType exists, will overwrite the details.
Expand Down
5 changes: 5 additions & 0 deletions apis/projectcontour/v1/zz_generated.deepcopy.go

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

102 changes: 102 additions & 0 deletions examples/contour/01-crds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,40 @@ spec:
- type
type: object
type: array
infos:
description: "Details contains a slice of relevant detail subconditions for this object. \n Subconditions expose detailed information about the object."
items:
description: "SubCondition is a Condition-like type intended for use as a subcondition inside a DetailedCondition. \n It contains a subset of the Condition fields. \n It is intended for warnings and errors, so `type` names should use abnormal-true polarity, that is, they should be of the form \"ErrorPresent: true\". \n The expected lifecycle for these errors is that they should only be present when the error or warning is, and should be removed when they are not relevant."
properties:
message:
description: "Message is a human readable message indicating details about the transition. \n This may be an empty string."
maxLength: 32768
type: string
reason:
description: "Reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. \n The value should be a CamelCase string. \n This field may not be empty."
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: Status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: "Type of condition in `CamelCase` or in `foo.example.com/CamelCase`. \n This must be in abnormal-true polarity, that is, `ErrorFound` or `controller.io/ErrorFound`. \n The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)"
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- message
- reason
- status
- type
type: object
type: array
lastTransitionTime:
description: "lastTransitionTime is the last time the condition transitioned from one status to another. \n This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable."
format: date-time
Expand Down Expand Up @@ -978,6 +1012,40 @@ spec:
- type
type: object
type: array
infos:
description: "Details contains a slice of relevant detail subconditions for this object. \n Subconditions expose detailed information about the object."
items:
description: "SubCondition is a Condition-like type intended for use as a subcondition inside a DetailedCondition. \n It contains a subset of the Condition fields. \n It is intended for warnings and errors, so `type` names should use abnormal-true polarity, that is, they should be of the form \"ErrorPresent: true\". \n The expected lifecycle for these errors is that they should only be present when the error or warning is, and should be removed when they are not relevant."
properties:
message:
description: "Message is a human readable message indicating details about the transition. \n This may be an empty string."
maxLength: 32768
type: string
reason:
description: "Reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. \n The value should be a CamelCase string. \n This field may not be empty."
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: Status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: "Type of condition in `CamelCase` or in `foo.example.com/CamelCase`. \n This must be in abnormal-true polarity, that is, `ErrorFound` or `controller.io/ErrorFound`. \n The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)"
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- message
- reason
- status
- type
type: object
type: array
lastTransitionTime:
description: "lastTransitionTime is the last time the condition transitioned from one status to another. \n This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable."
format: date-time
Expand Down Expand Up @@ -1188,6 +1256,40 @@ spec:
- type
type: object
type: array
infos:
description: "Details contains a slice of relevant detail subconditions for this object. \n Subconditions expose detailed information about the object."
items:
description: "SubCondition is a Condition-like type intended for use as a subcondition inside a DetailedCondition. \n It contains a subset of the Condition fields. \n It is intended for warnings and errors, so `type` names should use abnormal-true polarity, that is, they should be of the form \"ErrorPresent: true\". \n The expected lifecycle for these errors is that they should only be present when the error or warning is, and should be removed when they are not relevant."
properties:
message:
description: "Message is a human readable message indicating details about the transition. \n This may be an empty string."
maxLength: 32768
type: string
reason:
description: "Reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. \n The value should be a CamelCase string. \n This field may not be empty."
maxLength: 1024
minLength: 1
pattern: ^[A-Za-z]([A-Za-z0-9_,:]*[A-Za-z0-9_])?$
type: string
status:
description: Status of the condition, one of True, False, Unknown.
enum:
- "True"
- "False"
- Unknown
type: string
type:
description: "Type of condition in `CamelCase` or in `foo.example.com/CamelCase`. \n This must be in abnormal-true polarity, that is, `ErrorFound` or `controller.io/ErrorFound`. \n The regex it matches is (dns1123SubdomainFmt/)?(qualifiedNameFmt)"
maxLength: 316
pattern: ^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])$
type: string
required:
- message
- reason
- status
- type
type: object
type: array
lastTransitionTime:
description: "lastTransitionTime is the last time the condition transitioned from one status to another. \n This should be when the underlying condition changed. If that is not known, then using the time when the API field changed is acceptable."
format: date-time
Expand Down
Loading

0 comments on commit b444690

Please sign in to comment.