allenporter / flux-local

flux-local is a set of tools and libraries for managing a local flux gitops repository focused on validation steps to help improve quality of commits, PRs, and general local testing.
https://allenporter.github.io/flux-local/
Apache License 2.0
137 stars 22 forks source link

Problem with external gitRepository #753

Open yotles opened 2 months ago

yotles commented 2 months ago

@allenporter First of all thank you for such amazing tool! At first glance it could to resolve a lot of my issues during work with flux and gitops scheme.

But I cannot find the way to work properly. I have more or less standart platform admin repo with name conf:

tree conf
├── apps
│   ├── dev
│   └── prod
├── archived
│   ├── dev
│   └── prod
├── clusters
│   ├── dev
│   └── prod
└── infrastructure
    ├── archived
    ├── dev
    └── prod

And kustomizations within flux-system accessible ok with --sources:

flux-local  get ks --path ./clusters/dev --source flux-system
NAME              PATH
apps              apps/dev
flux-system       clusters/dev
infrastructure    infrastructure/dev

But I cannot figure out how to get work it with app which configured with external git repository. My manifests:

cat ./infrastructure/dev/app1/gitrepository/kustomize.yaml
apiVersion: kustomize.toolkit.fluxcd.io/v1
kind: Kustomization
metadata:
  name: app1
  namespace: app1
spec:
  interval: 1m0s
  path: ./base
  prune: true
  sourceRef:
    kind: GitRepository
    name: app1
    namespace: app1
  serviceAccountName: app1

cat ./infrastructure/dev/app1/gitrepository/git.yaml
apiVersion: source.toolkit.fluxcd.io/v1
kind: GitRepository
metadata:
  name: app1
  namespace: app1
spec:
  interval: 1m0s
  ref:
    branch: dev
  secretRef:
    name: flux-deploy-app1
  url: https://gitlab.xxx.xxx/okd/apps/infrastructure/app1.git

Such repository saved with path:

apps/infrastructure/app1/

base
├── imagestream
├── secrets
├── values
└── vault

And what I get:

 flux-local get ks --path ./infrastructure/dev/app1 --source app1
flux-local error:  Kustomization 'app1/app1-kustomization' path field 'base' is not a directory: /conf/base

but in my case /conf/base is not correct path, in some way it should look into apps/infrastructure/app1/base. Could you please clarify is it possible to work with flux-local in such manner?

Thanks!

allenporter commented 2 months ago

Yes, this is not currently supported, as the tool will not go out and clone external repos. You may be able to get something working by cloning the external repos yourself and using the --sources flag (details) to map the name of a git repo source to a local path.