代码拉取完成,页面将自动刷新
/*
Copyright 2017 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package strategy
import (
"k8s.io/kubernetes/pkg/kubectl/apply"
)
// delegatingStrategy delegates merging fields to other visitor implementations
// based on the merge strategy preferred by the field.
type delegatingStrategy struct {
options Options
merge mergeStrategy
replace replaceStrategy
retainKeys retainKeysStrategy
}
// createDelegatingStrategy returns a new delegatingStrategy
func createDelegatingStrategy(options Options) *delegatingStrategy {
v := &delegatingStrategy{
options: options,
}
v.replace = createReplaceStrategy(options, v)
v.merge = createMergeStrategy(options, v)
v.retainKeys = createRetainKeysStrategy(options, v)
return v
}
// MergeList delegates visiting a list based on the field patch strategy.
// Defaults to "replace"
func (v delegatingStrategy) MergeList(diff apply.ListElement) (apply.Result, error) {
switch diff.GetFieldMergeType() {
case apply.MergeStrategy:
return v.merge.MergeList(diff)
case apply.ReplaceStrategy:
return v.replace.MergeList(diff)
case apply.RetainKeysStrategy:
return v.retainKeys.MergeList(diff)
default:
return v.replace.MergeList(diff)
}
}
// MergeMap delegates visiting a map based on the field patch strategy.
// Defaults to "merge"
func (v delegatingStrategy) MergeMap(diff apply.MapElement) (apply.Result, error) {
switch diff.GetFieldMergeType() {
case apply.MergeStrategy:
return v.merge.MergeMap(diff)
case apply.ReplaceStrategy:
return v.replace.MergeMap(diff)
case apply.RetainKeysStrategy:
return v.retainKeys.MergeMap(diff)
default:
return v.merge.MergeMap(diff)
}
}
// MergeType delegates visiting a map based on the field patch strategy.
// Defaults to "merge"
func (v delegatingStrategy) MergeType(diff apply.TypeElement) (apply.Result, error) {
switch diff.GetFieldMergeType() {
case apply.MergeStrategy:
return v.merge.MergeType(diff)
case apply.ReplaceStrategy:
return v.replace.MergeType(diff)
case apply.RetainKeysStrategy:
return v.retainKeys.MergeType(diff)
default:
return v.merge.MergeType(diff)
}
}
// MergePrimitive delegates visiting a primitive to the ReplaceVisitorSingleton.
func (v delegatingStrategy) MergePrimitive(diff apply.PrimitiveElement) (apply.Result, error) {
// Always replace primitives
return v.replace.MergePrimitive(diff)
}
// MergeEmpty
func (v delegatingStrategy) MergeEmpty(diff apply.EmptyElement) (apply.Result, error) {
return v.merge.MergeEmpty(diff)
}
var _ apply.Strategy = &delegatingStrategy{}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。