本文整理匯總了Golang中k8s/io/kubernetes/pkg/apis/extensions.ThirdPartyResourceData.Data方法的典型用法代碼示例。如果您正苦於以下問題:Golang ThirdPartyResourceData.Data方法的具體用法?Golang ThirdPartyResourceData.Data怎麽用?Golang ThirdPartyResourceData.Data使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類k8s/io/kubernetes/pkg/apis/extensions.ThirdPartyResourceData
的用法示例。
在下文中一共展示了ThirdPartyResourceData.Data方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: populateFromObject
func (t *thirdPartyResourceDataCodec) populateFromObject(objIn *extensions.ThirdPartyResourceData, mapObj map[string]interface{}, data []byte) error {
typeMeta := unversioned.TypeMeta{}
if err := json.Unmarshal(data, &typeMeta); err != nil {
return err
}
if typeMeta.Kind != t.kind {
return fmt.Errorf("unexpected kind: %s, expected %s", typeMeta.Kind, t.kind)
}
metadata, ok := mapObj["metadata"].(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected object for metadata: %#v", mapObj["metadata"])
}
metadataData, err := json.Marshal(metadata)
if err != nil {
return err
}
if err := json.Unmarshal(metadataData, &objIn.ObjectMeta); err != nil {
return err
}
objIn.Data = data
return nil
}
示例2: populateResource
func (t *thirdPartyResourceDataCodec) populateResource(objIn *extensions.ThirdPartyResourceData, mapObj map[string]interface{}, data []byte) error {
metadata, ok := mapObj["metadata"].(map[string]interface{})
if !ok {
return fmt.Errorf("unexpected object for metadata: %#v", mapObj["metadata"])
}
metadataData, err := json.Marshal(metadata)
if err != nil {
return err
}
if err := json.Unmarshal(metadataData, &objIn.ObjectMeta); err != nil {
return err
}
// Override API Version with the ThirdPartyResourceData value
// TODO: fix this hard code
objIn.APIVersion = v1beta1.SchemeGroupVersion.String()
objIn.Data = data
return nil
}