1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-14 11:37:37 +00:00
Commit graph

54 commits

Author SHA1 Message Date
Antonio Gurgel
27b06c5798 Implement lib.gatherNamespaces
The documentation for pkgs.lib.lists.unique warned me that the function
is O(n^2). So I conducted some rather unscientific tests using my own
Kubernetes flake and found no noticeable time penalty:
`rm result && nix-collect-garbage -d && nix build` always took
between 37 and 40 seconds, with or without gatherNamespaces.
But, well, n=10.

Also, make more obvious the flaw in mk.namespaces.
If I prefix something with "N.B." it shouldn't be hidden in the code.
2023-12-07 00:03:08 -08:00
Antonio Gurgel
96ab10c070 Document flattenTree better 2023-12-06 22:59:39 -08:00
Antonio Gurgel
9e7bac64c8 Move app-template back to lib
This interface was getting ridiculous.

`app-template` gets released infrequently enough that keeping a static
`chart.nix` is a small tradeoff for the previous lunacy of passing a
whole derivation tree in through the flake.
2023-12-05 22:46:47 -08:00
Antonio Gurgel
a32b24c69a Lift only modules named default
Otherwise `services/default` obliterates everything at its level.
2023-12-04 22:57:52 -08:00
Antonio Gurgel
0f7f384137 Create mkChartsWithNixhelm; export appT 2023-12-03 23:03:36 -08:00
Antonio Gurgel
3a6246ab83 Final refactor
Make flake importable at top level.
Move app-template to `./src`, removing `charts` from `./lib`.
Clean up unused bits elsewhere.
2023-12-03 21:45:40 -08:00
Antonio Gurgel
6907ae7373 Clean up 2023-12-03 21:29:15 -08:00
Antonio Gurgel
ec3276b493 Truck in user data from own flake
Same rationale as 0790be8.
2023-12-03 20:03:13 -08:00
Antonio Gurgel
97dbdec7f7 Re-implement service-builder
`apiVersions` gave me a headache while writing the foldl so I made it
a separate input.

Now the service modules have this signature, without my having to
change any code in the modules themselves:

{charts, etc, ...} -> [apiVersion] -> {out, extra}
2023-12-03 19:58:28 -08:00
Antonio Gurgel
6b97777fe9 Typo 2023-12-03 18:02:47 -08:00
Antonio Gurgel
6bbd867da3 Experimentally implement mkStages 2023-12-03 18:01:06 -08:00
Antonio Gurgel
797ae401ae Truck in haumea 2023-12-03 17:07:21 -08:00
Antonio Gurgel
70fae512d1 Refactor crisis
Two imperfections have come to bite me simultaneously:
- I wanted strict ordering of services but implemented it very sloppily.
- The flake builders represent implementation leakage. I want to present
  a clean interface to users, not "first, you must evaluate these
  twenty-eight variables".

