本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.SecurityContextConstraints.Labels方法的典型用法代码示例。如果您正苦于以下问题:Golang SecurityContextConstraints.Labels方法的具体用法?Golang SecurityContextConstraints.Labels怎么用?Golang SecurityContextConstraints.Labels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类k8s/io/kubernetes/pkg/api.SecurityContextConstraints
的用法示例。
在下文中一共展示了SecurityContextConstraints.Labels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: computeUpdatedSCC
// computeUpdatedSCC determines if the expected SCC looks like the actual SCC
// it does this by making the expected SCC mirror the actual SCC for items that
// we are not reconciling and performing a diff (ignoring changes to metadata).
// If a diff is produced then the expected SCC is submitted as needing an update.
func (o *ReconcileSCCOptions) computeUpdatedSCC(expected kapi.SecurityContextConstraints, actual kapi.SecurityContextConstraints) (*kapi.SecurityContextConstraints, bool) {
needsUpdate := false
// if unioning old and new groups/users then make the expected contain all
// also preserve and set priorities
if o.Union {
groupSet := sets.NewString(actual.Groups...)
groupSet.Insert(expected.Groups...)
expected.Groups = groupSet.List()
userSet := sets.NewString(actual.Users...)
userSet.Insert(expected.Users...)
expected.Users = userSet.List()
if actual.Priority != nil {
expected.Priority = actual.Priority
}
// preserve labels and annotations
expected.Labels = MergeMaps(expected.Labels, actual.Labels)
expected.Annotations = MergeMaps(expected.Annotations, actual.Annotations)
}
// sort volumes to remove variants in order
sortVolumes(&expected)
sortVolumes(&actual)
// sort users and groups to remove any variants in order when diffing
sort.StringSlice(actual.Groups).Sort()
sort.StringSlice(actual.Users).Sort()
sort.StringSlice(expected.Groups).Sort()
sort.StringSlice(expected.Users).Sort()
// compute the updated scc as follows:
// 1. start with the expected scc
// 2. take the objectmeta from the actual scc (preserves the resource version and uid)
// 3. add back the labels and annotations from the expected scc (which were already merged if unioning was desired)
updated := expected
updated.ObjectMeta = actual.ObjectMeta
updated.ObjectMeta.Labels = expected.Labels
updated.ObjectMeta.Annotations = expected.Annotations
if !kapi.Semantic.DeepEqual(updated, actual) {
needsUpdate = true
}
return &updated, needsUpdate
}