mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
udpate some examples to use external types
This commit is contained in:
@@ -19,11 +19,9 @@ package set
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/legacyscheme"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
|
||||
"github.com/golang/glog"
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@@ -32,7 +30,9 @@ import (
|
||||
cmdutil "k8s.io/kubernetes/pkg/kubectl/cmd/util"
|
||||
"k8s.io/kubernetes/pkg/kubectl/genericclioptions"
|
||||
"k8s.io/kubernetes/pkg/kubectl/resource"
|
||||
"k8s.io/kubernetes/pkg/kubectl/scheme"
|
||||
"k8s.io/kubernetes/pkg/kubectl/util/i18n"
|
||||
"k8s.io/kubernetes/pkg/printers"
|
||||
)
|
||||
|
||||
// ImageOptions is the start of the data required to perform the operation. As new fields are added, add them here instead of
|
||||
@@ -161,7 +161,7 @@ func (o *SetImageOptions) Complete(f cmdutil.Factory, cmd *cobra.Command, args [
|
||||
|
||||
includeUninitialized := cmdutil.ShouldIncludeUninitialized(cmd, false)
|
||||
builder := f.NewBuilder().
|
||||
WithScheme(legacyscheme.Scheme).
|
||||
WithScheme(scheme.Scheme, scheme.Registry.RegisteredGroupVersions()...).
|
||||
LocalParam(o.Local).
|
||||
ContinueOnError().
|
||||
NamespaceParam(cmdNamespace).DefaultNamespace().
|
||||
@@ -209,9 +209,8 @@ func (o *SetImageOptions) Validate() error {
|
||||
func (o *SetImageOptions) Run() error {
|
||||
allErrs := []error{}
|
||||
|
||||
patches := CalculatePatches(o.Infos, cmdutil.InternalVersionJSONEncoder(), func(info *resource.Info) ([]byte, error) {
|
||||
patches := CalculatePatches(o.Infos, scheme.DefaultJSONEncoder(), func(info *resource.Info) ([]byte, error) {
|
||||
transformed := false
|
||||
info.Object = cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping)
|
||||
_, err := o.UpdatePodSpecForObject(info.Object, func(spec *v1.PodSpec) error {
|
||||
for name, image := range o.ContainerImages {
|
||||
var (
|
||||
@@ -259,7 +258,7 @@ func (o *SetImageOptions) Run() error {
|
||||
glog.V(4).Infof("error recording current command: %v", err)
|
||||
}
|
||||
|
||||
return runtime.Encode(cmdutil.InternalVersionJSONEncoder(), info.Object)
|
||||
return runtime.Encode(scheme.DefaultJSONEncoder(), info.Object)
|
||||
})
|
||||
|
||||
for _, patch := range patches {
|
||||
@@ -275,7 +274,7 @@ func (o *SetImageOptions) Run() error {
|
||||
}
|
||||
|
||||
if o.Local || o.DryRun {
|
||||
if err := o.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(patch.Info.Object, patch.Info.Mapping), o.Out); err != nil {
|
||||
if err := o.PrintObj(patch.Info.Object, o.Out); err != nil {
|
||||
return err
|
||||
}
|
||||
continue
|
||||
@@ -289,7 +288,7 @@ func (o *SetImageOptions) Run() error {
|
||||
}
|
||||
info.Refresh(obj, true)
|
||||
|
||||
if err := o.PrintObj(cmdutil.AsDefaultVersionedOrOriginal(info.Object, info.Mapping), o.Out); err != nil {
|
||||
if err := o.PrintObj(info.Object, o.Out); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user