-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(health): support for distribution aws.crossplane.io resource
Signed-off-by: nueavv <[email protected]>
- Loading branch information
Showing
9 changed files
with
713 additions
and
0 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
resource_customizations/cloudfront.aws.crossplane.io/Distribution/health.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
local hs = {} | ||
if obj.status ~= nil then | ||
if obj.status.conditions ~= nil then | ||
local ready = false | ||
local synced = false | ||
local suspended = false | ||
for i, condition in ipairs(obj.status.conditions) do | ||
if condition.reason == "Ready" then | ||
ready = condition.status == "True" | ||
ready_message = condition.reason | ||
elseif condition.type == "Synced" then | ||
synced = condition.status == "True" | ||
if condition.reason == "ReconcileError" then | ||
synced_message = condition.message | ||
elseif condition.reason == "ReconcilePaused" then | ||
suspended = true | ||
suspended_message = condition.reason | ||
end | ||
end | ||
end | ||
if ready == true and synced == true then | ||
hs.status = "Healthy" | ||
hs.message = ready_message | ||
elseif synced == false and suspended == true then | ||
hs.status = "Suspended" | ||
hs.message = suspended_message | ||
elseif ready == false and synced == true and suspended == false then | ||
hs.status = "Progressing" | ||
hs.message = "Waiting for distribution to be available" | ||
else | ||
hs.status = "Degraded" | ||
hs.message = synced_message | ||
end | ||
return hs | ||
end | ||
end | ||
|
||
hs.status = "Progressing" | ||
hs.message = "Waiting for distribution to be created" | ||
return hs |
37 changes: 37 additions & 0 deletions
37
resource_customizations/cloudfront.aws.crossplane.io/Distribution/health_test.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
tests: | ||
- healthStatus: | ||
status: Progressing | ||
message: Waiting for distribution to be available | ||
inputPath: testdata/progressing_creating.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: Waiting for distribution to be available | ||
inputPath: testdata/progressing_noavailable.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: Waiting for distribution to be available | ||
inputPath: testdata/progressing.yaml | ||
- healthStatus: | ||
status: Progressing | ||
message: Waiting for distribution to be created | ||
inputPath: testdata/progressing_noStatus.yaml | ||
- healthStatus: | ||
status: Degraded | ||
message: > | ||
update failed: cannot update Distribution in AWS: InvalidParameter: 2 | ||
validation error(s) found. | ||
- missing required field, | ||
UpdateDistributionInput.DistributionConfig.Origins.Items[0].DomainName. | ||
- missing required field, | ||
UpdateDistributionInput.DistributionConfig.Origins.Items[0].Id. | ||
inputPath: testdata/degraded_reconcileError.yaml | ||
- healthStatus: | ||
status: Suspended | ||
message: ReconcilePaused | ||
inputPath: testdata/suspended.yaml | ||
- healthStatus: | ||
status: Healthy | ||
message: Available | ||
inputPath: testdata/healthy.yaml |
96 changes: 96 additions & 0 deletions
96
...mizations/cloudfront.aws.crossplane.io/Distribution/testdata/degraded_reconcileError.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
apiVersion: cloudfront.aws.crossplane.io/v1alpha1 | ||
kind: Distribution | ||
metadata: | ||
creationTimestamp: '2024-01-17T07:26:02Z' | ||
generation: 2 | ||
name: crossplane.io | ||
resourceVersion: '261942288' | ||
uid: 4b50c88b-165c-4176-be8e-aa28fdec0a94 | ||
spec: | ||
deletionPolicy: Orphan | ||
forProvider: | ||
distributionConfig: | ||
comment: 'crossplane' | ||
customErrorResponses: | ||
items: [] | ||
defaultCacheBehavior: | ||
allowedMethods: | ||
cachedMethods: | ||
items: | ||
- HEAD | ||
- GET | ||
items: | ||
- HEAD | ||
- GET | ||
compress: false | ||
defaultTTL: 600 | ||
fieldLevelEncryptionID: '' | ||
forwardedValues: | ||
cookies: | ||
forward: none | ||
headers: | ||
items: [] | ||
queryString: false | ||
queryStringCacheKeys: {} | ||
functionAssociations: {} | ||
lambdaFunctionAssociations: {} | ||
maxTTL: 600 | ||
minTTL: 0 | ||
smoothStreaming: false | ||
targetOriginID: crossplane.io | ||
trustedKeyGroups: | ||
enabled: false | ||
trustedSigners: | ||
enabled: false | ||
viewerProtocolPolicy: allow-all | ||
defaultRootObject: index.html | ||
enabled: true | ||
httpVersion: http2 | ||
isIPV6Enabled: true | ||
logging: | ||
bucket: '' | ||
enabled: false | ||
includeCookies: false | ||
prefix: '' | ||
originGroups: {} | ||
origins: | ||
items: | ||
- connectionAttempts: 3 | ||
connectionTimeout: 10 | ||
customOriginConfig: | ||
httpPort: 8080 | ||
httpSPort: 443 | ||
originKeepaliveTimeout: 5 | ||
originProtocolPolicy: http-only | ||
originReadTimeout: 10 | ||
originSSLProtocols: | ||
items: | ||
- TLSv1 | ||
- TLSv1.1 | ||
- TLSv1.2 | ||
priceClass: PriceClass_200 | ||
restrictions: | ||
geoRestriction: | ||
restrictionType: none | ||
region: ap-northeast-2 | ||
providerConfigRef: | ||
name: crossplane | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2024-01-17T07:26:02Z' | ||
message: > | ||
update failed: cannot update Distribution in AWS: InvalidParameter: 2 | ||
validation error(s) found. | ||
- missing required field, | ||
UpdateDistributionInput.DistributionConfig.Origins.Items[0].DomainName. | ||
- missing required field, | ||
UpdateDistributionInput.DistributionConfig.Origins.Items[0].Id. | ||
reason: ReconcileError | ||
status: 'False' | ||
type: Synced | ||
- lastTransitionTime: '2024-01-17T07:26:03Z' | ||
reason: Available | ||
status: 'True' | ||
type: Ready |
92 changes: 92 additions & 0 deletions
92
resource_customizations/cloudfront.aws.crossplane.io/Distribution/testdata/healthy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
apiVersion: cloudfront.aws.crossplane.io/v1alpha1 | ||
kind: Distribution | ||
metadata: | ||
creationTimestamp: "2023-09-07T01:01:16Z" | ||
generation: 121 | ||
name: crossplane.io | ||
resourceVersion: "254225966" | ||
uid: 531d989c-a3d2-4ab4-841d-ab380cce0bdb | ||
spec: | ||
deletionPolicy: Orphan | ||
forProvider: | ||
distributionConfig: | ||
comment: 'crossplane' | ||
customErrorResponses: | ||
items: [] | ||
defaultCacheBehavior: | ||
allowedMethods: | ||
cachedMethods: | ||
items: | ||
- HEAD | ||
- GET | ||
items: | ||
- HEAD | ||
- GET | ||
compress: false | ||
defaultTTL: 600 | ||
fieldLevelEncryptionID: '' | ||
forwardedValues: | ||
cookies: | ||
forward: none | ||
headers: | ||
items: [] | ||
queryString: false | ||
queryStringCacheKeys: {} | ||
functionAssociations: {} | ||
lambdaFunctionAssociations: {} | ||
maxTTL: 600 | ||
minTTL: 0 | ||
smoothStreaming: false | ||
targetOriginID: crossplane.io | ||
trustedKeyGroups: | ||
enabled: false | ||
trustedSigners: | ||
enabled: false | ||
viewerProtocolPolicy: allow-all | ||
defaultRootObject: index.html | ||
enabled: true | ||
httpVersion: http2 | ||
isIPV6Enabled: true | ||
logging: | ||
bucket: '' | ||
enabled: false | ||
includeCookies: false | ||
prefix: '' | ||
originGroups: {} | ||
origins: | ||
items: | ||
- connectionAttempts: 3 | ||
connectionTimeout: 10 | ||
customHeaders: {} | ||
customOriginConfig: | ||
httpPort: 8080 | ||
httpSPort: 443 | ||
originKeepaliveTimeout: 5 | ||
originProtocolPolicy: http-only | ||
originReadTimeout: 10 | ||
originSSLProtocols: | ||
items: | ||
- TLSv1 | ||
- TLSv1.1 | ||
- TLSv1.2 | ||
domainName: crossplane.io | ||
id: crossplane.io | ||
originShield: | ||
enabled: false | ||
priceClass: PriceClass_200 | ||
restrictions: | ||
geoRestriction: | ||
restrictionType: none | ||
region: ap-northeast-2 | ||
providerConfigRef: | ||
name: crossplane | ||
status: | ||
conditions: | ||
- lastTransitionTime: "2024-01-11T06:23:18Z" | ||
reason: ReconcileSuccess | ||
status: "True" | ||
type: Synced | ||
- lastTransitionTime: "2024-01-10T03:23:02Z" | ||
reason: Available | ||
status: "True" | ||
type: Ready |
92 changes: 92 additions & 0 deletions
92
resource_customizations/cloudfront.aws.crossplane.io/Distribution/testdata/progressing.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
apiVersion: cloudfront.aws.crossplane.io/v1alpha1 | ||
kind: Distribution | ||
metadata: | ||
creationTimestamp: '2023-06-16T04:42:04Z' | ||
generation: 37 | ||
name: crossplane.io | ||
resourceVersion: '254326453' | ||
uid: fd357670-b762-4285-ae83-00859c40dd6b | ||
spec: | ||
deletionPolicy: Orphan | ||
forProvider: | ||
distributionConfig: | ||
comment: 'crossplane' | ||
customErrorResponses: | ||
items: [] | ||
defaultCacheBehavior: | ||
allowedMethods: | ||
cachedMethods: | ||
items: | ||
- HEAD | ||
- GET | ||
items: | ||
- GET | ||
- HEAD | ||
compress: false | ||
defaultTTL: 600 | ||
fieldLevelEncryptionID: "" | ||
forwardedValues: | ||
cookies: | ||
forward: none | ||
headers: | ||
items: [] | ||
queryString: false | ||
queryStringCacheKeys: {} | ||
functionAssociations: {} | ||
lambdaFunctionAssociations: {} | ||
maxTTL: 600 | ||
minTTL: 0 | ||
smoothStreaming: false | ||
targetOriginID: crossplane.io | ||
trustedKeyGroups: | ||
enabled: false | ||
trustedSigners: | ||
enabled: false | ||
viewerProtocolPolicy: allow-all | ||
defaultRootObject: index.html | ||
enabled: true | ||
httpVersion: http2 | ||
isIPV6Enabled: true | ||
logging: | ||
bucket: "" | ||
enabled: false | ||
includeCookies: false | ||
prefix: "" | ||
originGroups: {} | ||
origins: | ||
items: | ||
- connectionAttempts: 3 | ||
connectionTimeout: 10 | ||
customHeaders: {} | ||
customOriginConfig: | ||
httpPort: 8080 | ||
httpSPort: 443 | ||
originKeepaliveTimeout: 5 | ||
originProtocolPolicy: http-only | ||
originReadTimeout: 10 | ||
originSSLProtocols: | ||
items: | ||
- TLSv1 | ||
- TLSv1.1 | ||
- TLSv1.2 | ||
domainName: crossplane.io | ||
id: crossplane.io | ||
originShield: | ||
enabled: false | ||
priceClass: PriceClass_200 | ||
restrictions: | ||
geoRestriction: | ||
restrictionType: none | ||
region: ap-northeast-2 | ||
providerConfigRef: | ||
name: crossplane | ||
status: | ||
conditions: | ||
- lastTransitionTime: '2024-01-11T08:11:27Z' | ||
reason: Unavailable | ||
status: 'False' | ||
type: Ready | ||
- lastTransitionTime: '2024-01-11T08:11:02Z' | ||
reason: ReconcileSuccess | ||
status: 'True' | ||
type: Synced |
Oops, something went wrong.