{"id":15012961,"url":"https://github.com/sovereigncloudstack/capi-jsgen","last_synced_at":"2026-01-25T16:31:35.723Z","repository":{"id":248881542,"uuid":"826745251","full_name":"SovereignCloudStack/capi-jsgen","owner":"SovereignCloudStack","description":"CAPI json-schema generator, part of SovereignCloudStack/cluster-gen","archived":false,"fork":false,"pushed_at":"2024-11-06T15:40:12.000Z","size":225,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-02-18T19:19:53.647Z","etag":null,"topics":["k8s"],"latest_commit_sha":null,"homepage":"https://cluster-gen.moin.k8s.scs.community","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SovereignCloudStack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-10T09:43:00.000Z","updated_at":"2024-11-06T15:40:14.000Z","dependencies_parsed_at":"2024-09-20T08:01:33.539Z","dependency_job_id":"21073d06-e16c-442a-bc91-b1e3ebf23667","html_url":"https://github.com/SovereignCloudStack/capi-jsgen","commit_stats":{"total_commits":13,"total_committers":2,"mean_commits":6.5,"dds":0.07692307692307687,"last_synced_commit":"12bebcd9e0159b383e9966728a8c259d844e0591"},"previous_names":["sovereigncloudstack/capi-jsgen"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fcapi-jsgen","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fcapi-jsgen/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fcapi-jsgen/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SovereignCloudStack%2Fcapi-jsgen/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SovereignCloudStack","download_url":"https://codeload.github.com/SovereignCloudStack/capi-jsgen/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239533064,"owners_count":19654617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["k8s"],"created_at":"2024-09-24T19:43:31.648Z","updated_at":"2025-11-07T16:30:33.561Z","avatar_url":"https://github.com/SovereignCloudStack.png","language":"Go","readme":"# Introduction\nThe tool `capi-jsgen` creates json-schemas for cluster-API Clusters which reference a ClusterClass. The primary use-case for these schemas is to create UI-Forms out of it, but they can be used in other contexts as well.\n\n# Concept\nThe generic Cluster specification is merged with a ClusterClass to create a specialized version of the Cluster specification. The tailoring takes place by copying the variable schemas from a ClusterClass to the generic Cluster spec. Additional to that, `capi-jsgen` can set default values for the ClusterClass, the MachineDeployment class and the namespace. Most likely you do not want certain fields like  `.status` or `.metadata.gereration` in your UI. It is possible to remove or customize this by changing the \"base schema\". This is the schema that `capi-jsgen` works on to create specialized cluster-schemas. If you want to create a custom baseschema have a look at the [baseschema-builder](hack/baseschema-builder) it contains a good starting point to create your custom baseschema.\n```\n     generic cluster-spec\n+-----------------------------+\n|apiVersion: cluster.x-k8s.io |          \n|kind: Cluster                |                 specialized cluster-spec\n|spec:                        |----+        +-----------------------------+\n|  topology:                  |    |        |apiVersion: cluster.x-k8s.io |\n|    variables: \u003c[]Object\u003e    |    |        |kind: Cluster                |\n+-----------------------------+    |        |spec:                        |\n                                   |        |  topology:                  |\n                                   |        |    class: example-cc        |\n                                   +-------\u003e|    variables:               |\n                                   |        |      - name var1            |\n     specific clusterclass         |        |        schema: sc1          |\n+-----------------------------+    |        |      - name var2            |\n|apiVersion: cluster.x-k8s.io |    |        |        schema: sc2          |\n|kind: ClusterClass           |    |        +-----------------------------+\n|name: example-cc             |    |        \n|spec:                        |    |     \n|  variables:                 |----+     \n|    - name: var1             |          \n|      schema: sc1            |          \n|    - name: var2             |          \n|      schema: sc2            |          \n+-----------------------------+\n```\nNotice that the above graphic recklessly mixes specification (Cluster) and instances (ClusterClass). It is not correct in every detail and only meant to get a quick idea of the concept.\n# Usage\n```\nUsage of ./capi-jsgen:\n  -baseschema string\n        path to baseschema file (default \"data/baseschema.json\")\n  -cache string\n        Duration how long API-responses are cached (default \"1h\")\n  -default-clusterclass\n        When set, the clusterclass is used as default for .spec.topology.class (default true)\n  -default-machineclass\n        When set, the clusterclass name is used as default for .spec.topology.workers.machineDeployments.class (default true)\n  -default-namespace\n        When set, the namespace of the clusterclass is used as default for .metadata.namespace (default true)\n  -listen string\n        listen address (default \":8080\")\n  -local\n        run in local mode\n  -required\n        only include required variables into the schema\n\n```\n# Helm-Chart\n# API\nThere are two API endpoints that can be consumed. The first one offers information about the namespaces and the offered cluster-classes in the cluster. The second API offers Cluster schemas that are specific for a clusterclass in a namespace.\n## `GET /clusterclasses`\n## `GET /clusterschema/{namespace}/{clusterclass}`\n\n# Background\n[Kubernetes](https://kubernetes.io) stores structured objects (_resources_) in its database. Before saving a new _resource_ to its database, the _kubernetes-apiserver_ validates whether the _resource_ adheres to a certain structure. You can describe the desired structure (_schema_) for a kubernetes _resource_ using `kubectl explain`. If you do so, `kubectl` retrieves the corresponding _schema_ from the _kubernetes-apiserver_ under `\u003cserver\u003e/openapi/v3`. The format of this _schema_ is  [json-schema](https://json-schema.org), a standard to describe the validity of a structured object. This _schema_ can be used to generate documentation, display a help-text (`kubectl explain`), generate a GUI or validate whether an object adheres to the required structure in the _schema_.\n\nIf a _resource_ is validated by the _schema_ this is only a necessary condition for it to be accepted by the _kubernetes-apiserver_. The schema validation alone is not sufficient to guarantee that the _resource_ is accepted by the _kubernetes-apiserver_. For example, there can be webhooks that impose additional, stricter requirements upon the structure of the _resource_.\n\n[cluster-API](https://github.com/kubernetes-sigs/cluster-api) is an extension to the _kubernetes-apiserver_. It introduces several new _resource definitions_ ([CRDs](https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/)). The purpose of those _CRDs_ is to define the _schema_ of _resources_ that are used to define kubernetes clusters. An important, central _schema_ is called [Cluster](https://doc.crds.dev/github.com/kubernetes-sigs/cluster-api/cluster.x-k8s.io/Cluster/v1beta1@v1.7.3). It can be used in two ways (simplified):\n1. manually set all required values\n2. use a templating mechanism called [ClusterClass](https://cluster-api.sigs.k8s.io/tasks/experimental-features/cluster-class/) and only feed variables to customize the output of the template\n\nBoth approaches use the same _schema_. The part in the _schema_ (_subschema_) that defines the format of the variables is loosely defined. Basically, it accepts arbitrary key-value pairs. This makes sense because this _schema_ has to validate all thinkable instances of [Cluster](https://doc.crds.dev/github.com/kubernetes-sigs/cluster-api/cluster.x-k8s.io/Cluster/v1beta1@v1.7.3), no matter which variables are used by a ClusterClass or if a ClusterClass is used at all.\n\nThe loose definition of the variables makes the generic Cluster _schema_ a bad choice for creating a form or validating if a Cluster adheres to the required variables in a specific ClusterClass. The validation process for a Cluster that uses a ClusterClass is as follows:\n1. Read the referenced ClusterClass from `.spec.topology.class` from the Cluster _resource_.\n2. Use the referenced ClusterClass obtained in the prior step to read the variables and their _schemas_ from `.status.variables` \n3. Validate all variables set in the Cluster resource under `.spec.topology.variables` against the variable _schemas_ obtained in the prior step\n \n\u003cquote\u003e`capi-jsgen` creates a concrete _schema_ out of the generic Cluster _schema_ and the variables of a concrete ClusterClass by embedding the variable _schemas_ of the ClusterClass into the Cluster _schema_.\u003c/quote\u003e\n\n# Limitations\n* only inline Patches work (no Runtime-SDK support), but configurable behaviour for `definitionsConflict: true` is planned\n* CEL is not supported, probably as long as it is not part of json-schema\n# Glossary\n##### resource\nA kubernetes object. Its structure can be validated by its _schema_.\n##### schema\nA description of the structure of an object.\n##### subschema\nA description of a part of the structure of an object. Part of a _schema_.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovereigncloudstack%2Fcapi-jsgen","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsovereigncloudstack%2Fcapi-jsgen","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsovereigncloudstack%2Fcapi-jsgen/lists"}