本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.Node.Name方法的典型用法代碼示例。如果您正苦於以下問題:Golang Node.Name方法的具體用法?Golang Node.Name怎麽用?Golang Node.Name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/GoogleCloudPlatform/kubernetes/pkg/api.Node
的用法示例。
在下文中一共展示了Node.Name方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: GetCloudNodesWithSpec
// GetCloudNodesWithSpec constructs and returns api.NodeList from cloudprovider. If error
// occurs, an empty NodeList will be returned with a non-nil error info. The
// method only constructs spec fields for nodes.
func (s *NodeController) GetCloudNodesWithSpec() (*api.NodeList, error) {
result := &api.NodeList{}
instances, ok := s.cloud.Instances()
if !ok {
return result, ErrCloudInstance
}
matches, err := instances.List(s.matchRE)
if err != nil {
return result, err
}
for i := range matches {
node := api.Node{}
node.Name = matches[i]
resources, err := instances.GetNodeResources(matches[i])
if err != nil {
return nil, err
}
if resources == nil {
resources = s.staticResources
}
if resources != nil {
node.Spec.Capacity = resources.Capacity
}
instanceID, err := instances.ExternalID(node.Name)
if err != nil {
glog.Errorf("error getting instance id for %s: %v", node.Name, err)
} else {
node.Spec.ExternalID = instanceID
}
result.Items = append(result.Items, node)
}
return result, nil
}