• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang labels.Applicator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/square/p2/pkg/labels.Applicator的典型用法代码示例。如果您正苦于以下问题:Golang Applicator类的具体用法?Golang Applicator怎么用?Golang Applicator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Applicator类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: parseNodeSelectorWithPrompt

func parseNodeSelectorWithPrompt(
	oldSelector klabels.Selector,
	newSelectorString string,
	applicator labels.Applicator,
) (klabels.Selector, error) {
	newSelector, err := parseNodeSelector(newSelectorString)
	if err != nil {
		return newSelector, err
	}
	if oldSelector.String() == newSelector.String() {
		return newSelector, nil
	}

	newNodeLabels, err := applicator.GetMatches(newSelector, labels.NODE, false)
	if err != nil {
		return newSelector, util.Errorf("Error getting matching labels: %v", err)
	}

	oldNodeLabels, err := applicator.GetMatches(oldSelector, labels.NODE, false)
	if err != nil {
		return newSelector, util.Errorf("Error getting matching labels: %v", err)
	}

	toRemove, toAdd := makeNodeChanges(oldNodeLabels, newNodeLabels)

	fmt.Printf("Changing deployment from '%v' to '%v':\n", oldSelector.String(), newSelectorString)
	fmt.Printf("Removing:%9s hosts %s\n", fmt.Sprintf("-%v", len(toRemove)), toRemove)
	fmt.Printf("Adding:  %9s hosts %s\n", fmt.Sprintf("+%v", len(toAdd)), toAdd)
	fmt.Println("Continue?")
	if !confirm() {
		return newSelector, util.Errorf("User cancelled")
	}

	return newSelector, nil
}
开发者ID:rudle,项目名称:p2,代码行数:35,代码来源:main.go


示例2: confirmMinheathForSelector

func confirmMinheathForSelector(minHealth int, selector klabels.Selector, applicator labels.Applicator) error {
	matches, err := applicator.GetMatches(selector, labels.NODE, false)
	if err != nil {
		return err
	}
	if len(matches) < minHealth {
		fmt.Printf("Your selector matches %d nodes but your minhealth is set to only %d, this daemon set will not replicate. Continue?\n", len(matches), minHealth)
		if !confirm() {
			return util.Errorf("User cancelled")
		}
	}
	return nil
}
开发者ID:rudle,项目名称:p2,代码行数:13,代码来源:main.go


示例3: waitForPodLabel

func waitForPodLabel(applicator labels.Applicator, hasDSIDLabel bool, podPath string) (labels.Labeled, error) {
	var labeled labels.Labeled
	var err error

	condition := func() error {
		var val bool
		labeled, err = applicator.GetLabels(labels.POD, podPath)
		if err == nil {
			val = labeled.Labels.Has(DSIDLabel)
			if hasDSIDLabel == val {
				return nil
			}
		}
		return util.Errorf("Expected hasIDLabel to be '%v', got '%v'", hasDSIDLabel, val)
	}

	err = waitForCondition(condition)
	return labeled, err
}
开发者ID:drcapulet,项目名称:p2,代码行数:19,代码来源:farm_test.go


示例4: createRC

func createRC(
	rcs rcstore.Store,
	applicator labels.Applicator,
	manifest manifest.Manifest,
	desired int,
	nodes map[types.NodeName]bool,
) (rc_fields.RC, error) {
	created, err := rcs.Create(manifest, nil, nil)
	if err != nil {
		return rc_fields.RC{}, fmt.Errorf("Error creating RC: %s", err)
	}

	podID := string(manifest.ID())

	for node := range nodes {
		if err = applicator.SetLabel(labels.POD, node.String()+"/"+podID, rc.RCIDLabel, string(created.ID)); err != nil {
			return rc_fields.RC{}, fmt.Errorf("Error applying RC ID label: %s", err)
		}
	}

	return created, rcs.SetDesiredReplicas(created.ID, desired)
}
开发者ID:petertseng,项目名称:p2,代码行数:22,代码来源:update_test.go


示例5: applyLabels

func applyLabels(applicator labels.Applicator, entityID string, labelType labels.Type, additiveLabels map[string]string, destructiveKeys []string) error {
	var err error
	if !confirm(fmt.Sprintf("mutate the labels for %s/%s", labelType, entityID)) {
		return nil
	}
	if len(additiveLabels) > 0 {
		for k, v := range additiveLabels {
			err = applicator.SetLabel(labelType, entityID, k, v)
			if err != nil {
				fmt.Fprintf(os.Stderr, "Error while appyling label. k/v: %s/%s.\n%v\n", k, v, err)
			}
		}
	}
	if len(destructiveKeys) > 0 {
		for _, key := range destructiveKeys {
			err = applicator.RemoveLabel(labelType, entityID, key)
			if err != nil {
				fmt.Fprintf(os.Stderr, "Error while destroying label with key: %s.\n%v\n", key, err)
			}
		}
	}
	return nil
}
开发者ID:rudle,项目名称:p2,代码行数:23,代码来源:main.go


示例6: scheduledPods

func scheduledPods(t *testing.T, pods labels.Applicator) []labels.Labeled {
	podSelector := klabels.Everything().Add("podTest", klabels.EqualsOperator, []string{"successful"})
	labeled, err := pods.GetMatches(podSelector, labels.POD)
	Assert(t).IsNil(err, "expected no error matching pods")
	return labeled
}
开发者ID:tomzhang,项目名称:p2,代码行数:6,代码来源:replication_controller_test.go



注:本文中的github.com/square/p2/pkg/labels.Applicator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang logging.NewLogger函数代码示例发布时间:2022-05-28
下一篇:
Golang labels.NewFakeApplicator函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap