Skip to content

Commit

Permalink
[Addon]: add fluxcd kustomize healthcheck
Browse files Browse the repository at this point in the history
  • Loading branch information
卢永杰 committed Apr 24, 2023
1 parent e011c70 commit 210c273
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
58 changes: 57 additions & 1 deletion addons/fluxcd/definitions/kustomize.cue
Original file line number Diff line number Diff line change
@@ -1,5 +1,61 @@
kustomize: {
attributes: workload: type: "autodetects.core.oam.dev"
attributes:{
workload: type: "autodetects.core.oam.dev"
status: {
healthPolicy: #"""
isHealth: len(context.output.status.conditions) != 0 && context.output.status.conditions[0]["reason"]=="ReconciliationSucceeded" && context.output.status.conditions[0]["type"]=="Ready" && context.output.status.conditions[0]["status"] == "True"
"""#
customStatus: #"""
repoMessage: *"" | string
kustMessage: *"Wating repository ready" | string
if context.outputs.repo == _|_ {
repoMessage: "Use existed repository"
}
if context.outputs.repo != _|_ && context.outputs.repo.status == _|_ {
repoMessage: "Fetching repository"
}
if context.outputs.repo != _|_ && context.outputs.repo.status != _|_ && context.outputs.repo.status.conditions != _|_ {
repoStatus: context.outputs.repo.status
if len(repoStatus.conditions) != 0 && repoStatus.conditions[0]["reason"] != "Succeeded" {
lastMessage: repoStatus.conditions[0].message
if len(repoStatus.conditions)>1{
repoMessage : repoStatus.conditions[1].message + ", " + lastMessage
}
}
if len(repoStatus.conditions) != 0 && repoStatus.conditions[0]["reason"] == "Succeeded" {
repoMessage: repoStatus.conditions[0].message
}
}
if context.output.status == _|_ {
kustMessage: "Creating git repo"
}
if context.output.status != _|_ {
kustStatus: context.output.status
if kustStatus.conditions != _|_ {
if len(kustStatus.conditions) > 0 {
if kustStatus.conditions[0]["type"] != _|_ && kustStatus.conditions[0]["message"] != _|_ {
if kustStatus.conditions[0]["reason"] == "ReconciliationSucceeded"{
kustMessage: "Create kustomize successfully"
}
if kustStatus.conditions[0]["message"] != "ReconciliationSucceeded" {
kustBasicMessage: "Delivery git kustomize in progress, message: " + kustStatus.conditions[0]["message"]
if len(kustStatus.conditions) == 1 {
kustMessage: kustBasicMessage
}
if len(kustStatus.conditions) > 1 {
if kustStatus.conditions[1]["message"] != _|_ {
kustMessage: kustBasicMessage + ", " + kustStatus.conditions[1]["message"]
}
}
}
}
}
}
}
message: repoMessage + ", " + kustMessage
"""#
}
}
description: "kustomize can fetching, building, updating and applying Kustomize manifests from Git repo or Bucket or OCI repo."
type: "component"
annotations: {
Expand Down
2 changes: 1 addition & 1 deletion addons/fluxcd/metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: fluxcd
version: 2.3.4
version: 2.3.5
description: Extended workload to do continuous and progressive delivery
icon: https://raw.githubusercontent.com/cncf/artwork/master/projects/flux/horizontal/color/flux-horizontal-color.png
url: https://fluxcd.io
Expand Down

0 comments on commit 210c273

Please sign in to comment.