Skip to content

Commit

Permalink
Rename project to "kclipper"
Browse files Browse the repository at this point in the history
  • Loading branch information
MacroPower committed Jan 3, 2025
1 parent 0f688a9 commit 2e20452
Show file tree
Hide file tree
Showing 42 changed files with 134 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ jobs:
echo "Publishing module: $PKG_NAME"
cat kcl.mod
kcl mod push oci://ghcr.io/macropower/kclx/$PKG_NAME
kcl mod push oci://ghcr.io/macropower/kclipper/$PKG_NAME
fi
cd -
fi
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ linters-settings:
default-signifies-exhaustive: true

goimports:
local-prefixes: github.com/MacroPower/kclx
local-prefixes: github.com/MacroPower/kclipper

issues:
exclude-rules:
Expand Down
14 changes: 7 additions & 7 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
version: 2

project_name: kclx
project_name: kclipper

env:
- DOCKER_REGISTRY=ghcr.io/macropower
Expand All @@ -12,8 +12,8 @@ before:

# https://github.com/goreleaser/example-zig-cgo/
builds:
- id: kclx
main: ./cmd/kclx
- id: kclipper
main: ./cmd/kclipper
binary: kcl
goos:
- linux
Expand All @@ -35,10 +35,10 @@ builds:
{{- if and (eq .Os "darwin") (eq .Arch "arm64") -}} CXX={{ .Env.CXX_DARWIN_ARM64 }} {{- end -}}
ldflags:
- -s -w
- -X github.com/MacroPower/kclx/internal/version.Version={{.Version}}
- -X github.com/MacroPower/kclx/internal/version.Branch={{.Branch}}
- -X github.com/MacroPower/kclx/internal/version.BuildUser={{.Env.USER}}@{{.Env.HOSTNAME}}
- -X github.com/MacroPower/kclx/internal/version.BuildDate={{.Date}}
- -X github.com/MacroPower/kclipper/internal/version.Version={{.Version}}
- -X github.com/MacroPower/kclipper/internal/version.Branch={{.Branch}}
- -X github.com/MacroPower/kclipper/internal/version.BuildUser={{.Env.USER}}@{{.Env.HOSTNAME}}
- -X github.com/MacroPower/kclipper/internal/version.BuildDate={{.Date}}
flags:
- -trimpath
- -tags={{ .Env.BUILD_TAGS }}
Expand Down
30 changes: 16 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# macropower/kclx
# kclipper

