{"id":23180996,"url":"https://github.com/replicatedhq/plumber","last_synced_at":"2025-04-05T03:13:51.007Z","repository":{"id":65632727,"uuid":"596184649","full_name":"replicatedhq/plumber","owner":"replicatedhq","description":"Pipes objects from Yaml to Kubernetes API.","archived":false,"fork":false,"pushed_at":"2023-04-13T09:58:52.000Z","size":7067,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-03-23T03:33:15.357Z","etag":null,"topics":[],"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/replicatedhq.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}},"created_at":"2023-02-01T16:40:39.000Z","updated_at":"2023-02-01T16:54:04.000Z","dependencies_parsed_at":"2023-02-17T22:16:26.288Z","dependency_job_id":null,"html_url":"https://github.com/replicatedhq/plumber","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicatedhq%2Fplumber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicatedhq%2Fplumber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicatedhq%2Fplumber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/replicatedhq%2Fplumber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/replicatedhq","download_url":"https://codeload.github.com/replicatedhq/plumber/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247280270,"owners_count":20912967,"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":[],"created_at":"2024-12-18T08:14:05.019Z","updated_at":"2025-04-05T03:13:50.991Z","avatar_url":"https://github.com/replicatedhq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Plumber\n\nPlumber is a Go package that allows managing objects creation and patching,\npiping them from YAML to its concrete in-cluster representation. This package\nleverages Kustomize and its goal is to make object creation and management\neasier.\n\n## Example\n\nTo see the full example please see https://github.com/replicatedhq/plumber/tree/main/example\n\n```go\n// start by embedding all YAML files we are going to render and create.\n//go:embed kustomize\nvar resources embed.FS\n\nfunc main() {\n\tcli, err := client.New(config.GetConfigOrDie(), client.Options{})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// if we have objects that are not part of the objects supported by the\n\t// default controller runtime client we can register them here. below\n\t// we register the kurl types so we can create them in the cluster. if\n\t// no client can't be found to provide a concrete implementation of a\n\t// given type then we have to use Unstructured instead, see below.\n\tkurlkinds.AddToScheme(cli.Scheme())\n\n\toptions := []plumber.Option{\n\t\t// when using WithUnstructured objects are kept as Unstructured,\n\t\t// no conversion to concrete objects are made by the library. be\n\t\t// aware that whenever you use this the Mutator will receive an\n\t\t// Unstructured object instead of a concrete type (Pod, Service,\n\t\t// Deployment, etc).\n\t\t// plumber.WithUnstructured(),\n\t\tplumber.WithObjectMutator(\n\t\t\tfunc(ctx context.Context, obj client.Object) error {\n\t\t\t\t// here we can edit the objects before they are\n\t\t\t\t// created in the cluster. if using Unstructured\n\t\t\t\t// the object is going to be of type Unstructured.\n\t\t\t\tdeploy, ok := obj.(*appsv1.Deployment)\n\t\t\t\tif !ok {\n\t\t\t\t\treturn nil\n\t\t\t\t}\n\n\t\t\t\t// as an example we append an annotation to the nginx\n\t\t\t\t// deployment we are creating.\n\t\t\t\tif deploy.Annotations == nil {\n\t\t\t\t\tdeploy.Annotations = map[string]string{}\n\t\t\t\t}\n\t\t\t\tdeploy.Annotations[\"this-is-a-mutation\"] = \"foo\"\n\t\t\t\treturn nil\n\t\t\t},\n\t\t),\n\t\tplumber.WithKustomizeMutator(\n\t\t\tfunc(ctx context.Context, k *types.Kustomization) error {\n\t\t\t\t// here we can edit the \"kustomization.yaml\"\n\t\t\t\t// before yaml files are rendered.\n\t\t\t\treturn nil\n\t\t\t},\n\t\t),\n\t\tplumber.WithFSMutator(\n\t\t\tfunc(ctx context.Context, fs filesys.FileSystem) error {\n\t\t\t\t// here we can edit the filesystem before yaml files are\n\t\t\t\t// rendered with kustomize.\n\t\t\t\treturn nil\n\t\t\t},\n\t\t),\n\t}\n\n\t// for sake of having a complete example, here we apply different overlays\n\t// on top of the base deployment.\n\trenderer := plumber.NewRenderer(cli, resources, options...)\n\tfor _, overlay := range []string{\"base\", \"scale-up\", \"scale-down\"} {\n\t\tif err := renderer.Render(context.Background(), overlay); err != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Printf(\"overlay %q applied\\n\", overlay)\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplicatedhq%2Fplumber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freplicatedhq%2Fplumber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freplicatedhq%2Fplumber/lists"}