-
Notifications
You must be signed in to change notification settings - Fork 829
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3484 from yike21/bundle-fluxcd-HelmRepository
add customizations for source.toolkit.fluxcd.io/v1beta2/HelmRepository
- Loading branch information
Showing
4 changed files
with
201 additions
and
0 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
...esourcecustomizations/source.toolkit.fluxcd.io/v1beta2/HelmRepository/customizations.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,104 @@ | ||
apiVersion: config.karmada.io/v1alpha1 | ||
kind: ResourceInterpreterCustomization | ||
metadata: | ||
name: declarative-configuration-helmrepository | ||
spec: | ||
target: | ||
apiVersion: source.toolkit.fluxcd.io/v1beta2 | ||
kind: HelmRepository | ||
customizations: | ||
healthInterpretation: | ||
luaScript: > | ||
function InterpretHealth(observedObj) | ||
if observedObj.status ~= nil and observedObj.status.conditions ~= nil then | ||
for conditionIndex = 1, #observedObj.status.conditions do | ||
if observedObj.status.conditions[conditionIndex].type == 'Ready' and observedObj.status.conditions[conditionIndex].status == 'True' and observedObj.status.conditions[conditionIndex].reason == 'Succeeded' then | ||
return true | ||
end | ||
end | ||
end | ||
return false | ||
end | ||
statusAggregation: | ||
luaScript: > | ||
function AggregateStatus(desiredObj, statusItems) | ||
if statusItems == nil then | ||
return desiredObj | ||
end | ||
desiredObj.status = {} | ||
desiredObj.status.conditions = {} | ||
conditions = {} | ||
local conditionsIndex = 1 | ||
for i = 1, #statusItems do | ||
if statusItems[i].status ~= nil and statusItems[i].status.artifact ~= nil then | ||
desiredObj.status.artifact = statusItems[i].status.artifact | ||
end | ||
if statusItems[i].status ~= nil and statusItems[i].status.lastHandledReconcileAt ~= nil and statusItems[i].status.lastHandledReconcileAt ~= '' then | ||
desiredObj.status.lastHandledReconcileAt = statusItems[i].status.lastHandledReconcileAt | ||
end | ||
if statusItems[i].status ~= nil and statusItems[i].status.url ~= nil and statusItems[i].status.url ~= '' then | ||
desiredObj.status.url = statusItems[i].status.url | ||
end | ||
if statusItems[i].status ~= nil and statusItems[i].status.conditions ~= nil then | ||
for conditionIndex = 1, #statusItems[i].status.conditions do | ||
statusItems[i].status.conditions[conditionIndex].message = statusItems[i].clusterName..'='..statusItems[i].status.conditions[conditionIndex].message | ||
hasCondition = false | ||
for index = 1, #conditions do | ||
if conditions[index].type == statusItems[i].status.conditions[conditionIndex].type and conditions[index].status == statusItems[i].status.conditions[conditionIndex].status and conditions[index].reason == statusItems[i].status.conditions[conditionIndex].reason then | ||
conditions[index].message = conditions[index].message..', '..statusItems[i].status.conditions[conditionIndex].message | ||
hasCondition = true | ||
break | ||
end | ||
end | ||
if not hasCondition then | ||
conditions[conditionsIndex] = statusItems[i].status.conditions[conditionIndex] | ||
conditionsIndex = conditionsIndex + 1 | ||
end | ||
end | ||
end | ||
end | ||
desiredObj.status.observedGeneration = desiredObj.metadata.generation | ||
desiredObj.status.conditions = conditions | ||
return desiredObj | ||
end | ||
retention: | ||
luaScript: > | ||
function Retain(desiredObj, observedObj) | ||
if observedObj.spec.suspend ~= nil then | ||
desiredObj.spec.suspend = observedObj.spec.suspend | ||
end | ||
return desiredObj | ||
end | ||
statusReflection: | ||
luaScript: > | ||
function ReflectStatus (observedObj) | ||
status = {} | ||
if observedObj == nil or observedObj.status == nil then | ||
return status | ||
end | ||
status.conditions = observedObj.status.conditions | ||
status.artifact = observedObj.status.artifact | ||
status.url = observedObj.status.url | ||
status.lastHandledReconcileAt = observedObj.status.lastHandledReconcileAt | ||
return status | ||
end | ||
dependencyInterpretation: | ||
luaScript: > | ||
function GetDependencies(desiredObj) | ||
dependentSecrets = {} | ||
refs = {} | ||
local idx = 1 | ||
if desiredObj.spec.secretRef ~= nil and desiredObj.spec.secretRef.name ~= '' then | ||
dependentSecrets[desiredObj.spec.secretRef.name] = true | ||
end | ||
for key, value in pairs(dependentSecrets) do | ||
dependObj = {} | ||
dependObj.apiVersion = 'v1' | ||
dependObj.kind = 'Secret' | ||
dependObj.name = key | ||
dependObj.namespace = desiredObj.metadata.namespace | ||
refs[idx] = dependObj | ||
idx = idx + 1 | ||
end | ||
return refs | ||
end |
10 changes: 10 additions & 0 deletions
10
...ions/source.toolkit.fluxcd.io/v1beta2/HelmRepository/testdata/desired-helmrepository.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,10 @@ | ||
apiVersion: source.toolkit.fluxcd.io/v1beta2 | ||
kind: HelmRepository | ||
metadata: | ||
name: podinfo | ||
namespace: test-helmrepository | ||
spec: | ||
interval: 5m0s | ||
url: https://stefanprodan.github.io/podinfo | ||
secretRef: | ||
name: fake-secret |
36 changes: 36 additions & 0 deletions
36
...ons/source.toolkit.fluxcd.io/v1beta2/HelmRepository/testdata/observed-helmrepository.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,36 @@ | ||
apiVersion: source.toolkit.fluxcd.io/v1beta2 | ||
kind: HelmRepository | ||
metadata: | ||
name: podinfo | ||
namespace: test-helmrepository | ||
spec: | ||
interval: 5m0s | ||
provider: generic | ||
timeout: 60s | ||
url: https://stefanprodan.github.io/podinfo | ||
secretRef: | ||
name: fake-secret | ||
suspend: true | ||
status: | ||
artifact: | ||
digest: sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69 | ||
lastUpdateTime: "2023-04-29T09:30:31Z" | ||
path: helmrepository/test-helmrepository/sample/index-61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69.yaml | ||
revision: sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69 | ||
size: 42012 | ||
url: http://source-controller.flux-system.svc.cluster.local./helmrepository/test-helmrepository/sample/index-61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69.yaml | ||
conditions: | ||
- lastTransitionTime: "2023-04-29T09:30:31Z" | ||
message: 'stored artifact: revision ''sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69''' | ||
observedGeneration: 1 | ||
reason: Succeeded | ||
status: "True" | ||
type: Ready | ||
- lastTransitionTime: "2023-04-29T09:30:31Z" | ||
message: 'stored artifact: revision ''sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69''' | ||
observedGeneration: 1 | ||
reason: Succeeded | ||
status: "True" | ||
type: ArtifactInStorage | ||
observedGeneration: 1 | ||
url: http://source-controller.flux-system.svc.cluster.local./helmrepository/test-helmrepository/sample/index.yaml |
51 changes: 51 additions & 0 deletions
51
...ecustomizations/source.toolkit.fluxcd.io/v1beta2/HelmRepository/testdata/status-file.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,51 @@ | ||
applied: true | ||
clusterName: member1 | ||
health: Healthy | ||
status: | ||
artifact: | ||
digest: sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69 | ||
lastUpdateTime: "2023-04-29T09:30:31Z" | ||
path: helmrepository/test-helmrepository/sample/index-61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69.yaml | ||
revision: sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69 | ||
size: 42012 | ||
url: http://source-controller.flux-system.svc.cluster.local./helmrepository/test-helmrepository/sample/index-61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69.yaml | ||
conditions: | ||
- lastTransitionTime: "2023-04-29T09:30:31Z" | ||
message: 'stored artifact: revision ''sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69''' | ||
observedGeneration: 1 | ||
reason: Succeeded | ||
status: "True" | ||
type: Ready | ||
- lastTransitionTime: "2023-04-29T09:30:31Z" | ||
message: 'stored artifact: revision ''sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69''' | ||
observedGeneration: 1 | ||
reason: Succeeded | ||
status: "True" | ||
type: ArtifactInStorage | ||
url: http://source-controller.flux-system.svc.cluster.local./helmrepository/test-helmrepository/sample/index.yaml | ||
--- | ||
applied: true | ||
clusterName: member3 | ||
health: Healthy | ||
status: | ||
artifact: | ||
digest: sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69 | ||
lastUpdateTime: "2023-04-29T09:30:33Z" | ||
path: helmrepository/test-helmrepository/sample/index-61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69.yaml | ||
revision: sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69 | ||
size: 42012 | ||
url: http://source-controller.flux-system.svc.cluster.local./helmrepository/test-helmrepository/sample/index-61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69.yaml | ||
conditions: | ||
- lastTransitionTime: "2023-04-29T09:30:33Z" | ||
message: 'stored artifact: revision ''sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69''' | ||
observedGeneration: 1 | ||
reason: Succeeded | ||
status: "True" | ||
type: Ready | ||
- lastTransitionTime: "2023-04-29T09:30:33Z" | ||
message: 'stored artifact: revision ''sha256:61f94c20ee9417f222c3d30672724473ae50d406c8c097d80a8a6263c1384f69''' | ||
observedGeneration: 1 | ||
reason: Succeeded | ||
status: "True" | ||
type: ArtifactInStorage | ||
url: http://source-controller.flux-system.svc.cluster.local./helmrepository/test-helmrepository/sample/index.yaml |