[KCL](https://github.com/kcl-lang/kcl) is a constraint-based record & functional language mainly used in cloud-native configuration and policy scenarios. It is hosted by the Cloud Native Computing Foundation (CNCF) as a Sandbox Project. The KCL website can be found [here](https://kcl-lang.io/).
> KCL + Helm = kclipper
kclx = KCL Extended. This repo includes an opinionated set of extensions for KCL (thus macropower/kclx, other flavors are available). The included extensions are primarily centered upon improving the experience of using KCL with [Argo CD](https://argoproj.github.io/cd/), though they are not necessarily limited to that. In the context of this repo, "extensions" is meant to refer to a set of both KCL [plugins](https://www.kcl-lang.io/docs/next/reference/plugin/overview) and [packages](https://www.kcl-lang.io/docs/next/user_docs/concepts/package-and-module).
[KCL](https://github.com/kcl-lang/kcl) is a constraint-based record & functional language mainly used in cloud-native configuration and policy scenarios. It is hosted by the Cloud Native Computing Foundation (CNCF) as a Sandbox Project. The KCL website can be found [here](https://kcl-lang.io/).

To use macropower/kclx, you must [install](#installation) it as a KCL replacement. The macropower/kclx binary will wrap the upstream KCL release with its plugins. Up-to-date multi-architecture Docker images for x86 and arm64 are also available.
Kclipper combines [KCL](https://github.com/kcl-lang/kcl) and [Helm](https://helm.sh/). It provides KCL [plugins](https://www.kcl-lang.io/docs/next/reference/plugin/overview), [packages](https://www.kcl-lang.io/docs/next/user_docs/concepts/package-and-module), and CLI commands, which collectively allow you to manage Helm charts and their schemas declaratively, and render Helm charts directly within KCL. It is highly optimized for use as an [Argo CD](https://argoproj.github.io/cd/) ConfigManagementPlugin.

> :warning: You should not currently use macropower/kclx in multi-tenant Argo CD environments. See [#2](https://github.com/MacroPower/kclx/issues/2).
To use kclipper, you must [install](#installation) it as a KCL replacement. The kclipper binary will wrap the upstream KCL release with extra plugins and commands. Up-to-date multi-architecture Docker images for x86 and arm64 are also available.

## Features

Expand Down Expand Up @@ -75,24 +75,26 @@ kcl chart update

---

**Enjoy blazing fast reconciliation times.** macropower/kclx is built with performance in mind, and is optimized for speedy rendering at runtime. It achieves this with a custom Helm template implementation, based on the Argo CD Helm source implementation, with edits to minimize I/O. Additionally, using validation=KCL disables Helm's value validation, and instead relies on KCL for values validation. This can provide a significant performance boost for any chart that includes a proper JSON Schema, and is especially noticeable for charts with nested JSON Schemas (e.g. remote refs, chart dependencies, or both).
**Enjoy blazing fast reconciliation times.** Kclipper is built with performance in mind, and is optimized for speedy rendering at runtime. It achieves this with a custom Helm template implementation, based on the Argo CD Helm source implementation, with edits to minimize I/O. Additionally, using validation=KCL disables Helm's value validation, and instead relies on KCL for values validation. This can provide a significant performance boost for any chart that includes a proper JSON Schema, and is especially noticeable for charts with nested JSON Schemas (e.g. remote refs, chart dependencies, or both).

| Chart | Vanilla Argo CD | macropower/kclx | macropower/kclx (schemaValidator=KCL) |
| :----------- | :-------------- | :-------------- | :------------------------------------ |
| podinfo | 9.1 ms/op | 0.78 ms/op | 0.76 ms/op (~12x) |
| app-template | 159 ms/op | 143 ms/op | 1.48 ms/op (~107x) |
| Chart | Vanilla Argo CD | kclipper | kclipper (schemaValidator=KCL) |
| :----------- | :-------------- | :--------- | :----------------------------- |
| podinfo | 9.1 ms/op | 0.78 ms/op | 0.76 ms/op (~12x) |
| app-template | 159 ms/op | 143 ms/op | 1.48 ms/op (~107x) |

> Approximate values from my Mac Mini M1.
There is a bit of a trade-off. The binary size is larger, and KCL run performance will be worse by an small, absolute amount of time (in my case ~8ms). Meaning, KCL runs with no Helm templates will be slightly slower compared to upstream KCL.

## Installation

Binaries are posted in [releases](https://github.com/MacroPower/kclx/releases). Images and OCI artifacts are available under [packages](https://github.com/MacroPower/kclx/pkgs/container/kclx).
> :warning: You should not currently use kclipper in multi-tenant Argo CD environments. See [#2](https://github.com/MacroPower/kclipper/issues/2).
Binaries are posted in [releases](https://github.com/MacroPower/kclipper/releases). Images and OCI artifacts are available under [packages](https://github.com/MacroPower/kclipper/pkgs/container/kclipper).

The binary name for macropower/kclx is always still just `kcl`, so that it can be used as a drop-in replacement for official KCL binaries. Versions are tagged independently of upstream KCL, e.g. macropower/kclx `v0.1.0` maps to kcl `v0.11.0`, but macropower/kclx releases still follow semver with consideration for upstream KCL changes.
The binary name for kclipper is still just `kcl`, so it can be used as a drop-in replacement for official KCL binaries. Versions are tagged independently of upstream KCL, e.g. kclipper `v0.1.0` maps to kcl `v0.11.0`, but kclipper releases still follow semver with consideration for upstream KCL changes.

To use macropower/kclx with Argo CD, you can follow [this guide](https://www.kcl-lang.io/docs/user_docs/guides/gitops/gitops-quick-start) to set up the KCL ConfigManagementPlugin. You just need to substitute the official kcl image with a macropower/kclx image.
To use kclipper with Argo CD, you can follow [this guide](https://www.kcl-lang.io/docs/user_docs/guides/gitops/gitops-quick-start) to set up the KCL ConfigManagementPlugin. You just need to substitute the official kcl image with a kclipper image.

## Usage

Expand Down Expand Up @@ -203,7 +205,7 @@ manifests.yaml_stream(_podinfo)

Here, `_podinfo` is a list of Kubernetes resources that were rendered by Helm. You can use the `manifests` package to render these resources to a stream of YAML, which can be piped to `kubectl apply -f -`, be used in a GitOps workflow e.g. via an Argo CMP, etc.

In a real project, you might want to abstract away rendering of the output, package charts with other resources, and so on. For an example, I am using macropower/kclx in my [homelab](https://github.com/MacroPower/homelab/tree/main/konfig), using the [konfig](https://github.com/kcl-lang/konfig) pattern. In this case, a frontend package defines inputs for charts, a mixin processes those inputs, and a backend package renders the resources.
In a real project, you might want to abstract away rendering of the output, package charts with other resources, and so on. For an example, I am using kclipper in my [homelab](https://github.com/MacroPower/homelab/tree/main/konfig), using the [konfig](https://github.com/kcl-lang/konfig) pattern. In this case, a frontend package defines inputs for charts, a mixin processes those inputs, and a backend package renders the resources.

### Chart Updates

Expand Down
20 changes: 10 additions & 10 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,17 @@ tasks:
FLAGS: "--single-target"
- task: pull-upstream
vars:
KCLX_BIN: dist/kclx_{{OS}}_{{ARCH}}*/kcl
KCLX_BIN: dist/kclipper_{{OS}}_{{ARCH}}*/kcl
KCL_CODE: benchmarks/simple.k
KCL_HELM: benchmarks/simple-helm.k
KCL_HELM_VALUES: benchmarks/simple-helm-values.k
cmds:
- >-
hyperfine --warmup=10
--export-markdown ./benchmarks/README.md
--command-name "kclx ./{{.KCL_CODE}}"
--command-name "kclx ./{{.KCL_HELM}}"
--command-name "kclx ./{{.KCL_HELM_VALUES}}"
--command-name "kclipper ./{{.KCL_CODE}}"
--command-name "kclipper ./{{.KCL_HELM}}"
--command-name "kclipper ./{{.KCL_HELM_VALUES}}"
--reference ".tmp/bin/kcl ./{{.KCL_CODE}}"
"{{.KCLX_BIN}} ./{{.KCL_CODE}}"
"{{.KCLX_BIN}} ./{{.KCL_HELM}}"
Expand All @@ -165,14 +165,14 @@ tasks:
- defer: "docker rm kcl -f"
- docker exec kcl kcl version
- >-
docker run --name=kclx -d --entrypoint=/usr/bin/bash {{.DOCKER_MOUNTS}}
ghcr.io/macropower/kclx:v0.2.0-arm64 -c "sleep 300"
- defer: "docker rm kclx -f"
- docker exec kclx kcl version
docker run --name=kclipper -d --entrypoint=/usr/bin/bash {{.DOCKER_MOUNTS}}
ghcr.io/macropower/kclipper:v0.2.0-arm64 -c "sleep 300"
- defer: "docker rm kclipper -f"
- docker exec kclipper kcl version
- >-
hyperfine --warmup=1
--command-name "docker ../{{.KCL_CODE}}"
--command-name "docker ../{{.KCL_HELM}}"
--reference "docker exec kcl kcl run /opt/{{.KCL_CODE}}"
"docker exec kclx kcl run /opt/{{.KCL_CODE}}"
"docker exec kclx kcl run /opt/{{.KCL_HELM}}"
"docker exec kclipper kcl run /opt/{{.KCL_CODE}}"
"docker exec kclipper kcl run /opt/{{.KCL_HELM}}"
12 changes: 6 additions & 6 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :--------------------------------------- | ---------: | -------: | -------: | ----------: |
| `.tmp/bin/kcl ./benchmarks/simple.k` | 24.6 ± 3.0 | 22.5 | 51.9 | 1.00 |
| `kclx ./benchmarks/simple.k` | 36.8 ± 0.7 | 34.7 | 38.5 | 1.50 ± 0.18 |
| `kclx ./benchmarks/simple-helm.k` | 40.8 ± 3.1 | 37.7 | 63.9 | 1.66 ± 0.24 |
| `kclx ./benchmarks/simple-helm-values.k` | 42.7 ± 0.9 | 40.2 | 45.0 | 1.73 ± 0.21 |
| Command | Mean [ms] | Min [ms] | Max [ms] | Relative |
| :------------------------------------------- | ---------: | -------: | -------: | ----------: |
| `.tmp/bin/kcl ./benchmarks/simple.k` | 24.6 ± 3.0 | 22.5 | 51.9 | 1.00 |
| `kclipper ./benchmarks/simple.k` | 36.8 ± 0.7 | 34.7 | 38.5 | 1.50 ± 0.18 |
| `kclipper ./benchmarks/simple-helm.k` | 40.8 ± 3.1 | 37.7 | 63.9 | 1.66 ± 0.24 |
| `kclipper ./benchmarks/simple-helm-values.k` | 42.7 ± 0.9 | 40.2 | 45.0 | 1.73 ± 0.21 |
22 changes: 14 additions & 8 deletions cmd/kclx/main.go → cmd/kclipper/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import (
kclcmd "kcl-lang.io/cli/cmd/kcl/commands"
"kcl-lang.io/cli/pkg/plugin"

"github.com/MacroPower/kclx/internal/cli"
"github.com/MacroPower/kclx/pkg/log"
helmplugin "github.com/MacroPower/kclx/pkg/plugin/helm"
httpplugin "github.com/MacroPower/kclx/pkg/plugin/http"
osplugin "github.com/MacroPower/kclx/pkg/plugin/os"
"github.com/MacroPower/kclipper/internal/cli"
"github.com/MacroPower/kclipper/pkg/log"
helmplugin "github.com/MacroPower/kclipper/pkg/plugin/helm"
httpplugin "github.com/MacroPower/kclipper/pkg/plugin/http"
osplugin "github.com/MacroPower/kclipper/pkg/plugin/os"
)

func init() {
Expand All @@ -28,12 +28,18 @@ func init() {
const (
cmdName = "kcl"

shortDesc = "The KCL Extended Command Line Interface (CLI)."
longDesc = `The KCL Extended Command Line Interface (CLI).
shortDesc = "The Kclipper Command Line Interface (CLI)."
longDesc = `The Kclipper (KCL + Helm) Command Line Interface (CLI).
KCL is an open-source, constraint-based record and functional language that
enhances the writing of complex configurations, including those for cloud-native
scenarios. The KCL website: https://kcl-lang.io
scenarios.
Kclipper combines KCL and Helm. It provides KCL plugins, packages, and
additional commands, which collectively allow you to manage Helm charts and
their schemas declaratively, and render Helm charts directly within KCL.
The KCL website: https://kcl-lang.io
`
)

Expand Down
8 changes: 4 additions & 4 deletions docs/helm_extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ manifests.yaml_stream(
)
```

To read more about how the macropower/kclx Helm plugin compares to other KCL Helm plugins like [kcfoil](https://github.com/cakehappens/kcfoil), see the [Helm plugin comparison](docs/helm_plugin_comparison.md).
To read more about how the kclipper Helm plugin compares to other KCL Helm plugins like [kcfoil](https://github.com/cakehappens/kcfoil), see the [Helm plugin comparison](docs/helm_plugin_comparison.md).

## Helm Package

To gain full support for the Helm plugin with kcl-language-server (for highlighting, completion, and definitions in your editor), you can use the `macropower/kclx/helm` wrapper package. This is completely optional, but is a significant quality of life improvement.
To gain full support for the Helm plugin with kcl-language-server (for highlighting, completion, and definitions in your editor), you can use the `macropower/kclipper/helm` wrapper package. This is completely optional, but is a significant quality of life improvement.

```sh
kcl mod add oci://ghcr.io/macropower/kclx/helm
kcl mod add oci://ghcr.io/macropower/kclipper/helm
```

Then, you can use the `helm` package to interface with the Helm plugin, rather than calling it directly:
Expand Down Expand Up @@ -76,7 +76,7 @@ _podinfo = helm.template(helm.Chart {
manifests.yaml_stream(_podinfo)
```

> :warning: This must be completed AFTER installing `macropower/kclx`. Just adding the helm module will not provide you with the underlying plugin, and you will get an error when you call the template function.
> :warning: This must be completed AFTER installing kclipper. Just adding the helm module will not provide you with the underlying plugin, and you will get an error when you call the template function.
## `kcl chart` Command

Expand Down
4 changes: 2 additions & 2 deletions docs/helm_plugin_comparison.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

<https://github.com/kcl-lang/helm-kcl>

Don't let the names fool you. The [helm-kcl](https://github.com/kcl-lang/helm-kcl) plugin is a plugin for Helm, allowing you to use `KCLRun` resources in your Helm Charts. The macropower/kclx Helm plugin is a plugin for KCL, allowing you to template Helm Charts in your KCL code. i.e., they integrate in inverse directions.
Don't let the names fool you. The [helm-kcl](https://github.com/kcl-lang/helm-kcl) plugin is a plugin for Helm, allowing you to use `KCLRun` resources in your Helm Charts. The kclipper Helm plugin is a plugin for KCL, allowing you to template Helm Charts in your KCL code. i.e., they integrate in inverse directions.

## To the KCFoil Helm Plugin

<https://github.com/cakehappens/kcfoil>

The macropower/kclx Helm plugin is similar to [kcfoil](https://github.com/cakehappens/kcfoil)'s helm plugin. kcfoil's Helm plugin is based on Tanka's Helm implementation, whereas macropower/kclx's Helm plugin is based on Argo CD's Helm source implementation. So they both expose a helm template function, but the exposed parameters and backend implementations are completely different.
The kclipper Helm plugin is similar to [kcfoil](https://github.com/cakehappens/kcfoil)'s helm plugin. kcfoil's Helm plugin is based on Tanka's Helm implementation, whereas kclipper's Helm plugin is based on Argo CD's Helm source implementation. So they both expose a helm template function, but the exposed parameters and backend implementations are completely different.

The biggest difference:

Expand Down
4 changes: 2 additions & 2 deletions example/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
services:
kclx:
image: ghcr.io/macropower/kclx:latest
kclipper:
image: ghcr.io/macropower/kclipper:latest
command: run /opt/example.k
volumes:
- ./tmp:/tmp
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/MacroPower/kclx
module github.com/MacroPower/kclipper

go 1.23.3

Expand Down
8 changes: 4 additions & 4 deletions internal/cli/chart.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import (
"github.com/hashicorp/go-multierror"
"github.com/spf13/cobra"

"github.com/MacroPower/kclx/pkg/helm"
"github.com/MacroPower/kclx/pkg/helmutil"
"github.com/MacroPower/kclx/pkg/jsonschema"
"github.com/MacroPower/kclipper/pkg/helm"
"github.com/MacroPower/kclipper/pkg/helmutil"
"github.com/MacroPower/kclipper/pkg/jsonschema"
)

const (
Expand All @@ -32,7 +32,7 @@ var ErrInvalidArgument = errors.New("invalid argument")
func NewChartCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "chart",
Short: "KCL chart management",
Short: "Helm chart management",
Long: chartDesc,
Example: chartExample,
SilenceUsage: true,
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (

"github.com/stretchr/testify/require"

"github.com/MacroPower/kclx/internal/cli"
"github.com/MacroPower/kclipper/internal/cli"
)

var testDataDir string
Expand Down
4 changes: 2 additions & 2 deletions internal/cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/spf13/cobra"
kclversion "kcl-lang.io/cli/pkg/version"

"github.com/MacroPower/kclx/internal/version"
"github.com/MacroPower/kclipper/internal/version"
)

func GetVersionString() string {
Expand All @@ -17,7 +17,7 @@ func GetVersionString() string {
func NewVersionCmd() *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Show version of the KCL CLI",
Short: "Show version of the kclipper CLI",
Run: func(*cobra.Command, []string) {
fmt.Println(GetVersionString())
},
Expand Down
4 changes: 2 additions & 2 deletions modules/helm/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# kclx/helm
# kclipper/helm

```sh
kcl mod add oci://ghcr.io/macropower/kclx/helm
kcl mod add oci://ghcr.io/macropower/kclipper/helm
```

## Index
Expand Down
4 changes: 2 additions & 2 deletions modules/helm/main.k
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
This module provides an interface for the macropower/kclx Helm plugin.
This module provides an interface for the kclipper Helm plugin.
"""
import regex
import file
Expand Down Expand Up @@ -88,7 +88,7 @@ schema ChartConfig(ChartBase):
type Charts = {str:ChartConfig}

template = lambda chart: Chart -> [{str:}] {
"""Render Helm chart templates using `macropower/kclx`'s `kcl_plugin.helm.template`.
"""Render Helm chart templates using kclipper's `kcl_plugin.helm.template`.

Examples
--------
Expand Down
2 changes: 1 addition & 1 deletion pkg/argoutil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

`argoutil` is a collection of packages originally taken from [argoproj/argo-cd/util][1].

These packages have been modified for use in macropower/kclx.
These packages have been modified for use in kclipper.

## License

Expand Down
4 changes: 2 additions & 2 deletions pkg/argoutil/helm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import (
"oras.land/oras-go/v2/registry/remote"
"oras.land/oras-go/v2/registry/remote/auth"

"github.com/MacroPower/kclx/pkg/argoutil/sync"
"github.com/MacroPower/kclx/pkg/pathutil"
"github.com/MacroPower/kclipper/pkg/argoutil/sync"
"github.com/MacroPower/kclipper/pkg/pathutil"
)

var (
Expand Down
Loading

0 comments on commit 2e20452

Please sign in to comment.