{"id":16057773,"url":"https://github.com/kubism/testutil","last_synced_at":"2026-06-20T04:31:26.885Z","repository":{"id":57534259,"uuid":"281155226","full_name":"kubism/testutil","owner":"kubism","description":"Collection of helpers to ease implementing integration tests utilizing kind, helm and kubernetes","archived":false,"fork":false,"pushed_at":"2020-10-21T12:39:57.000Z","size":365,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-09T21:37:54.383Z","etag":null,"topics":["helm","kind","kubernetes","testing"],"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/kubism.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":"2020-07-20T15:29:46.000Z","updated_at":"2021-01-04T10:49:49.000Z","dependencies_parsed_at":"2022-09-26T18:21:30.911Z","dependency_job_id":null,"html_url":"https://github.com/kubism/testutil","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/kubism/testutil","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubism%2Ftestutil","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubism%2Ftestutil/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubism%2Ftestutil/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubism%2Ftestutil/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubism","download_url":"https://codeload.github.com/kubism/testutil/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubism%2Ftestutil/sbom","scorecard":{"id":572821,"data":{"date":"2025-08-11","repo":{"name":"github.com/kubism/testutil","commit":"3bfc9a3eb769a6f2f90edd17642fbfd1c77f991e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":1.7,"checks":[{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"19 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-9vp5-m38w-j776","Warn: Project is vulnerable to: GHSA-c52f-pq47-2r9j","Warn: Project is vulnerable to: GHSA-jm56-5h66-w453","Warn: Project is vulnerable to: GHSA-m54r-vrmv-hw33","Warn: Project is vulnerable to: GO-2022-1040 / GHSA-c38g-469g-cmgx","Warn: Project is vulnerable to: GO-2022-0384 / GHSA-56hp-xqp3-w2jf","Warn: Project is vulnerable to: GO-2022-0962 / GHSA-7hfp-qfw3-5jxh","Warn: Project is vulnerable to: GO-2022-1165 / GHSA-53c4-hhmh-vw5q","Warn: Project is vulnerable to: GO-2022-1166 / GHSA-67fx-wx78-jx33","Warn: Project is vulnerable to: GO-2022-1167 / GHSA-6rx9-889q-vv2r","Warn: Project is vulnerable to: GO-2023-1547 / GHSA-pwcw-6f5g-gxf8","Warn: Project is vulnerable to: GO-2024-2554 / GHSA-v53g-5gjp-272r","Warn: Project is vulnerable to: GO-2024-2575 / GHSA-r53h-jv2g-vpx6","Warn: Project is vulnerable to: GO-2025-3601 / GHSA-4hfp-h4cw-hj8p","Warn: Project is vulnerable to: GO-2025-3602 / GHSA-5xqw-8hwv-wg92","Warn: Project is vulnerable to: GO-2025-3802 / GHSA-557j-xg8c-q2mm","Warn: Project is vulnerable to: GHSA-9h84-qmv7-982p","Warn: Project is vulnerable to: GHSA-f9f8-9pmf-xv68","Warn: Project is vulnerable to: GO-2021-0064 / GHSA-8cfg-vx93-jvxw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-20T16:47:54.283Z","repository_id":57534259,"created_at":"2025-08-20T16:47:54.283Z","updated_at":"2025-08-20T16:47:54.283Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34557551,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["helm","kind","kubernetes","testing"],"created_at":"2024-10-09T03:04:40.282Z","updated_at":"2026-06-20T04:31:26.863Z","avatar_url":"https://github.com/kubism.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `testutil`\n\n[![Go Documentation](https://img.shields.io/badge/go-doc-blue.svg?style=flat)](https://pkg.go.dev/github.com/kubism/testutil/pkg)\n[![Build Status](https://travis-ci.org/kubism/testutil.svg?branch=master)](https://travis-ci.org/kubism/testutil)\n[![Go Report Card](https://goreportcard.com/badge/github.com/kubism/testutil)](https://goreportcard.com/report/github.com/kubism/testutil)\n[![Coverage Status](https://coveralls.io/repos/github/kubism/testutil/badge.svg?branch=master)](https://coveralls.io/github/kubism/testutil?branch=master)\n[![Maintainability](https://api.codeclimate.com/v1/badges/b75c438fc0c263a21024/maintainability)](https://codeclimate.com/github/kubism/testutil/maintainability)\n\nThis library is a collection of helpers to ease implementing integration tests \nutilizing [kind](https://github.com/kubernetes-sigs/kind), [helm](https://github.com/helm/helm) \nand [kubernetes](https://github.com/kubernetes/kubernetes) without the need to install any CLI tools.\n\nIf it improves the code readability and ergonomics, the library will utilize\n`panic` for rare errors, e.g. filesystem issues, and performance is not a\nprimary requirement.\nTherefore it should not be used as part of a production service.\n\n## Getting started\n\nBefore we can interact with a kubernetes cluster, we have to either create one\nor connect to an existing one. If you just want to connect to an external cluster\nfeel free to skip the following section.\n\n### Creating a kind cluster\n\nCreate a new kind cluster with a randomized name is as simple as running:\n```go\ncluster, err := kind.NewCluster()\nif err != nil {}\ndefer cluster.Close()\n```\nHowever in most use-cases you want to provide more options to kind to\nconfigure it as you require it. You might want to set a deadline for the creation\nor use an existing cluster.\n```go\nclusterOptions := []kind.ClusterOption{\n    kind.ClusterWithWaitForReady(2*time.Minute),\n}\nif existingClusterName != \"\" {\n    clusterOptions = append(clusterOptions,\n        kind.ClusterWithName(existingClusterName),\n        kind.ClusterUseExisting(),\n        kind.ClusterDoNotDelete(),\n    )\n}\ncluster, err := kind.NewCluster(clusterOptions...)\nif err != nil {}\ndefer cluster.Close() // If do not delete is set, the cluster will not be deleted\n```\n\nThe node image used by kind can be specified via `kind.ClusterWithNodeImage`.\nBy default this will fallback to a sensible default, but should be set to the\nkubernetes version of your choice.\n\nIf you require even deeper configurability, you can pass in a\n[cluster definition](https://godoc.org/github.com/kubernetes-sigs/kind/pkg/apis/config/v1alpha4#Cluster)\nvia `kind.ClusterWithConfig`.\n\n### Setting up helm\n\nBefore the helm-client can be setup you have to retrieve the raw kubeconfig.\n\n__NOTE__:_This will most likely change to `rest.Config` at some point in the future._\n\nFor an existing `kind.Cluster` this will look as follows:\n```go\nkubeConfig, err := cluster.GetKubeConfig()\nif err != nil {}\n```\nWith the kubeconfig at our disposal the client can then be created:\n```go\nhelmClient, err = helm.NewClient(kubeConfig)\nif err != nil {}\ndefer helmClient.Close()\n```\nIt is important to always clean up the `helm.Client` via `Close` as it manages\nits own temporary cache and repository indices, which will otherwise leak.\n\nTo be able to install a remote chart, you will have to add your repositories, e.g.:\n```go\nerr := helmClient.AddRepository(\u0026helm.RepositoryEntry{\n    Name: \"bitnami\",\n    URL:  \"https://charts.bitnami.com/bitnami\",\n})\nif err != nil {}\n```\n\n### Installing a chart\n\nYou can install both remote and local charts. In context of this getting started\nguide we will install the `bitnami/nginx`-chart:\n```go\nrls, err := helmClient.Install(\"bitnami/nginx\", \"\", helm.ValuesOptions{})\nif err != nil {}\n```\nThe second parameter is the `version` to use. If it is an empty string, the most\nrecent version will be installed.\n\n`helm.ValuesOptions` is a struct offering several ways to provide both from\nfilesystem and by definition. Before those are used they are merged according\nto helm's conventions.\n\nBy default a release name will be generated, but can be retrieved from the\nreturned `helm.Release`.\n\nThe install procedure can be further customized using `InstallOption`s. For\nexample to use a predefined release name:\n```go\nrls, err := client.Install(\"bitnami/nginx\", \"\", ValuesOptions{},\n    InstallWithReleaseName(name),\n)\nif err != nil {}\n```\n\n### Interacting with kubernetes objects\n\nFor most tests you will not stop after installing a helm chart, but rather\nyou want to interact with the resulting objects.\n\nSo to show off some of the available helpers, let's create a `kube.Client`\n(also embed the kubernetes controller-runtime client) and illustrate some\nof its usage.\n```go\nrestConfig, err = cluster.GetRESTConfig()\nif err != nil {}\nk8sClient, err = NewClient(restConfig)\nif err != nil {}\n```\nLet's create a context with a timeout first, so that commands can not exceed\na deadline in our tests:\n```go\nctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute)\ndefer cancel()\n```\nThe installed `nginx` has a Deployment, so let's retrieve it first:\n```go\ndeployment := kube.DeploymentWithNamespacedName(rls.Namespace, rls.Name+\"-nginx\")\nerr := k8sClient.Get(ctx, NamespacedName(deployment), deployment)\nif err != nil {}\n```\nWe want to retrieve the scheduled pod, but at the beginning it won't be available,\nso let's wait until the deployment is scheduled.\n```go\nerr := k8sClient.WaitUntil(ctx, kube.DeploymentIsScheduled(deployment))\nif err != nil {}\n```\nOnce we know the deployment was scheduled, we can either retrieve pods with the\nrequired labels via `k8sClient.List` or for demonstration purposes find the\nreplicasets for the deployment and then the pods for the active replicaset\n(using `k8sClient.ListForOwner` also particularly useful for jobs):\n```go\nreplicaSetList := \u0026appsv1.ReplicaSetList{}\nerr := k8sClient.ListForOwner(context.Background(), replicaSetList, deployment)\nif err != nil {}\nif len(replicaSetList) \u003c 1 {}\nreplicaSet := \u0026replicaSetList.Items[0]\nerr = k8sClient.WaitUntil(ctx, kube.ReplicaSetIsAvailable(replicaSet), kube.ReplicaSetIsReady(replicaSet))\nif err != nil {}\npodList := \u0026corev1.PodList{}\nerr = k8sClient.ListForOwner(ctx, podList, replicaSet)\nif err != nil {}\nif len(podList) \u003c 1 {}\npod := \u0026podList.Items[0]\n```\nNow we actually retrieved our nginx pod. At this point we probably want to\ninteract with the pod, e.g. create a port forward, however let's wait until the\npod it ready to retrieve traffic first:\n```go\nerr := k8sClient.WaitUntil(ctx, kube.PodIsReady(\u0026pod))\nif err != nil {}\n```\nThe pod is ready, so we can create a port-forward:\n```go\npf, err := k8sClient.PortForward(pod, PortAny, 8080)\nif err != nil {}\ndefer pf.Close()\n```\nThe above code will use an available port on the host rather than a predefined one.\nSo connecting to nginx might look as follows:\n```go\n_, err := http.Get(fmt.Sprintf(\"http://localhost:%d\", pf.LocalPort))\n```\n\nFor some integration tests it might make sense to retrieve logs of a pod,\nconveniently `k8sClient.Logs` is here to help:\n```go\nlogs, err := k8sClient.LogsString(ctx, pod)\n```\n\nLast but not least events for a specific object can be retrieved using\n`k8sClient.Events`. This is particularly useful for operators which interact\nwith several resources and create events for their interactions:\n```go\nevents, err := k8sClient.Events(ctx, pod)\n```\n\n## Notes (temporary)\n\n* uses panic do not use in live code just tests\n* `make TEST_FLAGS=\"-kind-cluster=testutil\" test`\n* still missing ds, statefulsets\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubism%2Ftestutil","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubism%2Ftestutil","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubism%2Ftestutil/lists"}