本文整理汇总了Golang中k8s/io/kubernetes/pkg/api.FinalizerName函数的典型用法代码示例。如果您正苦于以下问题:Golang FinalizerName函数的具体用法?Golang FinalizerName怎么用?Golang FinalizerName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FinalizerName函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: autoConvert_v1_ProjectSpec_To_api_ProjectSpec
func autoConvert_v1_ProjectSpec_To_api_ProjectSpec(in *ProjectSpec, out *project_api.ProjectSpec, s conversion.Scope) error {
if in.Finalizers != nil {
in, out := &in.Finalizers, &out.Finalizers
*out = make([]api.FinalizerName, len(*in))
for i := range *in {
(*out)[i] = api.FinalizerName((*in)[i])
}
} else {
out.Finalizers = nil
}
return nil
}
示例2: autoConvert_v1_ProjectSpec_To_api_ProjectSpec
func autoConvert_v1_ProjectSpec_To_api_ProjectSpec(in *ProjectSpec, out *project_api.ProjectSpec, s conversion.Scope) error {
if defaulting, found := s.DefaultingInterface(reflect.TypeOf(*in)); found {
defaulting.(func(*ProjectSpec))(in)
}
if in.Finalizers != nil {
in, out := &in.Finalizers, &out.Finalizers
*out = make([]api.FinalizerName, len(*in))
for i := range *in {
(*out)[i] = api.FinalizerName((*in)[i])
}
} else {
out.Finalizers = nil
}
return nil
}
示例3: finalizeNamespaceFunc
// finalize will finalize the namespace for kubernetes
func finalizeNamespaceFunc(kubeClient client.Interface, namespace *api.Namespace) (*api.Namespace, error) {
namespaceFinalize := api.Namespace{}
namespaceFinalize.ObjectMeta = namespace.ObjectMeta
namespaceFinalize.Spec = namespace.Spec
finalizerSet := sets.NewString()
for i := range namespace.Spec.Finalizers {
if namespace.Spec.Finalizers[i] != api.FinalizerKubernetes {
finalizerSet.Insert(string(namespace.Spec.Finalizers[i]))
}
}
namespaceFinalize.Spec.Finalizers = make([]api.FinalizerName, 0, len(finalizerSet))
for _, value := range finalizerSet.List() {
namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, api.FinalizerName(value))
}
return kubeClient.Namespaces().Finalize(&namespaceFinalize)
}
示例4: NamespaceSpec
func NamespaceSpec(namespaceSpecs []interface{}) api.NamespaceSpec {
if len(namespaceSpecs) == 0 {
return api.NamespaceSpec{}
}
userNamespaceSpec := namespaceSpecs[0].(map[string]interface{})
namespaceSpec := api.NamespaceSpec{}
if _, ok := userNamespaceSpec["finalizers"]; ok {
strFinalizers := convertListToStringArray(userNamespaceSpec["finalizers"].([]interface{}))
var finalizers []api.FinalizerName
for _, f := range strFinalizers {
finalizers = append(finalizers, api.FinalizerName(f))
}
namespaceSpec.Finalizers = finalizers
}
return namespaceSpec
}
示例5: finalizeInternal
// finalizeInternal will update the namespace finalizer list to either have or not have origin finalizer
func finalizeInternal(kubeClient kclient.Interface, namespace *kapi.Namespace, withOrigin bool) (*kapi.Namespace, error) {
namespaceFinalize := kapi.Namespace{}
namespaceFinalize.ObjectMeta = namespace.ObjectMeta
namespaceFinalize.Spec = namespace.Spec
finalizerSet := util.NewStringSet()
for i := range namespace.Spec.Finalizers {
finalizerSet.Insert(string(namespace.Spec.Finalizers[i]))
}
if withOrigin {
finalizerSet.Insert(string(api.FinalizerOrigin))
} else {
finalizerSet.Delete(string(api.FinalizerOrigin))
}
namespaceFinalize.Spec.Finalizers = make([]kapi.FinalizerName, 0, len(finalizerSet))
for _, value := range finalizerSet.List() {
namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, kapi.FinalizerName(value))
}
return kubeClient.Namespaces().Finalize(&namespaceFinalize)
}
示例6: finalizeNamespace
// finalizeNamespace removes the specified finalizerToken and finalizes the namespace
func finalizeNamespace(kubeClient clientset.Interface, namespace *api.Namespace, finalizerToken api.FinalizerName) (*api.Namespace, error) {
namespaceFinalize := api.Namespace{}
namespaceFinalize.ObjectMeta = namespace.ObjectMeta
namespaceFinalize.Spec = namespace.Spec
finalizerSet := sets.NewString()
for i := range namespace.Spec.Finalizers {
if namespace.Spec.Finalizers[i] != finalizerToken {
finalizerSet.Insert(string(namespace.Spec.Finalizers[i]))
}
}
namespaceFinalize.Spec.Finalizers = make([]api.FinalizerName, 0, len(finalizerSet))
for _, value := range finalizerSet.List() {
namespaceFinalize.Spec.Finalizers = append(namespaceFinalize.Spec.Finalizers, api.FinalizerName(value))
}
namespace, err := kubeClient.Core().Namespaces().Finalize(&namespaceFinalize)
if err != nil {
// it was removed already, so life is good
if errors.IsNotFound(err) {
return namespace, nil
}
}
return namespace, err
}