Skip to content

Instantly share code, notes, and snippets.

@xmh19936688
xmh19936688 / countArray.js
Created October 9, 2022 00:33
遍历数组,给重复出现的元素标号
// 遍历数组,给重复出现的元素标号
// 可直接复制到浏览器F12运行
(function () {
// 返回需要判断重复出现的字段
var getKey = function (obj) {
return obj.id
}
// 当出现次数大于1时的回调,需要返回处理后的对象
// item: 需要处理的对象
// get k8s version in pod with client-go 通过client-go在pod中获取k8s版本
// refer: https://stackoverflow.com/questions/69446495/how-should-i-retrieve-the-current-kubernetes-server-version-via-golang-codes
import (
"k8s.io/client-go/discovery"
"k8s.io/client-go/rest"
)
func getKubernetesVersion(cfg *rest.Config) {
cli, err := discovery.NewDiscoveryClientForConfig(cfg)