Revert "try old patch after new patch fails"

This reverts commit f32696e734.
This commit is contained in:
ymqytw
2016-11-22 21:02:30 -08:00
parent 9b16b435fc
commit d248843b65
18 changed files with 123 additions and 58 deletions

View File

@@ -164,8 +164,8 @@ func (o *ImageOptions) Validate() error {
func (o *ImageOptions) Run() error {
allErrs := []error{}
// Defauting to SMPatchVersion_1_5, since the func passed in doesn't update any lists of primitive
patches := CalculatePatches(o.f, o.Infos, o.Encoder, strategicpatch.SMPatchVersion_1_5, func(info *resource.Info) (bool, error) {
patches := CalculatePatches(o.f, o.Infos, o.Encoder, o.Local, func(info *resource.Info) (bool, error) {
transformed := false
_, err := o.UpdatePodSpecForObject(info.Object, func(spec *api.PodSpec) error {
for name, image := range o.ContainerImages {
@@ -189,6 +189,14 @@ func (o *ImageOptions) Run() error {
return transformed, err
})
smPatchVersion := strategicpatch.SMPatchVersionLatest
var err error
if !o.Local {
smPatchVersion, err = cmdutil.GetServerSupportedSMPatchVersionFromFactory(o.f)
if err != nil {
return err
}
}
for _, patch := range patches {
info := patch.Info
if patch.Err != nil {
@@ -215,7 +223,7 @@ func (o *ImageOptions) Run() error {
// record this change (for rollout history)
if o.Record || cmdutil.ContainsChangeCause(info) {
if patch, err := cmdutil.ChangeResourcePatch(info, o.ChangeCause); err == nil {
if patch, err := cmdutil.ChangeResourcePatch(info, o.ChangeCause, smPatchVersion); err == nil {
if obj, err = resource.NewHelper(info.Client, info.Mapping).Patch(info.Namespace, info.Name, api.StrategicMergePatchType, patch); err != nil {
fmt.Fprintf(o.Err, "WARNING: changes to %s/%s can't be recorded: %v\n", info.Mapping.Resource, info.Name, err)
}