{"id":18810357,"url":"https://github.com/absaoss/gopkg","last_synced_at":"2026-01-10T18:30:12.875Z","repository":{"id":44612056,"uuid":"308353278","full_name":"AbsaOSS/gopkg","owner":"AbsaOSS","description":"Absa Go package library","archived":false,"fork":false,"pushed_at":"2022-02-04T15:45:58.000Z","size":87,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-12-29T23:25:50.867Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/AbsaOSS.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":"CODEOWNERS","security":null,"support":null}},"created_at":"2020-10-29T14:27:45.000Z","updated_at":"2022-02-04T14:12:31.000Z","dependencies_parsed_at":"2022-09-26T18:41:55.421Z","dependency_job_id":null,"html_url":"https://github.com/AbsaOSS/gopkg","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/AbsaOSS%2Fgopkg","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgopkg/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgopkg/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AbsaOSS%2Fgopkg/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AbsaOSS","download_url":"https://codeload.github.com/AbsaOSS/gopkg/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239744096,"owners_count":19689602,"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-11-07T23:19:56.798Z","updated_at":"2026-01-10T18:30:12.780Z","avatar_url":"https://github.com/AbsaOSS.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gopkg\n\nAbsa Go package library\n\n## Absa library\n\n- [controller](#controller)\n- [dns](#dns)\n- [env](#env)\n- [k8s](#k8s)\n- [reflect](#reflect)  \n- [shell](#shell)\n- [strings](#string)\n\n### controller\npackage controller extends sigs.k8s.io/controller-runtime [os.Getenv](https://golang.org/pkg/os/#Getenv).\n#### Overview\nPackage contains `ReconcileResult` which provides abstraction over reconciliation loop management.\n\n#### Usage\n```go\nconst reconcileSeconds = 10\nresult := utils.NewReconcileResult(time.Duration(reconcileSeconds) * time.Second)\n...\nfunc (r *MyReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) {\n\t...\n\tif finish {\n\t\t// sucesfuly stop reconciliation loop\n\t\treturn result.Stop()\n\t}\n\tif err := doSomething(); err != nil {\n\t\t// requeue loop immediately with error\n\t\treturn result.RequeueError(err)\n\t}\n\t// requeue loop after reconcileSeconds \n\treturn result.Requeue()\n}\n```\n\n### dns\nDNS contains helper functions related to DNS.\n#### Overview\nPackage currently contains Dig function retrieving \nslice of tuples \u003cIP address, A record \u003e for specific FQDN.\n#### Usage\n```go\n\tedgeDNSServer := \"8.8.8.8\"\n\tfqdn := \"google.com\"\n\tresult, err := Dig(edgeDNSServer, fqdn)\n```\n\n### env\nEnvironment variable helper extending standard [os.Getenv](https://golang.org/pkg/os/#Getenv).\n#### Overview\nPackage contains several functions which returns the typed env variable for the given \nkey and falls back to the default value if not set.\n#### Usage\n```go\nnoProxy := env.GetEnvAsStringOrFallback(\"NO_PROXY\", \"*.foo.bar.com\")\n \nrunOnStart := env.GetEnvAsStringOrFallback(\"RUN_ON_START\", true)\n```\n\n### k8s\nPackage k8s provides extensions for k8s apimachinery/pkg/apis\n#### Overview\nPackage contains following functions:\n - `MergeAnnotations(target *metav1.ObjectMeta, source *metav1.ObjectMeta)` adds or updates annotations from \n   defaultSource to defaultTarget\n - `ContainsAnnotations(target *metav1.ObjectMeta, source *metav1.ObjectMeta) bool` checks if defaultTarget \n   contains all annotations of defaultSource\nAny kubernetes resource having ObjectMeta can be passed.  \n#### Usage\n```go\nif !k8s.ContainsAnnotations(currentIngress.ObjectMeta, expectedIngress.ObjectMeta) {\n    MergeAnnotations(currentIngress.ObjectMeta, expectedIngress.ObjectMeta)\n}\n```\n\n### shell\nShell command runner \n#### Overview\nPackage shell is used for running executables and returns command output for further processing. It is a synchronized \nwrapper around the standard Go [command](https://golang.org/pkg/os/exec/#Cmd) package, which allows you to define environment variables in a native way \nand returns the output as a return value.\n#### Usage\n```go\ncmd := shell.Command{\n\tCommand: \"sh\",\n\tArgs: []string{\"-c\", \"terraform apply -auto-approve tfplan\"},\n\tEnv: map[string]string{\"name\":\"test\"},\n}\no, _ = shell.Execute(cmd)\n```\n\n### string\nPackage string provide helper functions related to string\n#### Overview\nPackage string contains extensions of standard strings and formatting functions:\n- `ToString(v interface{}) string` ToString converts type to formatted string. If value is struct, function returns formatted JSON.\n\n#### Usage\n```go\nlog.Debug().Msgf(\"current config: %s\",utils.ToString(config))\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsaoss%2Fgopkg","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabsaoss%2Fgopkg","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabsaoss%2Fgopkg/lists"}