So now I'm fixing too many things at once. Luckily it's hard to lose
things in Git.
2023-11-29 23:06:13 -08:00
Antonio Gurgel
742612a9d7 rm alwaysList
https://github.com/farcaller/nix-kube-generators/pull/6
2023-11-27 11:40:13 -08:00
Antonio Gurgel
bc64f70610 Remove everything specific to my cluster 2023-11-26 23:41:14 -08:00
Antonio Gurgel
ffc18857a5 Export lib.rake 2023-11-26 22:38:11 -08:00
Antonio Gurgel
021d366351 Forcibly set namespace on all Helm charts 2023-11-26 13:39:16 -08:00
Antonio Gurgel
dc3060aa30 Pass charts into releases, and restore variadity
It doesn't pay to be strict about release module arity.
2023-11-21 20:46:32 -08:00
Antonio Gurgel
aa1ec7d842 Don't do readFile twice
Also, I had a brief temptation to move `gatherApis` to `flake-builders`,
but apart from being used in the flake's let-in, it has little in common
with the other builders. I need to lose a direct dependency on kubelib
to try the concept out, though (`flake-builders` doesn't take `kubelib`),
and I ended up keeping the result.
2023-11-20 23:02:54 -08:00
Antonio Gurgel
16365ee3e5 Refine API-gatherer 2023-11-20 21:42:16 -08:00
Antonio Gurgel
f75c9aa476 Add API-gatherer 2023-11-20 20:51:34 -08:00
Antonio Gurgel
708e537c7c Remove verbs from lib.{build,fetch}ers.*
Reading things like `lib.builders.buildHelmChart` got exhausting.
2023-11-19 14:24:24 -08:00
Antonio Gurgel
33433a953e Build namespaces
I initially thought this would be just another release in
`releases/common/namespaces`, but there's a lot more potential
than that.
2023-11-19 13:21:41 -08:00
Antonio Gurgel
46ec341d3e Make app-template lib kebab-case
To reduce collisions with lib.eureka.appTemplate, and because
bjw-s' chart and the Nix module for it are both kebab-case.
2023-11-19 11:39:39 -08:00
Antonio Gurgel
408befb503 Decouple homelab idiosyncrasies
My long-term vision for this flake is to use it as a control flake:
plug it into your homelab ("data-plane") flake and avail yourself
of its `lib.builders`, et cetera.

In short, I want this flake to be useful to many people, and that
means not shipping my homelab with it.
2023-11-19 11:35:35 -08:00
Antonio Gurgel
7443323ebb Last bout of refactoring before bed
- Moved external ServiceEntry generator to `lib.resources`.
- Gave it some company: a generator of HTTPRoutes for gateway/svc.
- Gave `lib.vars.svcGateway` a parentRef generator, at the cost of
  another level of recursion, and some variable renaming.
2023-11-18 23:45:45 -08:00
Antonio Gurgel
2c213d6222 Factor out (and document exhaustively) flake-builders 2023-11-18 23:13:11 -08:00
Antonio Gurgel
f62420754a Lower all of lib's imports into named attrs
The namespace was getting a bit crowded.
2023-11-18 22:38:17 -08:00
Antonio Gurgel
18b3cbfe84 Remove kubelib as release input; rm buildYAMLStream synonym
Everything I need directly from nix-kube-generators is now
handled in `lib/`. Additionally, now that I know buildYAMLStream always
takes a namespace and name, there's no need for the longer-winded name.
2023-11-18 22:21:08 -08:00
Antonio Gurgel
367851267f Split fetchers and builders; create NamespacedYAML builder
The reason I struggled with genericBuilders, and again when I replaced
`remoteYAML`'s NS-name `pname` with `url`, is that I was confusing the
following two things:
1. Things that fetch a resource (a Helm chart, a YAML stream, etc.)
without naming or namespacing it.
2. Things that create a release _by_ giving it a name and namespace
so that lib/output.sh can sort the resultant files into directories.

Additionally, I was questioning the good sense of releases/svc/gateway:
a release with no release, but only extra objects? Turns out I
needlessly bound the concept of JIT namespace injection to that
`extraObjects` feature. Once I abstracted that builder, the more general
solution became clear.
2023-11-18 22:01:43 -08:00
Antonio Gurgel
666f822bc1 Get rid of genericBuilder; use URLs in drvs of fetched charts
genericBuilder didn't make much sense to begin with.
2023-11-18 20:44:45 -08:00
Antonio Gurgel
c02685125d Move gitChart back to lib/builders
I probably took it out because I struggled with fitting it into
genericBuilder, but gitChart really does belong there.
2023-11-18 20:24:13 -08:00
Antonio Gurgel
e6ef6e90ef Factor out Istio ServiceEntries
I have a handful in my cluster, and they're all lists of HTTPS domains.
2023-11-18 20:12:17 -08:00
Antonio Gurgel
9d888486c1 Learn recursive updates
Turns out `//` is more destructive than I thought. With it,
I was wiping `metadata` of everything but the `namespace` key.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
b51bcafdaf Implement attaching extra k8s objects to releases
No more tossing YAMLs into release dirs. All is Nix.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
11a3fcb002 Refactor modules
By declaring builders at the module level, only to call them in
flake.nix, I give myself the opportunity to inject `{name, namespace}`
there and need no longer pass these args into every module myself.
2023-11-18 19:22:25 -08:00
Antonio Gurgel
e0907193ba rm lib.getValues
I'm no longer doing Helm values in YAML.
2023-11-18 14:25:39 -08:00
Antonio Gurgel
05604660ea Factor out app-template HTTPRoutes 2023-11-18 02:09:30 -08:00
Antonio Gurgel
1b63b4bda1 Refactor lib/
NixOS configs taught me wrong; `imports=[]` is not a magic sequence.
But because `lib/default.nix` returns an attrset, I can use attrset
mechanics on it.
2023-11-18 01:55:21 -08:00
Antonio Gurgel
293b4da857 Factor out a generic builder
This definitely wasn't a ridiculous amount of premature optimization...
2023-11-16 21:51:57 -08:00
Antonio Gurgel
cb4dda1812 Hopefully the last format-only commit 2023-11-16 21:31:26 -08:00
Antonio Gurgel
924cf69fb8 Create lib.gitChart
That was easy.
2023-11-16 21:20:58 -08:00
Antonio Gurgel
e6ee6049bf Import upstream fix for fromYAML 2023-11-16 20:29:32 -08:00
Antonio Gurgel
88bd864322 Include ns/name in derivations 2023-11-16 18:40:20 -08:00
Antonio Gurgel
1826882c13 Factor out values-gathering 2023-11-15 18:34:32 -08:00
Antonio Gurgel
e99474e22b Use pname in yamlFile
Instead of recooking derivation names.
2023-11-15 16:50:32 -08:00
Antonio Gurgel
bef2c80e9f Make release tree itself an output
I was puzzling over how to cobble all these derivations into one
mega-derivation, but I might not have to.
2023-11-15 16:44:34 -08:00
Antonio Gurgel
d26e1356de Create lib.yamlBundle
rakeLeaves moved to a separate module so that it still won't require
`pkgs`, which would pull it into `eachDefaultSystem`.
2023-11-15 15:37:28 -08:00
Antonio Gurgel
a0bec492c0 DRY and explain dirToAttrs 2023-11-15 10:56:50 -08:00
Antonio Gurgel
a2abba2889 Ascend to godlike levels of genericness
charts/ and src/ both have two levels of children:
- charts/$repo/$chart
- src/$ns/$release

So, why not use one function to rake them both?

Also, the leaf-raking doesn't require nixpkgs or nix-kube-generators so
I moved everything that does (e.g.: `downloadCharts`) into the
`eachDefaultSystem` part of the output, following the example of
nixhelm's flake.
2023-11-15 01:36:46 -08:00