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


Golang Node.Status方法代碼示例

本文整理匯總了Golang中github.com/GoogleCloudPlatform/kubernetes/pkg/api.Node.Status方法的典型用法代碼示例。如果您正苦於以下問題:Golang Node.Status方法的具體用法?Golang Node.Status怎麽用?Golang Node.Status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/GoogleCloudPlatform/kubernetes/pkg/api.Node的用法示例。


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

示例1: ValidateMinionUpdate

// ValidateMinionUpdate tests to make sure a minion update can be applied.  Modifies oldMinion.
func ValidateMinionUpdate(oldMinion *api.Node, minion *api.Node) errs.ValidationErrorList {
	allErrs := errs.ValidationErrorList{}
	allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldMinion.ObjectMeta, &minion.ObjectMeta).Prefix("metadata")...)

	// TODO: Enable the code once we have better api object.status update model. Currently,
	// anyone can update node status.
	// if !api.Semantic.DeepEqual(minion.Status, api.NodeStatus{}) {
	// 	allErrs = append(allErrs, errs.NewFieldInvalid("status", minion.Status, "status must be empty"))
	// }

	// TODO: move reset function to its own location
	// Ignore metadata changes now that they have been tested
	oldMinion.ObjectMeta = minion.ObjectMeta
	// Allow users to update capacity
	oldMinion.Spec.Capacity = minion.Spec.Capacity
	// Clear status
	oldMinion.Status = minion.Status

	// TODO: Add a 'real' ValidationError type for this error and provide print actual diffs.
	if !api.Semantic.DeepEqual(oldMinion, minion) {
		glog.V(4).Infof("Update failed validation %#v vs %#v", oldMinion, minion)
		allErrs = append(allErrs, fmt.Errorf("update contains more than labels or capacity changes"))
	}

	// TODO: validate Spec.Capacity
	return allErrs
}
開發者ID:brorhie,項目名稱:panamax-kubernetes-adapter-go,代碼行數:28,代碼來源:validation.go

示例2: ValidateMinionUpdate

// ValidateMinionUpdate tests to make sure a minion update can be applied.  Modifies oldMinion.
func ValidateMinionUpdate(oldMinion *api.Node, minion *api.Node) errs.ValidationErrorList {
	allErrs := errs.ValidationErrorList{}

	if !api.Semantic.DeepEqual(minion.Status, api.NodeStatus{}) {
		allErrs = append(allErrs, errs.NewFieldInvalid("status", minion.Status, "status must be empty"))
	}

	// Allow users to update labels and capacity
	oldMinion.Labels = minion.Labels
	oldMinion.Spec.Capacity = minion.Spec.Capacity
	// Clear status
	oldMinion.Status = minion.Status

	if !api.Semantic.DeepEqual(oldMinion, minion) {
		glog.V(4).Infof("Update failed validation %#v vs %#v", oldMinion, minion)
		allErrs = append(allErrs, fmt.Errorf("update contains more than labels or capacity changes"))
	}
	return allErrs
}
開發者ID:nhr,項目名稱:kubernetes,代碼行數:20,代碼來源:validation.go


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