From 6938d24f126c8ae32505f93085e3875a78778482 Mon Sep 17 00:00:00 2001 From: Ibrahim Diallo <20114089+thisisibrahimd@users.noreply.github.com> Date: Sat, 29 Aug 2026 16:38:14 -0400 Subject: [PATCH] chore: rename module and repo references to thisisibrahimd/k8s Rename the Go module path from github.com/jsonnet-libs/k8s to github.com/thisisibrahimd/k8s and point all repo references at the fork: - go.mod module path and all package imports - README: ghcr.io/thisisibrahimd/k8s-gen image, release, go install and tree URLs - goreleaser: hardcode the ghcr image owner, drop the now-unused OWNER env from the release workflow - remove dead excludeVersions config field (never wired up) Also fix README inaccuracies found during review: - note that go install yields a `k8s` binary, not `k8s-gen` - document the `go build -o k8s-gen .` prerequisite for make targets - document the VERSIONS make var, positional version filter, and --debug flag - document the includeVersions default and crds/openapi mutual exclusivity - correct custom/core patch descriptions (apps/core swap, batch/v1, autoscaling v1+v2) --- .github/workflows/release.yml | 1 - README.md | 37 ++++++++++++++----- cmd/k8s-gen/generate.go | 14 +++---- cmd/k8s-gen/root.go | 2 +- go.mod | 2 +- goreleaser.yml | 2 +- main.go | 2 +- pkg/builder/docsonnet/docsonnet.go | 2 +- .../jsonschemacomplier/jsonschemacomplier.go | 4 +- .../jsonschemacomplier_test.go | 2 +- pkg/config/config.go | 1 - pkg/model/gvk.go | 2 +- pkg/model/load.go | 2 +- pkg/model/modifiers.go | 2 +- pkg/render/modifiers.go | 8 ++-- pkg/render/render.go | 6 +-- pkg/render/sort.go | 2 +- pkg/render/sort_test.go | 2 +- pkg/targetgenerator/githubtargetgenerator.go | 4 +- pkg/targetgenerator/targetgenerator.go | 2 +- pkg/writer/disk.go | 6 +-- pkg/writer/writer.go | 4 +- 22 files changed, 62 insertions(+), 47 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e62a6a09..a41f645a 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -36,4 +36,3 @@ jobs: args: release --clean env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - OWNER: ${{ github.repository_owner }} diff --git a/README.md b/README.md index 63ebfccc..b83e374e 100644 --- a/README.md +++ b/README.md @@ -11,24 +11,26 @@ CustomResourceDefinitions, or from JSON Schema. ### Docker ```bash -docker pull ghcr.io/jsonnet-libs/k8s: +docker pull ghcr.io/thisisibrahimd/k8s-gen: ``` ### Binary release -Download pre-built binaries from [GitHub Releases](https://github.com/jsonnet-libs/k8s/releases): +Download pre-built binaries from [GitHub Releases](https://github.com/thisisibrahimd/k8s/releases): ```bash -curl -sL https://github.com/jsonnet-libs/k8s/releases/latest/download/k8s-gen_linux_x86_64.tar.gz | tar xz +curl -sL https://github.com/thisisibrahimd/k8s/releases/latest/download/k8s-gen_linux_x86_64.tar.gz | tar xz sudo mv k8s-gen /usr/local/bin/ ``` ### From source ```bash -go install github.com/jsonnet-libs/k8s@latest +go install github.com/thisisibrahimd/k8s@latest ``` +Note: this installs the binary as `k8s` (module path name). Rename or symlink it to `k8s-gen`, or substitute `k8s` in the commands below. + ## Usage ### Create a self-managed lib @@ -137,7 +139,7 @@ If you prefer to manually define versions and CRD URLs, omit `specGenerator` and } ``` -Note: When using manual specs, add a per-spec `prefix` if the CRD group cannot be inferred from the URLs alone. +Note: When using manual specs, set a per-spec `prefix` (regex) to filter which API groups are included; without a prefix, all groups found in the specs are included. Each spec must set either `crds` (a list of CRDs) or `openapi` (a single OpenAPI v2/Swagger spec) — they are mutually exclusive, and both accept URLs or local file paths. | Feature | Auto-Discovery | Manual | |---------|---------------|--------| @@ -147,6 +149,7 @@ Note: When using manual specs, add a per-spec `prefix` if the CRD group cannot b | `versionLimit` | Default `10` (mutually exclusive with `versions`) | Not applicable | | `versions` | Optional exact list of clean versions (without prefix) | Not applicable | | `versionPrefix` | Default `"v"` (prepended to `versions` for the Git ref) | Not applicable | +| `includeVersions` | Default `^v?\d+\.\d+\.\d+$` (regex filter on discovered tag names) | Not applicable | | `dedupeCrds` | Default `true` (skips duplicate CRD versions; ignored when `versions` is set) | Not applicable | | Maintenance | Automatic on new releases | Manual updates required | @@ -175,18 +178,32 @@ Create a `config.json` in the new folder. This example renders a lib from CRDs: } ``` +Build the binary first (the Makefile expects `./k8s-gen` in the repo root): + +```bash +go build -o k8s-gen . +``` + Generate the library: ```bash $ make libs/ ``` +Pass `VERSIONS` to regenerate only specific versions: + +```bash +$ make libs/ VERSIONS="1.27.0" +``` + Or run the binary directly: ```bash $ k8s-gen generate k8s --config libs//config.json ``` +Append version outputs as positional arguments to regenerate only specific versions, e.g. `k8s-gen generate k8s --config libs//config.json 1.27.0`. Use the global `--debug` flag for verbose logging. + ### Generate Jsonnet from JSON Schema You can also generate a Jsonnet library directly from a JSON Schema file. This is useful for configuration files such as `.golangci.yml`, `package.json`, or any other schema-backed document. @@ -270,7 +287,7 @@ For that, there are two methods for extending: ### `custom` patches -The [`custom/`](https://github.com/jsonnet-libs/k8s/tree/master/libs/k8s/custom) +The [`custom/`](https://github.com/thisisibrahimd/k8s/tree/master/libs/k8s/custom) directory contains a set of `.libsonnet` files, that are _automatically merged_ with the generated result in `main.libsonnet`, so they become part of the exported API. @@ -283,10 +300,10 @@ libs/k8s/ ├── config.json # Config to generate the k8s jsonnet libraries └── custom └── core - ├── apps.libsonnet # Constructors for `core/v1`, ported from `ksonnet-gen` and `kausal.libsonnet` - ├── autoscaling.libsonnet # Extends `autoscaling/v2beta2` - ├── batch.libsonnet # Constructors for `batch/v1beta1`, `batch/v2alpha1`, ported from `kausal.libsonnet` - ├── core.libsonnet # Constructors for `apps/v1`, `apps/v1beta1`, ported from `ksonnet-gen` and `kausal.libsonnet` + ├── apps.libsonnet # Constructors for `apps/v1` (daemonSet, deployment, statefulSet), ported from `ksonnet-gen` and `kausal.libsonnet` + ├── autoscaling.libsonnet # Extends `autoscaling/v1` and `autoscaling/v2` + ├── batch.libsonnet # Constructors for `batch/v1` (cronJob), ported from `kausal.libsonnet` + ├── core.libsonnet # Constructors for `core/v1`, ported from `ksonnet-gen` and `kausal.libsonnet` ├── list.libsonnet # Adds `core.v1.List` ├── mapContainers.libsonnet # Adds `mapContainers` functions for fields that support them ├── rbac.libsonnet # Adds helper functions to rbac objects diff --git a/cmd/k8s-gen/generate.go b/cmd/k8s-gen/generate.go index 5d9148de..44070a9f 100644 --- a/cmd/k8s-gen/generate.go +++ b/cmd/k8s-gen/generate.go @@ -10,13 +10,13 @@ import ( "path/filepath" "github.com/google/go-jsonnet/formatter" - "github.com/jsonnet-libs/k8s/pkg/complier/jsonschemacomplier" - "github.com/jsonnet-libs/k8s/pkg/config" - "github.com/jsonnet-libs/k8s/pkg/model" - "github.com/jsonnet-libs/k8s/pkg/swagger" - "github.com/jsonnet-libs/k8s/pkg/targetgenerator" - "github.com/jsonnet-libs/k8s/pkg/util" - "github.com/jsonnet-libs/k8s/pkg/writer" + "github.com/thisisibrahimd/k8s/pkg/complier/jsonschemacomplier" + "github.com/thisisibrahimd/k8s/pkg/config" + "github.com/thisisibrahimd/k8s/pkg/model" + "github.com/thisisibrahimd/k8s/pkg/swagger" + "github.com/thisisibrahimd/k8s/pkg/targetgenerator" + "github.com/thisisibrahimd/k8s/pkg/util" + "github.com/thisisibrahimd/k8s/pkg/writer" "github.com/mdobak/go-xerrors" "github.com/santhosh-tekuri/jsonschema/v6" "github.com/urfave/cli/v3" diff --git a/cmd/k8s-gen/root.go b/cmd/k8s-gen/root.go index 897a2963..c1555f5a 100644 --- a/cmd/k8s-gen/root.go +++ b/cmd/k8s-gen/root.go @@ -5,7 +5,7 @@ import ( "log/slog" "os" - "github.com/jsonnet-libs/k8s/pkg/telemetry" + "github.com/thisisibrahimd/k8s/pkg/telemetry" "github.com/urfave/cli/v3" ) diff --git a/go.mod b/go.mod index 033ac31d..ba632249 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/jsonnet-libs/k8s +module github.com/thisisibrahimd/k8s go 1.26.6 diff --git a/goreleaser.yml b/goreleaser.yml index 94f9bf29..6b5b9f5d 100644 --- a/goreleaser.yml +++ b/goreleaser.yml @@ -47,7 +47,7 @@ dockers_v2: - id: k8s-gen dockerfile: "Containerfile" images: - - "ghcr.io/{{ .Env.OWNER }}/k8s-gen" + - "ghcr.io/thisisibrahimd/k8s-gen" extra_files: - LICENSE labels: diff --git a/main.go b/main.go index 0db419a5..0dd2a299 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "log/slog" "os" - cmd "github.com/jsonnet-libs/k8s/cmd/k8s-gen" + cmd "github.com/thisisibrahimd/k8s/cmd/k8s-gen" ) func main() { diff --git a/pkg/builder/docsonnet/docsonnet.go b/pkg/builder/docsonnet/docsonnet.go index a332e5f3..3741369e 100644 --- a/pkg/builder/docsonnet/docsonnet.go +++ b/pkg/builder/docsonnet/docsonnet.go @@ -1,7 +1,7 @@ package docsonnet import ( - j "github.com/jsonnet-libs/k8s/pkg/builder" + j "github.com/thisisibrahimd/k8s/pkg/builder" ) const dPkg = "doc-util/main.libsonnet" diff --git a/pkg/complier/jsonschemacomplier/jsonschemacomplier.go b/pkg/complier/jsonschemacomplier/jsonschemacomplier.go index c99527ac..60ef31fe 100644 --- a/pkg/complier/jsonschemacomplier/jsonschemacomplier.go +++ b/pkg/complier/jsonschemacomplier/jsonschemacomplier.go @@ -3,8 +3,8 @@ package jsonschemacomplier import ( "fmt" - "github.com/jsonnet-libs/k8s/pkg/builder" - "github.com/jsonnet-libs/k8s/pkg/render" + "github.com/thisisibrahimd/k8s/pkg/builder" + "github.com/thisisibrahimd/k8s/pkg/render" "github.com/santhosh-tekuri/jsonschema/v6" "github.com/stoewer/go-strcase" ) diff --git a/pkg/complier/jsonschemacomplier/jsonschemacomplier_test.go b/pkg/complier/jsonschemacomplier/jsonschemacomplier_test.go index a6e96fba..37432830 100644 --- a/pkg/complier/jsonschemacomplier/jsonschemacomplier_test.go +++ b/pkg/complier/jsonschemacomplier/jsonschemacomplier_test.go @@ -4,7 +4,7 @@ import ( "testing" "github.com/google/go-jsonnet/formatter" - "github.com/jsonnet-libs/k8s/pkg/complier/jsonschemacomplier" + "github.com/thisisibrahimd/k8s/pkg/complier/jsonschemacomplier" "github.com/santhosh-tekuri/jsonschema/v6" "github.com/sebdah/goldie/v2" ) diff --git a/pkg/config/config.go b/pkg/config/config.go index 6ab60847..208f768f 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -28,7 +28,6 @@ type TargetGenerator struct { Prefix string `json:"prefix" validate:"required"` VersionLimit *int `json:"versionLimit" validate:"omitempty,min=1,excluded_with=Versions"` IncludeVersions string `json:"includeVersions" default:"^v?\\d+\\.\\d+\\.\\d+$"` - ExcludeVersions string `json:"excludeVersions"` DedupeCrds *bool `json:"dedupeCrds" default:"true"` Versions []string `json:"versions" validate:"excluded_with=VersionLimit"` VersionPrefix *string `json:"versionPrefix" default:"v"` diff --git a/pkg/model/gvk.go b/pkg/model/gvk.go index 66ec1146..40697695 100644 --- a/pkg/model/gvk.go +++ b/pkg/model/gvk.go @@ -6,7 +6,7 @@ import ( "regexp" "strings" - "github.com/jsonnet-libs/k8s/pkg/swagger" + "github.com/thisisibrahimd/k8s/pkg/swagger" ) // Groups represents a list of group diff --git a/pkg/model/load.go b/pkg/model/load.go index df2554bc..22aebc5f 100644 --- a/pkg/model/load.go +++ b/pkg/model/load.go @@ -4,7 +4,7 @@ import ( "fmt" "regexp" - "github.com/jsonnet-libs/k8s/pkg/swagger" + "github.com/thisisibrahimd/k8s/pkg/swagger" ) var expr = regexp.MustCompile(`(?mU)(?P.+)\.((?P\w*)\.)?(?P\w*)\.(?P\w*)$`) diff --git a/pkg/model/modifiers.go b/pkg/model/modifiers.go index 58335211..7cbf9426 100644 --- a/pkg/model/modifiers.go +++ b/pkg/model/modifiers.go @@ -5,7 +5,7 @@ import ( "strings" "github.com/fatih/camelcase" - "github.com/jsonnet-libs/k8s/pkg/swagger" + "github.com/thisisibrahimd/k8s/pkg/swagger" ) type excludeType string diff --git a/pkg/render/modifiers.go b/pkg/render/modifiers.go index 92b6954a..2c5b93c9 100644 --- a/pkg/render/modifiers.go +++ b/pkg/render/modifiers.go @@ -4,10 +4,10 @@ import ( "fmt" "strings" - j "github.com/jsonnet-libs/k8s/pkg/builder" - d "github.com/jsonnet-libs/k8s/pkg/builder/docsonnet" - "github.com/jsonnet-libs/k8s/pkg/model" - "github.com/jsonnet-libs/k8s/pkg/swagger" + j "github.com/thisisibrahimd/k8s/pkg/builder" + d "github.com/thisisibrahimd/k8s/pkg/builder/docsonnet" + "github.com/thisisibrahimd/k8s/pkg/model" + "github.com/thisisibrahimd/k8s/pkg/swagger" ) const ( diff --git a/pkg/render/render.go b/pkg/render/render.go index a8670c9c..ded81690 100644 --- a/pkg/render/render.go +++ b/pkg/render/render.go @@ -4,9 +4,9 @@ import ( "path" "path/filepath" - j "github.com/jsonnet-libs/k8s/pkg/builder" - d "github.com/jsonnet-libs/k8s/pkg/builder/docsonnet" - "github.com/jsonnet-libs/k8s/pkg/model" + j "github.com/thisisibrahimd/k8s/pkg/builder" + d "github.com/thisisibrahimd/k8s/pkg/builder/docsonnet" + "github.com/thisisibrahimd/k8s/pkg/model" ) // Common set of directory structure / file extensions diff --git a/pkg/render/sort.go b/pkg/render/sort.go index 12fbfd9c..4df9159a 100644 --- a/pkg/render/sort.go +++ b/pkg/render/sort.go @@ -4,7 +4,7 @@ import ( "sort" "strings" - j "github.com/jsonnet-libs/k8s/pkg/builder" + j "github.com/thisisibrahimd/k8s/pkg/builder" ) // SortFields sorts Jsonnet fields diff --git a/pkg/render/sort_test.go b/pkg/render/sort_test.go index db40ef52..03515eef 100644 --- a/pkg/render/sort_test.go +++ b/pkg/render/sort_test.go @@ -3,7 +3,7 @@ package render import ( "testing" - j "github.com/jsonnet-libs/k8s/pkg/builder" + j "github.com/thisisibrahimd/k8s/pkg/builder" "github.com/stretchr/testify/assert" ) diff --git a/pkg/targetgenerator/githubtargetgenerator.go b/pkg/targetgenerator/githubtargetgenerator.go index d7088095..d127d3cd 100644 --- a/pkg/targetgenerator/githubtargetgenerator.go +++ b/pkg/targetgenerator/githubtargetgenerator.go @@ -11,8 +11,8 @@ import ( "regexp" "strings" - "github.com/jsonnet-libs/k8s/pkg/config" - "github.com/jsonnet-libs/k8s/pkg/telemetry" + "github.com/thisisibrahimd/k8s/pkg/config" + "github.com/thisisibrahimd/k8s/pkg/telemetry" "github.com/mdobak/go-xerrors" "resty.dev/v3" ) diff --git a/pkg/targetgenerator/targetgenerator.go b/pkg/targetgenerator/targetgenerator.go index 6c983a88..747e57c8 100644 --- a/pkg/targetgenerator/targetgenerator.go +++ b/pkg/targetgenerator/targetgenerator.go @@ -1,7 +1,7 @@ package targetgenerator import ( - "github.com/jsonnet-libs/k8s/pkg/config" + "github.com/thisisibrahimd/k8s/pkg/config" "github.com/mdobak/go-xerrors" ) diff --git a/pkg/writer/disk.go b/pkg/writer/disk.go index 48886683..e117da14 100644 --- a/pkg/writer/disk.go +++ b/pkg/writer/disk.go @@ -6,9 +6,9 @@ import ( "path/filepath" "github.com/google/go-jsonnet/formatter" - "github.com/jsonnet-libs/k8s/pkg/config" - "github.com/jsonnet-libs/k8s/pkg/model" - "github.com/jsonnet-libs/k8s/pkg/render" + "github.com/thisisibrahimd/k8s/pkg/config" + "github.com/thisisibrahimd/k8s/pkg/model" + "github.com/thisisibrahimd/k8s/pkg/render" "github.com/mdobak/go-xerrors" ) diff --git a/pkg/writer/writer.go b/pkg/writer/writer.go index 15059ca9..a01efbd9 100644 --- a/pkg/writer/writer.go +++ b/pkg/writer/writer.go @@ -1,8 +1,8 @@ package writer import ( - "github.com/jsonnet-libs/k8s/pkg/config" - "github.com/jsonnet-libs/k8s/pkg/model" + "github.com/thisisibrahimd/k8s/pkg/config" + "github.com/thisisibrahimd/k8s/pkg/model" ) type Writer interface {