{"id":18293115,"url":"https://github.com/kubesphere/client-go","last_synced_at":"2025-04-05T11:30:51.777Z","repository":{"id":97853537,"uuid":"344052926","full_name":"kubesphere/client-go","owner":"kubesphere","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-02T11:22:46.000Z","size":251,"stargazers_count":9,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-13T21:23:17.563Z","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/kubesphere.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","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}},"created_at":"2021-03-03T08:21:43.000Z","updated_at":"2024-04-17T12:23:37.514Z","dependencies_parsed_at":"2024-03-25T18:23:22.801Z","dependency_job_id":"b8e6e51a-7c3b-462f-ba5d-4e13c2dba9c8","html_url":"https://github.com/kubesphere/client-go","commit_stats":{"total_commits":32,"total_committers":10,"mean_commits":3.2,"dds":0.75,"last_synced_commit":"bc196c9414fd577609f4e9f90b18bb958c37472b"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fclient-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fclient-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fclient-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kubesphere%2Fclient-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kubesphere","download_url":"https://codeload.github.com/kubesphere/client-go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247330449,"owners_count":20921633,"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-05T14:22:09.754Z","updated_at":"2025-04-05T11:30:51.483Z","avatar_url":"https://github.com/kubesphere.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KubeSphere client-go Project\n\nThe KubeSphere client-go Project is a rest-client of go libraries for communicating with the KubeSphere API Server.\n\n# How to use it\n\n1. Import client-go packages:\n```golang\nimport (\n\t\"kubesphere.io/client-go/rest\"\n\t\"kubesphere.io/client-go/client\"\n\t\"kubesphere.io/client-go/client/generic\"\n)\n```\n2. Create a generic client instance:\n```golang\n    var client client.Client\n\tconfig := \u0026rest.Config{\n\t\tHost:     \"127.0.0.1:9090\",\n\t\tUsername: \"admin\",\n\t\tPassword: \"P@88w0rd\",\n\t}\n\tclient = generic.NewForConfigOrDie(config, client.Options{Scheme: f.Scheme})\n```\n\u003e generic.NewForConfigOrDie returns a client.Client that reads and writes from/to an KubeSphere API server. \n\n\u003e It's only compatible with Kubernetes-like API objects.\n\n3. KubeSphere API server provided a proxy to Kubernetes API Server. The client can read and write those Kubernetes native objects with the client directly.\n\n```golang\n\tdeploy := \u0026appsv1.Deployment{}\n\tclient.Get(context.TODO(), client.ObjectKey{Namespace: \"kubesphere-system\", Name: \"ks-apiserver\"}, deploy)\n```\n\n4. URLOptions and WorkspaceOptions can be provided to read and write Kubernetes likely Object that provided by KubeSphere API.\n```golang\n\tns := \u0026corev1.Namespace{\n\t\tObjectMeta: metav1.ObjectMeta{\n\t\t\tName: \"ks-test\",\n\t\t\tLabels: map[string]string{\n\t\t\t\tconstants.WorkspaceLabelKey: \"Workspace\",\n\t\t\t},\n\t\t},\n\t}\n\n\topts := \u0026client.URLOptions{\n\t\tGroup:   \"tenant.kubesphere.io\",\n\t\tVersion: \"v1alpha2\",\n\t}\n\n\terr := f.GenericClient(f.BaseName).Create(context.TODO(), ns, opts, \u0026client.WorkspaceOptions{Name: \"Workspace\"})\n```\n\nThe KubeSphere API Architecture can be found at https://kubesphere.io/docs/reference/api-docs/\n\n# Where does it come from?\n\nclient-go is synced from https://github.com/kubesphere/kubesphere/blob/master/staging/src/kubesphere.io/client-go. Code changes are made in that location, merged into `kubesphere.io/client-go` and later synced here.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubesphere%2Fclient-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkubesphere%2Fclient-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkubesphere%2Fclient-go/lists"}