Skip to content

Commit

Permalink
chore(service update): Add "unchanged" to revision if not changed
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Oct 10, 2019
1 parent a0cb9d8 commit d650365
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pkg/kn/commands/service/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ func waitForServiceToGetReady(client serving_kn_v1alpha1.KnServingClient, name s
if err != nil {
return err
}
return showUrl(client, name, verbDone, out)
return showUrl(client, name, "", verbDone, out)
}

// Duck type for writers having a flush
Expand Down
9 changes: 7 additions & 2 deletions pkg/kn/commands/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func waitForService(client serving_kn_v1alpha1.KnServingClient, serviceName stri
return nil
}

func showUrl(client serving_kn_v1alpha1.KnServingClient, serviceName string, what string, out io.Writer) error {
func showUrl(client serving_kn_v1alpha1.KnServingClient, serviceName string, originalRevision string, what string, out io.Writer) error {
service, err := client.GetService(serviceName)
if err != nil {
return fmt.Errorf("cannot fetch service '%s' in namespace '%s' for extracting the URL: %v", serviceName, client.Namespace(), err)
Expand All @@ -64,6 +64,11 @@ func showUrl(client serving_kn_v1alpha1.KnServingClient, serviceName string, wha
if url == "" {
url = service.Status.DeprecatedDomain
}
fmt.Fprintf(out, "\nService '%s' %s with latest revision '%s' and URL:\n%s\n", serviceName, what, service.Status.LatestReadyRevisionName, url)
revisionUpdateStatus := ""
newRevision := service.Status.LatestReadyRevisionName
if originalRevision != "" && originalRevision == newRevision {
revisionUpdateStatus = " (unchanged)"
}
fmt.Fprintf(out, "\nService '%s' %s with latest revision '%s'%s and URL:\n%s\n", serviceName, what, newRevision, revisionUpdateStatus, url)
return nil
}
4 changes: 2 additions & 2 deletions pkg/kn/commands/service/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command {
return err
}
service = service.DeepCopy()

latestRevisionBeforeUpdate := service.Status.LatestReadyRevisionName
var baseRevision *v1alpha1.Revision
if !cmd.Flags().Changed("image") && editFlags.LockToDigest {
baseRevision, err = client.GetBaseRevision(service)
Expand Down Expand Up @@ -119,7 +119,7 @@ func NewServiceUpdateCommand(p *commands.KnParams) *cobra.Command {
if err != nil {
return err
}
return showUrl(client, name, "updated", out)
return showUrl(client, name, latestRevisionBeforeUpdate, "updated", out)
} else {
fmt.Fprintf(out, "Service '%s' updated in namespace '%s'.\n", args[0], namespace)

Expand Down

0 comments on commit d650365

Please sign in to comment.