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

feat: Ability to include or exclude fields in the response. Closes #2294 #2326

Merged
merged 1 commit into from
Feb 28, 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
12 changes: 12 additions & 0 deletions api/openapi-spec/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,12 @@
"description": "The continue option should be set when retrieving more results from the server. Since this value is\nserver defined, clients may only use the continue value from a previous query result with identical\nquery parameters (except for the value of continue) and the server may reject a continue value it\ndoes not recognize. If the specified continue value is no longer valid whether due to expiration\n(generally five to fifteen minutes) or a configuration change on the server, the server will\nrespond with a 410 ResourceExpired error together with a continue token. If the client needs a\nconsistent list, it must restart their list without the continue field. Otherwise, the client may\nsend another list request with the token received with the 410 error, the server will respond with\na list starting from the next key, but from the latest snapshot, which is inconsistent from the\nprevious list results - objects that are created, modified, or deleted after the first list request\nwill be included in the response, as long as their keys are after the \"next key\".\n\nThis field is not supported when watch is true. Clients may start a watch from the last\nresourceVersion value returned by the server and not miss any modifications.",
"name": "listOptions.continue",
"in": "query"
},
{
"type": "string",
"description": "Fields to be included or excluded in the response. e.g. \"items.spec,items.status.phase\", \"-items.status.nodes\".",
"name": "fields",
"in": "query"
}
],
"responses": {
Expand Down Expand Up @@ -946,6 +952,12 @@
"description": "When specified:\n- if unset, then the result is returned from remote storage based on quorum-read flag;\n- if it's 0, then we simply return what we currently have in cache, no guarantee;\n- if set to non zero, then the result is at least as fresh as given rv.",
"name": "getOptions.resourceVersion",
"in": "query"
},
{
"type": "string",
"description": "Fields to be included or excluded in the response. e.g. \"spec,status.phase\", \"-status.nodes\".",
"name": "fields",
"in": "query"
}
],
"responses": {
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
cloud.google.com/go v0.51.0 // indirect
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible
github.com/ajg/form v1.5.1 // indirect
github.com/argoproj/pkg v0.0.0-20200102163130-2dd1f3f6b4de
github.com/argoproj/pkg v0.0.0-20200226231057-d69f0b04da65
github.com/aws/aws-sdk-go v1.27.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYU
github.com/antihax/optional v0.0.0-20180407024304-ca021399b1a6/go.mod h1:V8iCPQYkqmusNa815XgQio277wI47sdRh1dUOLdyC6Q=
github.com/argoproj/pkg v0.0.0-20200102163130-2dd1f3f6b4de h1:i19Yd0ERYAHtR84jnB8vmTuizk2q4Qw4NuayfRja5/A=
github.com/argoproj/pkg v0.0.0-20200102163130-2dd1f3f6b4de/go.mod h1:2EZ44RG/CcgtPTwrRR0apOc7oU6UIw8GjCUJWZ8X3bM=
github.com/argoproj/pkg v0.0.0-20200226231057-d69f0b04da65 h1:bBC9exkuWvqhyDDhoNr66BpE6B4f+vxxKIXKxg6E6us=
github.com/argoproj/pkg v0.0.0-20200226231057-d69f0b04da65/go.mod h1:2EZ44RG/CcgtPTwrRR0apOc7oU6UIw8GjCUJWZ8X3bM=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio=
github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs=
github.com/aws/aws-sdk-go v1.27.1 h1:MXnqY6SlWySaZAqNnXThOvjRFdiiOuKtC6i7baFdNdU=
Expand Down
4 changes: 3 additions & 1 deletion pkg/apiclient/workflow/forwarder_overwrite.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package workflow

import (
"github.com/argoproj/argo/util/http"
"github.com/argoproj/pkg/grpc/http"
)

func init() {
forward_WorkflowService_WatchWorkflows_0 = http.StreamForwarder
forward_WorkflowService_PodLogs_0 = http.StreamForwarder
forward_WorkflowService_ListWorkflows_0 = http.UnaryForwarder
forward_WorkflowService_GetWorkflow_0 = http.UnaryForwarder
}
4 changes: 4 additions & 0 deletions pkg/apiclient/workflow/workflow.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,15 @@ message WorkflowGetRequest {
string name = 1;
string namespace = 2;
k8s.io.apimachinery.pkg.apis.meta.v1.GetOptions getOptions = 3;
// Fields to be included or excluded in the response. e.g. "spec,status.phase", "-status.nodes"
string fields = 4;
}

message WorkflowListRequest {
string namespace = 1;
k8s.io.apimachinery.pkg.apis.meta.v1.ListOptions listOptions = 2;
// Fields to be included or excluded in the response. e.g. "items.spec,items.status.phase", "-items.status.nodes"
string fields = 3;
}

message WorkflowResubmitRequest {
Expand Down
14 changes: 14 additions & 0 deletions pkg/apiclient/workflow/workflow.swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,13 @@
"in": "query",
"required": false,
"type": "string"
},
{
"name": "fields",
"description": "Fields to be included or excluded in the response. e.g. \"items.spec,items.status.phase\", \"-items.status.nodes\".",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
Expand Down Expand Up @@ -272,6 +279,13 @@
"in": "query",
"required": false,
"type": "string"
},
{
"name": "fields",
"description": "Fields to be included or excluded in the response. e.g. \"spec,status.phase\", \"-status.nodes\".",
"in": "query",
"required": false,
"type": "string"
}
],
"tags": [
Expand Down
24 changes: 24 additions & 0 deletions test/e2e/argo_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,21 @@ func (s *ArgoServerSuite) TestWorkflowService() {
NotNull()
})

s.Run("ListWithFields", func() {
j := s.e(s.T()).GET("/api/v1/workflows/argo").
WithQuery("listOptions.labelSelector", "argo-e2e=subject").
WithQuery("fields", "-items.status.nodes,items.status.finishedAt,items.status.startedAt").
Expect().
Status(200).
JSON()
j.
Path("$.items").
Array().
Length().
Equal(1)
j.Path("$.items[0].status").Object().ContainsKey("phase").NotContainsKey("nodes")
})

s.Run("Get", func() {
j := s.e(s.T()).GET("/api/v1/workflows/argo/test").
Expect().
Expand All @@ -480,6 +495,15 @@ func (s *ArgoServerSuite) TestWorkflowService() {
Status(404)
})

s.Run("GetWithFields", func() {
j := s.e(s.T()).GET("/api/v1/workflows/argo/test").
WithQuery("fields", "status.phase").
Expect().
Status(200).
JSON()
j.Path("$.status").Object().ContainsKey("phase").NotContainsKey("nodes")
})

s.Run("Suspend", func() {
s.e(s.T()).PUT("/api/v1/workflows/argo/test/suspend").
Expect().
Expand Down
48 changes: 0 additions & 48 deletions util/http/forwarders.go

This file was deleted.