當前位置: 首頁>>代碼示例>>Golang>>正文


Golang runtime.FieldPtr函數代碼示例

本文整理匯總了Golang中k8s/io/kubernetes/pkg/runtime.FieldPtr函數的典型用法代碼示例。如果您正苦於以下問題:Golang FieldPtr函數的具體用法?Golang FieldPtr怎麽用?Golang FieldPtr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了FieldPtr函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: extractFromListMeta

// extractFromObjectMeta extracts pointers to metadata fields from a list object
func extractFromListMeta(v reflect.Value, a *genericAccessor) error {
	if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil {
		return err
	}
	return nil
}
開發者ID:XbinZh,項目名稱:kubernetes,代碼行數:10,代碼來源:meta.go

示例2: extractFromTypeMeta

// extractFromTypeMeta extracts pointers to version and kind fields from an object
func extractFromTypeMeta(v reflect.Value, a *genericAccessor) error {
	if err := runtime.FieldPtr(v, "APIVersion", &a.apiVersion); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Kind", &a.kind); err != nil {
		return err
	}
	return nil
}
開發者ID:XbinZh,項目名稱:kubernetes,代碼行數:10,代碼來源:meta.go

示例3: extractFromObjectMeta

// extractFromObjectMeta extracts pointers to metadata fields from an object
func extractFromObjectMeta(v reflect.Value, a *genericAccessor) error {
	if err := runtime.FieldPtr(v, "Namespace", &a.namespace); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Tenant", &a.tenant); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Name", &a.name); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "GenerateName", &a.generateName); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "UID", &a.uid); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Labels", &a.labels); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Annotations", &a.annotations); err != nil {
		return err
	}
	return nil
}
開發者ID:kuenzaa,項目名稱:hypernetes,代碼行數:31,代碼來源:meta.go

示例4: extractFromObjectMeta

// extractFromObjectMeta extracts pointers to metadata fields from an object
func extractFromObjectMeta(v reflect.Value, a *genericAccessor) error {
	if err := runtime.FieldPtr(v, "Namespace", &a.namespace); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Name", &a.name); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "GenerateName", &a.generateName); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "UID", &a.uid); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "ResourceVersion", &a.resourceVersion); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "SelfLink", &a.selfLink); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Labels", &a.labels); err != nil {
		return err
	}
	if err := runtime.FieldPtr(v, "Annotations", &a.annotations); err != nil {
		return err
	}
	ownerReferences := v.FieldByName("OwnerReferences")
	if !ownerReferences.IsValid() {
		return fmt.Errorf("struct %#v lacks OwnerReferences type", v)
	}
	if ownerReferences.Kind() != reflect.Slice {
		return fmt.Errorf("expect %v to be a slice", ownerReferences.Kind())
	}
	a.ownerReferences = ownerReferences.Addr()
	return nil
}
開發者ID:odacremolbap,項目名稱:kubernetes,代碼行數:36,代碼來源:meta.go

示例5: ListMetaFor

// ListMetaFor returns a pointer to a provided object's ListMeta,
// or an error if the object does not have that pointer.
// TODO: allow runtime.Unknown to extract this object
func ListMetaFor(obj runtime.Object) (*unversioned.ListMeta, error) {
	v, err := conversion.EnforcePtr(obj)
	if err != nil {
		return nil, err
	}
	var meta *unversioned.ListMeta
	err = runtime.FieldPtr(v, "ListMeta", &meta)
	return meta, err
}
開發者ID:CodeJuan,項目名稱:kubernetes,代碼行數:12,代碼來源:meta.go


注:本文中的k8s/io/kubernetes/pkg/runtime.FieldPtr函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。