Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e for service export #739

Merged
merged 5 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/cmd/kn_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ kn service [flags]
* [kn service create](kn_service_create.md) - Create a service.
* [kn service delete](kn_service_delete.md) - Delete a service.
* [kn service describe](kn_service_describe.md) - Show details of a service
* [kn service export](kn_service_export.md) - export a service
* [kn service export](kn_service_export.md) - Export a service.
* [kn service list](kn_service_list.md) - List available services.
* [kn service update](kn_service_update.md) - Update a service.

4 changes: 2 additions & 2 deletions docs/cmd/kn_service_export.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
## kn service export

export a service
Export a service.

### Synopsis

export a service
Export a service.

```
kn service export NAME [flags]
Expand Down
10 changes: 6 additions & 4 deletions pkg/kn/commands/service/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func NewServiceExportCommand(p *commands.KnParams) *cobra.Command {

command := &cobra.Command{
Use: "export NAME",
Short: "export a service",
Short: "Export a service.",
Example: `
# Export a service in yaml format
kn service export foo -n bar -o yaml
Expand Down Expand Up @@ -125,7 +125,7 @@ func constructServicefromRevision(latestSvc *servingv1.Service, revision serving
TypeMeta: latestSvc.TypeMeta,
}

exportedSvc.Spec.Template = servingv1.RevisionTemplateSpec{
exportedSvc.Spec.ConfigurationSpec.Template = servingv1.RevisionTemplateSpec{
Spec: revision.Spec,
ObjectMeta: latestSvc.Spec.ConfigurationSpec.Template.ObjectMeta,
}
Expand Down Expand Up @@ -164,8 +164,10 @@ func exportServiceWithActiveRevisions(latestSvc *servingv1.Service, client clien
return nil, fmt.Errorf("no revisions found for service %s", latestSvc.ObjectMeta.Name)
}

//set traffic in the latest revision
exportedSvcItems[len(exportedSvcItems)-1] = setTrafficSplit(latestSvc, exportedSvcItems[len(exportedSvcItems)-1])
//set traffic in the latest revision on if there is traffic split
if len(latestSvc.Spec.RouteSpec.Traffic) > 1 {
exportedSvcItems[len(exportedSvcItems)-1] = setTrafficSplit(latestSvc, exportedSvcItems[len(exportedSvcItems)-1])
}

typeMeta := metav1.TypeMeta{
APIVersion: "v1",
Expand Down
Loading