Skip to content

Commit

Permalink
feat(argo): more configuration options and generic git sync via matrix (
Browse files Browse the repository at this point in the history
#29)

Signed-off-by: Christopher Haar <[email protected]>
  • Loading branch information
haarchri authored Mar 6, 2024
1 parent 1e2d624 commit d3272b9
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 19 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/yamllint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: yamllint
on: [pull_request]
jobs:
yamllint:
name: runner / yamllint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
- name: yamllint
uses: reviewdog/action-yamllint@e419e43894e391d358ebf996800673d72de6c69b # v1.11.0
with:
reporter: github-pr-review
filter_mode: nofilter
yamllint_flags: 'apis/'
fail_on_error: true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ UPTEST_VERSION = v0.11.1
# ====================================================================================
# Setup XPKG
XPKG_DIR = $(shell pwd)
XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml,test/provider/*.yaml
XPKG_IGNORE = .github/workflows/*.yaml,.github/workflows/*.yml,examples/*.yaml,.work/uptest-datasource.yaml,test/provider/*.yaml,gitops/*.yaml
XPKG_REG_ORGS ?= xpkg.upbound.io/upbound
# NOTE(hasheddan): skip promoting on xpkg.upbound.io as channel tags are
# inferred.
Expand Down
73 changes: 59 additions & 14 deletions apis/composition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,32 @@ spec:
message = "Provisioning ..."
}
local function contains (table, val)
for i, v in ipairs(table) do
if v == val then
return true
end
end
return false
end
local has_no_status = {
"ProviderConfig",
"ProviderConfigUsage"
}
if obj.status == nil and contains(has_no_status, obj.kind) then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
if obj.status == nil or obj.status.conditions == nil then
if obj.kind == "ProviderConfig" and obj.status.users ~= nil then
health_status.status = "Healthy"
health_status.message = "Resource is in use."
return health_status
end
return health_status
end
Expand Down Expand Up @@ -101,6 +126,27 @@ spec:
message = "Provisioning ..."
}
local function contains (table, val)
for i, v in ipairs(table) do
if v == val then
return true
end
end
return false
end
local has_no_status = {
"Composition",
"CompositionRevision",
"DeploymentRuntimeConfig",
"ControllerConfig"
}
if obj.status == nil and contains(has_no_status, obj.kind) then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
return health_status
end
if obj.status == nil or obj.status.conditions == nil then
return health_status
end
Expand All @@ -122,7 +168,7 @@ spec:
end
end
if condition.type == "Ready" then
if contains({"Ready", "Healthy", "Offered", "Established"}, condition.type) then
if condition.status == "True" then
health_status.status = "Healthy"
health_status.message = "Resource is up-to-date."
Expand All @@ -132,11 +178,6 @@ spec:
end
return health_status
resource.exclusions: |
- kinds:
- ProviderConfigUsage
apiGroups:
- "*"
params:
application.namespaces: cluster-*
controller:
Expand Down Expand Up @@ -204,6 +245,12 @@ spec:
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.oidcConfig
toFieldPath: spec.forProvider.values.server.config[oidc.config]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.resourceInclusions
toFieldPath: spec.forProvider.values.configs.cm[resource.inclusions]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.resourceExclusions
toFieldPath: spec.forProvider.values.configs.cm[resource.exclusions]
- type: FromCompositeFieldPath
fromFieldPath: spec.parameters.operators.argocd.version
toFieldPath: spec.forProvider.chart.version
Expand Down Expand Up @@ -247,14 +294,12 @@ spec:
spec:
destination:
namespace: '{{.namespace}}'
server: https://kubernetes.default.svc
project: default
sources:
- chart: '{{.chart}}'
helm:
releaseName: '{{.releaseName}}'
repoURL: '{{.repoUrl}}'
targetRevision: '{{.version}}'
server: '{{.server}}'
project: '{{.project}}'
source:
repoURL: '{{.repoUrl}}'
targetRevision: '{{.version}}'
path: '{{.folder}}'
syncPolicy:
automated:
selfHeal: true
Expand Down
6 changes: 6 additions & 0 deletions apis/definition.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ spec:
oidcConfig:
type: string
description: set oidc config for argocd server
resourceInclusions:
type: string
description: configure the list of included resources
resourceExclusions:
type: string
description: configure the list of exclude resources
deletionPolicy:
description: Delete the external resources when the Claim/XR is deleted. Defaults to Delete
enum:
Expand Down
30 changes: 26 additions & 4 deletions examples/argocd-xr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,39 @@ metadata:
spec:
parameters:
# this configuration is needed if you want to configure argocd with oidc
# ingressUrl: argocd-platform-ref-aws-cnoe.upboundrocks.cloud
# ingressUrl: configuration-gitops-argocd.example.com
# oidcConfig: |
# name: Keycloak
# issuer: https://keycloak-platform-ref-aws-cnoe.upboundrocks.cloud/realms/master
# issuer: https://configuration-gitops-argocd.example.com/realms/master
# clientID: argocd
# clientSecret: 0000000000000000000
# requestedScopes: ['openid', 'profile', 'email', 'groups']
resourceExclusions: |
- kinds:
- ProviderConfigUsage
apiGroups:
- "*"
- kinds:
- "Nodes"
apiGroups:
- "*"
clusters:
- "ctp-*"
resourceInclusions: |
- apiGroups:
- "*"
kinds:
- Provider
- Function
- Configuration
- CompositeResourceDefinition
- Composition
clusters:
- "ctp-*"
providerConfigName: configuration-gitops-argocd
source:
git:
url: https://github.com/haarchri/gitops-argocd.git
path: configuration-gitops-argocd/infrastructure.yaml
url: https://github.com/upbound/configuration-gitops-argocd.git
path: gitops
ref:
name: HEAD
9 changes: 9 additions & 0 deletions gitops/infrastructure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
key:
components:
- name: spaces-reference-architecture
namespace: upbound-system
server: https://kubernetes.default.svc
project: default
repoUrl: https://github.com/upbound/spaces-reference-architecture.git
version: HEAD
folder: "bootstrap/"

0 comments on commit d3272b9

Please sign in to comment.