Skip to content

Commit

Permalink
Fluxtomize with multiple levels of subdirectories (#298)
Browse files Browse the repository at this point in the history
Allow fluxtomize to process nested subdirectories

Relates to: #295
  • Loading branch information
ansarhun authored Aug 5, 2023
1 parent 1fb9d4b commit 68abd10
Show file tree
Hide file tree
Showing 13 changed files with 123 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/flux-local-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
- tests/testdata/cluster4
- tests/testdata/cluster5
- tests/testdata/cluster6
- tests/testdata/cluster7
resource:
- helmrelease
- kustomization
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/flux-local-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ jobs:
- tests/testdata/cluster5
- tests/testdata/cluster4
- tests/testdata/cluster6
- tests/testdata/cluster7
steps:
- uses: actions/checkout@v3
- uses: ./action/test
Expand Down
2 changes: 1 addition & 1 deletion flux_local/kustomize.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ async def fluxtomize(path: Path) -> bytes:
filenames.sort()
for filename in filenames:
new_path = path / filename
if new_path.is_dir() and await can_kustomize_dir(new_path):
if new_path.is_dir():
tasks.append(build(new_path).objects())
elif filename.endswith(".yaml") or filename.endswith(".yml"):
tasks.append(yaml_load_all(new_path))
Expand Down
15 changes: 15 additions & 0 deletions tests/testdata/cluster7/clusters/home/apps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: apps
namespace: flux-system
spec:
interval: 10m0s
path: ./tests/testdata/cluster7/flux/apps
prune: true
dependsOn:
- name: charts
sourceRef:
kind: GitRepository
name: flux-system
13 changes: 13 additions & 0 deletions tests/testdata/cluster7/clusters/home/charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: charts
namespace: flux-system
spec:
interval: 10m0s
path: ./tests/testdata/cluster7/flux/charts
prune: true
sourceRef:
kind: GitRepository
name: flux-system
27 changes: 27 additions & 0 deletions tests/testdata/cluster7/clusters/home/flux-system/gotk-sync.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# This manifest was generated by flux. DO NOT EDIT.
---
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 1m0s
ref:
branch: master
secretRef:
name: flux-system
url: ssh://[email protected]/allenporter/flux-local
---
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
name: flux-system
namespace: flux-system
spec:
interval: 10m0s
path: ./tests/testdata/cluster7/clusters/home
prune: true
sourceRef:
kind: GitRepository
name: flux-system
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- gotk-sync.yaml
7 changes: 7 additions & 0 deletions tests/testdata/cluster7/flux/apps/database/namespace.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: database
labels:
kustomize.toolkit.fluxcd.io/prune: disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
apiVersion: helm.toolkit.fluxcd.io/v2beta1
kind: HelmRelease
metadata:
name: postgresql
namespace: database
spec:
interval: 15m
chart:
spec:
chart: postgresql
version: 12.7.1
sourceRef:
kind: HelmRepository
name: bitnami-charts
namespace: flux-system
10 changes: 10 additions & 0 deletions tests/testdata/cluster7/flux/charts/bitnami-charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: source.toolkit.fluxcd.io/v1beta2
kind: HelmRepository
metadata:
name: bitnami-charts
namespace: flux-system
spec:
type: oci
interval: 5m
url: oci://registry-1.docker.io/bitnamicharts
8 changes: 8 additions & 0 deletions tests/tool/testdata/get_cluster7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
args:
- get
- cluster
- --path
- tests/testdata/cluster7/
stdout: |
NAME PATH KUSTOMIZATIONS
flux-system ./tests/testdata/cluster7/clusters/home 3
9 changes: 9 additions & 0 deletions tests/tool/testdata/get_hr7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
args:
- get
- hr
- -A
- --path
- tests/testdata/cluster7
stdout: |
NAMESPACE NAME REVISION CHART SOURCE
database postgresql 12.7.1 database-postgresql bitnami-charts
10 changes: 10 additions & 0 deletions tests/tool/testdata/get_ks7.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
args:
- get
- ks
- --path
- tests/testdata/cluster7
stdout: |
NAME PATH
apps tests/testdata/cluster7/flux/apps
charts tests/testdata/cluster7/flux/charts
flux-system tests/testdata/cluster7/clusters/home

0 comments on commit 68abd10

Please sign in to comment.