nyl 0.7.0__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nyl-0.7.2/.changelog/0.7.1.toml +7 -0
- nyl-0.7.2/.changelog/0.7.2.toml +31 -0
- {nyl-0.7.0 → nyl-0.7.2}/PKG-INFO +1 -1
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/changelog.md +29 -1
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/templating/components.md +1 -1
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/templating/inlining/helmcharts.md +75 -2
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/templating/inlining/overview.md +1 -1
- {nyl-0.7.0 → nyl-0.7.2}/pyproject.toml +1 -1
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/__init__.py +2 -0
- nyl-0.7.2/src/nyl/commands/add.py +118 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/template.py +2 -2
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/generator/helmchart.py +2 -1
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/__init__.py +2 -1
- {nyl-0.7.0 → nyl-0.7.2}/uv.lock +1 -1
- {nyl-0.7.0 → nyl-0.7.2}/.changelog/0.7.0.toml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/.envrc +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/.github/workflows/docker.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/.github/workflows/docs.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/.github/workflows/python.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/.github/workflows/update-flake-lock.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/.gitignore +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/README.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-cmp/Dockerfile +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-cmp/README.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-cmp/plugin.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/.envrc +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/.secrets.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/.sops.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/README.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/argocd.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/nyl-project.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/argocd-with-nyl/nyl-secrets.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/index.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/applysets.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/argocd-plugin.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/cluster-connectivity.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/configuration/environment.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/configuration/profiles.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/configuration/projects.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/configuration/secrets.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/configuration-api/profiles.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/configuration-api/secrets.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/glossary.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/templating/basics.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/templating/inlining/postprocessor.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/content/reference/templating/secrets.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/mkdocs.yml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/pyproject.toml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/docs/uv.lock +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/example/manifests/postgres.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/example/nyl-profiles.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/example/nyl-secrets.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/example/secrets.yaml +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/flake.lock +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/flake.nix +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/nix/uv.nix +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/renovate.json +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/README.md +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/__init__.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/dynamic/__init__.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/dynamic/client.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/dynamic/discovery.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/dynamic/exceptions.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/dynamic/resource.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/watch/__init__.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/kubernetes/watch/watch.pyi +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/__init__.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/argocd.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/crds.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/new.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/profile.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/run.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/secrets.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/tools/__init__.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/tools/bcrypt.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/tools/sops.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/commands/tun.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/generator/__init__.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/generator/components.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/generator/dispatch.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/generator/dispatch_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/generator/statefulsecret.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/profiles/__init__.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/profiles/config.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/profiles/config_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/profiles/kubeconfig.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/profiles/tunnel.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/project/config.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/applyset.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/applyset_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/helmchart.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/helmchart_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/placeholder.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/postprocessor.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/postprocessor_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/resources/statefulsecret.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/__init__.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/config.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/config_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/kubernetes.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/null.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/sops.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/secrets/sops_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/templating.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/templating_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/di.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/fs.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/fs_test.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/kubectl.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/kubernetes.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/kvstore.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/loads.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/logging.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/shell.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/testing.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/typer.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/types.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/src/nyl/tools/yaml.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/tests/__init__.py +0 -0
- {nyl-0.7.0 → nyl-0.7.2}/tests/conftest.py +0 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
release-date = "2025-01-17"
|
|
2
|
+
|
|
3
|
+
[[entries]]
|
|
4
|
+
id = "b7adb487-a449-49c4-8ef9-402625228b0d"
|
|
5
|
+
type = "fix"
|
|
6
|
+
description = "Fixed a bug where pulling two different charts with the same version number from the same repository conflated the cache key and ended up with Nyl using the wrong chart (that which has been pulled first)."
|
|
7
|
+
author = "@NiklasRosenstein"
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
release-date = "2025-01-17"
|
|
2
|
+
|
|
3
|
+
[[entries]]
|
|
4
|
+
id = "00755f35-1e28-4946-9cbb-eccb2735b9fb"
|
|
5
|
+
type = "feature"
|
|
6
|
+
description = "Add `nyl add namespace` command"
|
|
7
|
+
author = "@NiklasRosenstein"
|
|
8
|
+
|
|
9
|
+
[[entries]]
|
|
10
|
+
id = "1a17887c-ed8a-40a9-9ff5-11b594c20dd4"
|
|
11
|
+
type = "docs"
|
|
12
|
+
description = "Fix links in docs and add information on how to use the `HelmChart.spec.chart` field"
|
|
13
|
+
author = "@NiklasRosenstein"
|
|
14
|
+
|
|
15
|
+
[[entries]]
|
|
16
|
+
id = "3f471926-8529-4e46-8d73-41c2825a3578"
|
|
17
|
+
type = "feature"
|
|
18
|
+
description = "Add `nyl add chart` command"
|
|
19
|
+
author = "@NiklasRosenstein"
|
|
20
|
+
|
|
21
|
+
[[entries]]
|
|
22
|
+
id = "242fa8b1-225f-42f4-bf7f-fe6af806f0b5"
|
|
23
|
+
type = "docs"
|
|
24
|
+
description = "Add note to discurage from using `{{ .Release.Namespace }}` in Helm charts"
|
|
25
|
+
author = "@NiklasRosenstein"
|
|
26
|
+
|
|
27
|
+
[[entries]]
|
|
28
|
+
id = "a09f0665-99a6-4a54-b0eb-afe4f719a320"
|
|
29
|
+
type = "breaking change"
|
|
30
|
+
description = "Rename annotation `nyl.io/default-namespace` to `nyl.io/is-default-namespace`"
|
|
31
|
+
author = "@NiklasRosenstein"
|
{nyl-0.7.0 → nyl-0.7.2}/PKG-INFO
RENAMED
|
@@ -1,6 +1,34 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.7.
|
|
3
|
+
## 0.7.2 (2025-01-17)
|
|
4
|
+
|
|
5
|
+
<table><tr><th>Type</th><th>Description</th><th>PR</th><th>Issues</th><th>Author</th></tr>
|
|
6
|
+
<tr><td>Feature</td><td>
|
|
7
|
+
|
|
8
|
+
Add `nyl add namespace` command</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
|
|
9
|
+
<tr><td>Docs</td><td>
|
|
10
|
+
|
|
11
|
+
Fix links in docs and add information on how to use the `HelmChart.spec.chart` field</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
|
|
12
|
+
<tr><td>Feature</td><td>
|
|
13
|
+
|
|
14
|
+
Add `nyl add chart` command</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
|
|
15
|
+
<tr><td>Docs</td><td>
|
|
16
|
+
|
|
17
|
+
Add note to discurage from using `{{ .Release.Namespace }}` in Helm charts</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
|
|
18
|
+
<tr><td>Breaking change</td><td>
|
|
19
|
+
|
|
20
|
+
Rename annotation `nyl.io/default-namespace` to `nyl.io/is-default-namespace`</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
|
|
21
|
+
</table>
|
|
22
|
+
|
|
23
|
+
## 0.7.1 (2025-01-17)
|
|
24
|
+
|
|
25
|
+
<table><tr><th>Type</th><th>Description</th><th>PR</th><th>Issues</th><th>Author</th></tr>
|
|
26
|
+
<tr><td>Fix</td><td>
|
|
27
|
+
|
|
28
|
+
Fixed a bug where pulling two different charts with the same version number from the same repository conflated the cache key and ended up with Nyl using the wrong chart (that which has been pulled first).</td><td></td><td></td><td>@NiklasRosenstein</td></tr>
|
|
29
|
+
</table>
|
|
30
|
+
|
|
31
|
+
## 0.7.0 (2025-01-17)
|
|
4
32
|
|
|
5
33
|
<table><tr><th>Type</th><th>Description</th><th>PR</th><th>Issues</th><th>Author</th></tr>
|
|
6
34
|
<tr><td>Breaking change</td><td>
|
|
@@ -8,7 +8,7 @@ Nyl components are effectively templates that you can instantiate them similar t
|
|
|
8
8
|
are treated in a way similar to CRDs, only that they will never to pushed to the Kubernetes API server and instead be
|
|
9
9
|
replaced throuhg a first reconcilation phase during `nyl template`.
|
|
10
10
|
|
|
11
|
-
Components are built on top of Helm chart [inlining](./inlining.md
|
|
11
|
+
Components are built on top of Helm chart [inlining](./inlining/helmcharts.md).
|
|
12
12
|
|
|
13
13
|
## How Nyl looks for components
|
|
14
14
|
|
|
@@ -5,12 +5,12 @@ weight: 5
|
|
|
5
5
|
# HelmChart
|
|
6
6
|
|
|
7
7
|
Nyl allows you to inline Helm charts by specifying a `HelmChart` resource in your manifest. Just like any other
|
|
8
|
-
resource, the Helm chart resource values can be templated using Nyl's [structured templating](../
|
|
8
|
+
resource, the Helm chart resource values can be templated using Nyl's [structured templating](../basics.md)
|
|
9
9
|
(for example to inject secrets), and are then rendered to Kubernetes resources that are inlined in your configuration.
|
|
10
10
|
|
|
11
11
|
__Example__
|
|
12
12
|
|
|
13
|
-
```yaml
|
|
13
|
+
```yaml
|
|
14
14
|
apiVersion: inline.nyl.io/v1
|
|
15
15
|
kind: HelmChart
|
|
16
16
|
metadata:
|
|
@@ -27,6 +27,79 @@ spec:
|
|
|
27
27
|
type: LoadBalancer
|
|
28
28
|
```
|
|
29
29
|
|
|
30
|
+
When writing Helm charts, we discourage from using `namespace: {{ .Release.Namespace }}`. This is because when you
|
|
31
|
+
instantiate a `HelmChart` in Nyl without specifying a `.metadata.namespace`, the Helm chart will be templated without
|
|
32
|
+
the `--namespace` option. This will have Helm assume `.Release.Namespace == "default"`, thus all `namespace` fields
|
|
33
|
+
in the generated resource will be set to `default`. This is not what you want, as it will prevent Nyl from injecting the
|
|
34
|
+
appropriate namespace based on the context of your local manifest file.
|
|
35
|
+
|
|
36
|
+
If you are dealing with a Helm chart that does use `namespace: {{ .Release.Namespace }}`, be sure to set the `.metadata.namespace` field of your Nyl `HelmChart` resource.
|
|
37
|
+
|
|
38
|
+
## ChartRef
|
|
39
|
+
|
|
40
|
+
The `.spec.chart` field defines the source of the Helm chart. You can source charts from a Helm HTTP(S) or OCI repository, a Git repository or a local directory. Local chart paths are first resolved in the Nyl search path that can be defined in the [Project settings](../../configuration/projects.md).
|
|
41
|
+
|
|
42
|
+
!!! note
|
|
43
|
+
We highly recommend to add a as a comment the link to <artifacthub.io>, if available. This allows you to easily
|
|
44
|
+
look up the chart version, values and documentation.
|
|
45
|
+
|
|
46
|
+
=== "HTTP(S) repository"
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
# ...
|
|
50
|
+
spec:
|
|
51
|
+
chart:
|
|
52
|
+
# https://artifacthub.io/packages/helm/bitnami/nginx
|
|
53
|
+
repository: https://charts.bitnami.com/bitnami
|
|
54
|
+
name: nginx
|
|
55
|
+
version: 18.3.5 # 1.27.3
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
=== "OCI repository"
|
|
59
|
+
|
|
60
|
+
```yaml
|
|
61
|
+
# ...
|
|
62
|
+
spec:
|
|
63
|
+
chart:
|
|
64
|
+
# https://artifacthub.io/packages/helm/bitnami/nginx
|
|
65
|
+
repository: oci://registry-1.docker.io/bitnamicharts
|
|
66
|
+
name: nginx
|
|
67
|
+
version: 18.3.5 # 1.27.3
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Note how the OCI URL does not contain the chart name. It is specified separately in the `name` field.
|
|
71
|
+
|
|
72
|
+
=== "Git repository"
|
|
73
|
+
|
|
74
|
+
```yaml
|
|
75
|
+
# ...
|
|
76
|
+
spec:
|
|
77
|
+
chart:
|
|
78
|
+
# This can be any valid URL that can be used with `git clone`, plus an optional URL query parameter that is
|
|
79
|
+
# either `ref` (for a Git reF) or `rev` (or a Git commit SHA).
|
|
80
|
+
git: https://github.com/bitnami/charts?rev=e808ba0
|
|
81
|
+
|
|
82
|
+
# If the chart is not located at the root of the repository, point to its subdirectory.
|
|
83
|
+
path: bitnami/nginx
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
=== "Local directory"
|
|
87
|
+
|
|
88
|
+
```yaml
|
|
89
|
+
# ...
|
|
90
|
+
spec:
|
|
91
|
+
chart:
|
|
92
|
+
# Explicitly relative paths (e.g. starting with `./`) are resolved relative to the manifest source file that
|
|
93
|
+
# defines the `HelmChart` resource.
|
|
94
|
+
path: ./charts/nginx
|
|
95
|
+
|
|
96
|
+
# Absolute paths are resolved absolute in the local filesystem. This is not usually useful except for testing.
|
|
97
|
+
path: /path/to/chart
|
|
98
|
+
|
|
99
|
+
# Any other path is resolved in the Nyl project search path.
|
|
100
|
+
path: nginx
|
|
101
|
+
```
|
|
102
|
+
|
|
30
103
|
### Comparison to native ArgoCD Helm applications
|
|
31
104
|
|
|
32
105
|
Nyl may look similar to Helm in the sense that it allows for templating YAML files. However, there are some important
|
|
@@ -6,5 +6,5 @@ title: Overview
|
|
|
6
6
|
|
|
7
7
|
Nyl supports inlining of Kubernetes resources generated from templates in your configuration. Resources that are
|
|
8
8
|
inlined by Nyl are typically in the `inline.nyl.io/v1` API group, however Nyl also has the concept of
|
|
9
|
-
[components](
|
|
9
|
+
[components](../components.md) which effectively allow you to define your own API groups and resource kinds for
|
|
10
10
|
inlined resources.
|
|
@@ -121,6 +121,7 @@ def version() -> None:
|
|
|
121
121
|
sys.exit(0)
|
|
122
122
|
|
|
123
123
|
|
|
124
|
+
from . import add # noqa: E402
|
|
124
125
|
from . import argocd # noqa: E402
|
|
125
126
|
from . import crds # noqa: F401,E402
|
|
126
127
|
from . import new # noqa: E402
|
|
@@ -131,6 +132,7 @@ from . import template # noqa: F401,E402
|
|
|
131
132
|
from . import tools # noqa: E402
|
|
132
133
|
from . import tun # noqa: E402
|
|
133
134
|
|
|
135
|
+
app.add_typer(add.app)
|
|
134
136
|
app.add_typer(argocd.app)
|
|
135
137
|
app.add_typer(new.app)
|
|
136
138
|
app.add_typer(profile.app)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Convenient CLI for making ammends to Kubernetes manifest files.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
import sys
|
|
7
|
+
from typing import Any
|
|
8
|
+
from typer import Argument, Option, Typer
|
|
9
|
+
from loguru import logger
|
|
10
|
+
import yaml
|
|
11
|
+
|
|
12
|
+
from nyl.commands.template import (
|
|
13
|
+
DEFAULT_NAMESPACE_ANNOTATION,
|
|
14
|
+
ManifestsWithSource,
|
|
15
|
+
is_namespace_resource,
|
|
16
|
+
load_manifests,
|
|
17
|
+
)
|
|
18
|
+
from nyl.resources import ObjectMetadata
|
|
19
|
+
from nyl.resources.helmchart import ChartRef, HelmChart, HelmChartSpec
|
|
20
|
+
from nyl.tools.typer import new_typer
|
|
21
|
+
from nyl.tools.types import Manifests
|
|
22
|
+
|
|
23
|
+
app: Typer = new_typer(name="add", help=__doc__)
|
|
24
|
+
|
|
25
|
+
MANIFEST_OPTION = Option(..., "-m", "--manifest", help="The manifest YAML file to add the namespace to.")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@app.command()
|
|
29
|
+
def namespace(
|
|
30
|
+
manifest: Path = MANIFEST_OPTION,
|
|
31
|
+
name: str = Argument(help="Name of the namespace to add."),
|
|
32
|
+
) -> None:
|
|
33
|
+
"""
|
|
34
|
+
Add a Kubernetes `Namespace` resource definition to the top of the specified manifest file.
|
|
35
|
+
|
|
36
|
+
If this is the first namespace defined in the manifest, it will be annotated with `nyl.io/is-default-namespace`.
|
|
37
|
+
"""
|
|
38
|
+
|
|
39
|
+
if manifest.exists():
|
|
40
|
+
content = manifest.read_text()
|
|
41
|
+
resources = load_manifests([manifest])[0]
|
|
42
|
+
else:
|
|
43
|
+
content = ""
|
|
44
|
+
resources = ManifestsWithSource(Manifests([]), manifest)
|
|
45
|
+
|
|
46
|
+
if any(is_namespace_resource(x) and x["metadata"]["name"] == name for x in resources.manifests):
|
|
47
|
+
logger.error("Namespace '{}' already exists in {}.", name, manifest)
|
|
48
|
+
sys.exit(1)
|
|
49
|
+
|
|
50
|
+
namespace: dict[str, Any] = {
|
|
51
|
+
"apiVersion": "v1",
|
|
52
|
+
"kind": "Namespace",
|
|
53
|
+
"metadata": {
|
|
54
|
+
"name": name,
|
|
55
|
+
},
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
as_default = not any(is_namespace_resource(x) for x in resources.manifests)
|
|
59
|
+
if as_default:
|
|
60
|
+
namespace["metadata"]["annotations"] = {DEFAULT_NAMESPACE_ANNOTATION: "true"}
|
|
61
|
+
|
|
62
|
+
if not content.lstrip().startswith("---"):
|
|
63
|
+
content = f"---\n{content}"
|
|
64
|
+
content = f"---\n{yaml.safe_dump(namespace, sort_keys=False)}\n{content}"
|
|
65
|
+
manifest.write_text(content)
|
|
66
|
+
|
|
67
|
+
logger.info("Added {}namespace '{}' to {}.", "default " if as_default else "", name, manifest)
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
@app.command()
|
|
71
|
+
def chart(
|
|
72
|
+
manifest: Path = MANIFEST_OPTION,
|
|
73
|
+
name: str = Argument(help="The release name."),
|
|
74
|
+
namespace: str | None = Option(None, "-n", "--namespace", help="The release namespace."),
|
|
75
|
+
repository: str | None = Option(None, "--repo", "--repository", help="The chart repository."),
|
|
76
|
+
chart: str | None = Option(None, "--chart", help="The chart name."),
|
|
77
|
+
version: str | None = Option(None, "--version", help="The chart version."),
|
|
78
|
+
path: str | None = Option(None, "--path", help="The chart path if consumed from disk."),
|
|
79
|
+
git: str | None = Option(None, "--git", help="Git URL of the chart."),
|
|
80
|
+
) -> None:
|
|
81
|
+
"""
|
|
82
|
+
Append a Nyl `HelmChart` resource to the specified manifest file.
|
|
83
|
+
"""
|
|
84
|
+
|
|
85
|
+
if repository or chart or version:
|
|
86
|
+
if not repository or not chart or not version:
|
|
87
|
+
logger.error("If any of --repo, --chart, or --version are specified, all must be specified.")
|
|
88
|
+
sys.exit(1)
|
|
89
|
+
|
|
90
|
+
if path or git:
|
|
91
|
+
logger.error("If --repo is specified, --path and --git must not be specified.")
|
|
92
|
+
sys.exit(1)
|
|
93
|
+
|
|
94
|
+
if git:
|
|
95
|
+
if repository:
|
|
96
|
+
logger.error("If --git is specified, --repo must not be specified.")
|
|
97
|
+
sys.exit(1)
|
|
98
|
+
|
|
99
|
+
resource = HelmChart(
|
|
100
|
+
metadata=ObjectMetadata(name=name, namespace=namespace),
|
|
101
|
+
spec=HelmChartSpec(
|
|
102
|
+
chart=ChartRef(
|
|
103
|
+
path=path,
|
|
104
|
+
git=git,
|
|
105
|
+
repository=repository,
|
|
106
|
+
name=chart,
|
|
107
|
+
version=version,
|
|
108
|
+
),
|
|
109
|
+
values={},
|
|
110
|
+
),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
content = manifest.read_text() if manifest.exists() else ""
|
|
114
|
+
if not content.rstrip().endswith("---"):
|
|
115
|
+
content += "\n---\n"
|
|
116
|
+
content += yaml.safe_dump(resource.dump())
|
|
117
|
+
|
|
118
|
+
manifest.write_text(content)
|
|
@@ -29,7 +29,7 @@ from nyl.tools.logging import lazy_str
|
|
|
29
29
|
from nyl.tools.types import Manifest, Manifests
|
|
30
30
|
|
|
31
31
|
DEFAULT_PROFILE = "default"
|
|
32
|
-
DEFAULT_NAMESPACE_ANNOTATION = "nyl.io/default-namespace"
|
|
32
|
+
DEFAULT_NAMESPACE_ANNOTATION = "nyl.io/is-default-namespace"
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
# Need an enum for typer
|
|
@@ -431,7 +431,7 @@ def get_default_namespace_for_manifest(source: ManifestsWithSource, fallback: st
|
|
|
431
431
|
fallback.
|
|
432
432
|
|
|
433
433
|
- If there are multiple `v1/Namespace` resources declared in the manifest, we pick the one with the
|
|
434
|
-
`nyl.io/default-namespace` label. If there is no such namespace, a warning is logged and we pick the first one
|
|
434
|
+
`nyl.io/is-default-namespace` label. If there is no such namespace, a warning is logged and we pick the first one
|
|
435
435
|
alphabetically.
|
|
436
436
|
|
|
437
437
|
Returns:
|
|
@@ -67,7 +67,8 @@ class HelmChartGenerator(Generator[HelmChart], resource_type=HelmChart):
|
|
|
67
67
|
|
|
68
68
|
parsed = urlparse(chart_ref.repository)
|
|
69
69
|
cache_dir = (
|
|
70
|
-
self.chart_cache_dir
|
|
70
|
+
self.chart_cache_dir
|
|
71
|
+
/ f"{parsed.scheme}-{parsed.hostname}-{(parsed.path.replace('/', '-') + '-' + chart).lstrip('-')}"
|
|
71
72
|
)
|
|
72
73
|
command = ["helm", "pull", chart]
|
|
73
74
|
if repository:
|
|
@@ -6,6 +6,7 @@ from abc import ABC
|
|
|
6
6
|
from dataclasses import dataclass
|
|
7
7
|
from typing import ClassVar, Collection, cast
|
|
8
8
|
|
|
9
|
+
from databind.core import SerializeDefaults
|
|
9
10
|
from databind.json import dump as ser
|
|
10
11
|
from databind.json import load as deser
|
|
11
12
|
from typing_extensions import Self
|
|
@@ -107,7 +108,7 @@ class NylResource(ABC):
|
|
|
107
108
|
Dump the resource to a manifest.
|
|
108
109
|
"""
|
|
109
110
|
|
|
110
|
-
manifest = cast(Manifest, ser(self, type(self)))
|
|
111
|
+
manifest = cast(Manifest, ser(self, type(self), settings=[SerializeDefaults(False)]))
|
|
111
112
|
manifest["apiVersion"] = self.API_VERSION
|
|
112
113
|
manifest["kind"] = self.KIND
|
|
113
114
|
return Manifest(manifest)
|
{nyl-0.7.0 → nyl-0.7.2}/uv.lock
RENAMED
|
File without changes
|
{nyl-0.7.0 → nyl-0.7.2}/.envrc
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|