{"id":15516226,"url":"https://github.com/dippynark/kfmt","last_synced_at":"2025-04-23T03:28:38.367Z","repository":{"id":38328990,"uuid":"331943153","full_name":"dippynark/kfmt","owner":"dippynark","description":"Organises Kubernetes manifests into a standard format","archived":false,"fork":false,"pushed_at":"2024-12-21T23:38:32.000Z","size":493,"stargazers_count":16,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T21:41:21.104Z","etag":null,"topics":["gitops","kubernetes-manifests"],"latest_commit_sha":null,"homepage":"","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/dippynark.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":"2021-01-22T12:42:59.000Z","updated_at":"2025-03-29T21:24:57.000Z","dependencies_parsed_at":"2024-06-19T04:12:15.630Z","dependency_job_id":"a83edfb0-f1f1-4079-b78e-787839746762","html_url":"https://github.com/dippynark/kfmt","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dippynark%2Fkfmt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dippynark%2Fkfmt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dippynark%2Fkfmt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dippynark%2Fkfmt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dippynark","download_url":"https://codeload.github.com/dippynark/kfmt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250364083,"owners_count":21418412,"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":["gitops","kubernetes-manifests"],"created_at":"2024-10-02T10:06:14.806Z","updated_at":"2025-04-23T03:28:38.346Z","avatar_url":"https://github.com/dippynark.png","language":"Go","readme":"# kfmt\n\nkfmt takes input files and directories containing Kubernetes manifests and organises them into a\nstandard format:\n\n```t\n# Output directory\noutput\n|   # Directory containing cluster scoped resources\n├── cluster\n|   |   # Each cluster scoped resource is given a directory named after its plural and group\n│   └── \u003cplural\u003e.\u003cgroup\u003e\n|       |   # Files are named after the resource name\n│       └── \u003cname\u003e.yaml\n|   # Directory containing namespace scoped resources\n└── namespaces\n    |   # Each Namespace is given its own directory\n    └── \u003cnamespace\u003e\n        |   # Files are named after the resource name, kind and group\n        └── \u003ckind\u003e.\u003cgroup\u003e-\u003cname\u003e.yaml\n```\n\nInspiration is taken from a number of other tools:\n\n- [manifest-splitter](https://github.com/munnerz/manifest-splitter)\n- [nomos](https://cloud.google.com/anthos-config-management/docs/how-to/nomos-command)\n- [jx gitops split](https://github.com/jenkins-x/jx-gitops/blob/master/docs/cmd/jx-gitops_split.md)\n- [jx gitops\n  rename](https://github.com/jenkins-x/jx-gitops/blob/master/docs/cmd/jx-gitops_rename.md)\n- [jx gitops helmfile\n  move](https://github.com/jenkins-x/jx-gitops/blob/master/docs/cmd/jx-gitops_helmfile_move.md)\n\n## Use Cases\n\nkfmt is useful in any situation where it's beneficial to have a collection of manifests organised\ninto a standard format. This could be to tidy up a large collection of manifests or just to make\nthem easier to browse.\n\nGitOps tools such as [Flux](https://github.com/fluxcd/flux2) and [Anthos Config\nManagement](https://cloud.google.com/anthos/config-management) that sync manifests from a Git\nrepository could also benefit from kfmt by running it as a final step in CI, taking in all the\nmanifests to be synced and verifying there are no clashes. Using the `kfmt.dev/namespaces`\nannotation can also be used to copy policy resources across Namespaces and having a standard format\nmay make any changes easier to review.\n\n## Installation\n\n```sh\nGO111MODULE=on go get github.com/dippynark/kfmt\n```\n\nkfmt is also distributed as a [binary](https://github.com/dippynark/kfmt/releases) and a [Docker\nimage](https://hub.docker.com/repository/docker/dippynark/kfmt).\n\n## Usage\n\nThe simplest usage is to format manifests coming from stdin:\n\n```sh\ncat \u003c\u003cEOF | kfmt -o output\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: test\n---\napiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: test\n---\napiVersion: v1\nkind: Secret\nmetadata:\n  name: test\n  namespace: test\nEOF\n```\n\nThe full help text is show below:\n\n```text\nkfmt organises Kubernetes manifests into a standard format.\n\nUsage:\n  kfmt [flags]\n\nFlags:\n      --clean                       Remove metadata.namespace field from non-namespaced resources\n      --comment                     Comment each output file with the path of the corresponding input file\n      --create-missing-namespaces   Create missing Namespace manifests\n  -d, --discovery                   Use API Server for discovery\n  -f, --filter stringArray          Filter Kind.group from output manifests (e.g. Deployment.apps or Secret)\n  -g, --gvk-scope stringArray       Add GVK scope mapping Kind.group/version:Cluster or Kind.group/version:Namespaced to discovery\n  -h, --help                        Print help text\n  -i, --input stringArray           Input files or directories containing manifests. If no input is specified /dev/stdin will be used\n  -k, --kubeconfig string           Path to the kubeconfig file used for discovery (default \"/.kube/config\")\n  -n, --namespace string            Set metadata.namespace field if missing from namespaced resources (default \"default\")\n  -o, --output string               Output directory to write organised manifests\n      --overwrite                   Overwrite existing output files\n      --remove                      Remove processed input files\n      --strict                      Require metadata.namespace field is not set for non-namespaced resources\n  -v, --version                     Print version\n```\n\nNamespaced resources can be annotated as follows:\n\n```\nkfmt.dev/namespaces: \"namespace1,namespace2,...\"\n```\n\nThe resource will be copied into each named Namespace that does already contain a matching resource\nof the same name. Note that each Namespace must be present in the manifests being processed, either\ndue to a Namespace resource being defined or any namespaced resource being in that Namespace.\nAlternatively, the special value `*` can be used and the resource will be copied into every\nNamespace; prefixing a Namespace name with `-` excludes that Namespace.\n\n### Discovery\n\nkfmt needs to know whether a particular\n[GVK](https://book.kubebuilder.io/cronjob-tutorial/gvks.html) maps to a namespaced resource or not\nto know how to organise the input manifests. kfmt understands core Kubernetes resources and supports\ndiscovering mappings for custom resources by reading CRDs in the input manifests, using the\n`--gvk-scope` flag or reading cached discovery information, which can be produced by writing it to\ndisk:\n\n```sh\nkubectl api-resources \u003e api-resources.txt\n```\n\nSimilarly, this cached discovery information can be augmented with all available versions:\n\n```sh\nkubectl api-versions \u003e api-versions.txt\n```\n\nIn addition, kfmt supports the `--discovery` flag to enable use of the Kubernetes discovery API.\nkfmt will only attempt to use the Kubernetes discovery API if the required discovery information is\nnot provided using another method.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdippynark%2Fkfmt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdippynark%2Fkfmt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdippynark%2Fkfmt/lists"}