Skip to content

Commit

Permalink
Error when trying to BYO revision name to an old-format service
Browse files Browse the repository at this point in the history
  • Loading branch information
sixolet committed Jul 20, 2019
1 parent 941f643 commit 0eb0c77
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/kn/commands/service/configuration_edit_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,9 @@ func (p *ConfigurationEditFlags) Apply(
}
if anyMutation {
err = servinglib.UpdateName(template, name)
if err != nil {
if err == servinglib.ApiTooOldError && !cmd.Flags().Changed("revision-name") {
// pass
} else if err != nil {
return err
}
}
Expand Down
6 changes: 6 additions & 0 deletions pkg/serving/config_changes.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package serving

import (
"errors"
"fmt"
"strconv"

Expand Down Expand Up @@ -62,8 +63,13 @@ func UpdateAnnotation(template *servingv1alpha1.RevisionTemplateSpec, annotation
annoMap[annotation] = value
}

var ApiTooOldError = errors.New("The service is using too old of an API format for the operation")

// UpdateName updates the revision name.
func UpdateName(template *servingv1alpha1.RevisionTemplateSpec, name string) error {
if template.Spec.DeprecatedContainer != nil {
return ApiTooOldError
}
template.Name = name
return nil
}
Expand Down

0 comments on commit 0eb0c77

Please sign in to comment.