本文整理匯總了Golang中k8s/io/kubernetes/pkg/runtime.Unstructured.SetSelfLink方法的典型用法代碼示例。如果您正苦於以下問題:Golang Unstructured.SetSelfLink方法的具體用法?Golang Unstructured.SetSelfLink怎麽用?Golang Unstructured.SetSelfLink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/runtime.Unstructured
的用法示例。
在下文中一共展示了Unstructured.SetSelfLink方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: TestUnstructuredSetters
func TestUnstructuredSetters(t *testing.T) {
unstruct := runtime.Unstructured{}
want := runtime.Unstructured{
Object: map[string]interface{}{
"kind": "test_kind",
"apiVersion": "test_version",
"metadata": map[string]interface{}{
"name": "test_name",
"namespace": "test_namespace",
"generateName": "test_generateName",
"uid": "test_uid",
"resourceVersion": "test_resourceVersion",
"selfLink": "test_selfLink",
"creationTimestamp": "2009-11-10T23:00:00Z",
"deletionTimestamp": "2010-11-10T23:00:00Z",
"labels": map[string]interface{}{
"test_label": "test_value",
},
"annotations": map[string]interface{}{
"test_annotation": "test_value",
},
},
},
}
unstruct.SetAPIVersion("test_version")
unstruct.SetKind("test_kind")
unstruct.SetNamespace("test_namespace")
unstruct.SetName("test_name")
unstruct.SetGenerateName("test_generateName")
unstruct.SetUID(types.UID("test_uid"))
unstruct.SetResourceVersion("test_resourceVersion")
unstruct.SetSelfLink("test_selfLink")
unstruct.SetCreationTimestamp(unversioned.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC))
date := unversioned.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC)
unstruct.SetDeletionTimestamp(&date)
unstruct.SetLabels(map[string]string{"test_label": "test_value"})
unstruct.SetAnnotations(map[string]string{"test_annotation": "test_value"})
if !reflect.DeepEqual(unstruct, want) {
t.Errorf("Wanted: \n%s\n Got:\n%s", unstruct, want)
}
}
示例2: TestUnstructuredSetters
func TestUnstructuredSetters(t *testing.T) {
unstruct := runtime.Unstructured{}
trueVar := true
want := runtime.Unstructured{
Object: map[string]interface{}{
"kind": "test_kind",
"apiVersion": "test_version",
"metadata": map[string]interface{}{
"name": "test_name",
"namespace": "test_namespace",
"generateName": "test_generateName",
"uid": "test_uid",
"resourceVersion": "test_resourceVersion",
"selfLink": "test_selfLink",
"creationTimestamp": "2009-11-10T23:00:00Z",
"deletionTimestamp": "2010-11-10T23:00:00Z",
"labels": map[string]interface{}{
"test_label": "test_value",
},
"annotations": map[string]interface{}{
"test_annotation": "test_value",
},
"ownerReferences": []map[string]interface{}{
{
"kind": "Pod",
"name": "poda",
"apiVersion": "v1",
"uid": "1",
"controller": (*bool)(nil),
},
{
"kind": "Pod",
"name": "podb",
"apiVersion": "v1",
"uid": "2",
"controller": &trueVar,
},
},
"finalizers": []interface{}{
"finalizer.1",
"finalizer.2",
},
"clusterName": "cluster123",
},
},
}
unstruct.SetAPIVersion("test_version")
unstruct.SetKind("test_kind")
unstruct.SetNamespace("test_namespace")
unstruct.SetName("test_name")
unstruct.SetGenerateName("test_generateName")
unstruct.SetUID(types.UID("test_uid"))
unstruct.SetResourceVersion("test_resourceVersion")
unstruct.SetSelfLink("test_selfLink")
unstruct.SetCreationTimestamp(unversioned.Date(2009, time.November, 10, 23, 0, 0, 0, time.UTC))
date := unversioned.Date(2010, time.November, 10, 23, 0, 0, 0, time.UTC)
unstruct.SetDeletionTimestamp(&date)
unstruct.SetLabels(map[string]string{"test_label": "test_value"})
unstruct.SetAnnotations(map[string]string{"test_annotation": "test_value"})
newOwnerReferences := []metatypes.OwnerReference{
{
Kind: "Pod",
Name: "poda",
APIVersion: "v1",
UID: "1",
},
{
Kind: "Pod",
Name: "podb",
APIVersion: "v1",
UID: "2",
Controller: &trueVar,
},
}
unstruct.SetOwnerReferences(newOwnerReferences)
unstruct.SetFinalizers([]string{"finalizer.1", "finalizer.2"})
unstruct.SetClusterName("cluster123")
if !reflect.DeepEqual(unstruct, want) {
t.Errorf("Wanted: \n%s\n Got:\n%s", want, unstruct)
}
}