Skip to content

Commit

Permalink
feat: Create API clients (#2218)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexec committed Feb 25, 2020
1 parent 214c451 commit b594716
Show file tree
Hide file tree
Showing 25 changed files with 15,096 additions and 20,650 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ cmd/**/debug
hack/**/debug
/argo
/argoexec
/sdks
debug.test
*.iml
/coverage.out
Expand Down
14 changes: 7 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ CONTROLLER_PKGS := $(shell echo cmd/workflow-controller && go list -f '{{ join
MANIFESTS := $(shell find manifests -mindepth 2 -type f)
E2E_MANIFESTS := $(shell find test/e2e/manifests -mindepth 2 -type f)
E2E_EXECUTOR ?= pns
SWAGGER_FILES := $(shell find pkg -name '*.swagger.json')
# the sort puts _.primary first in the list
SWAGGER_FILES := $(shell find pkg -name '*.swagger.json' | sort)

.PHONY: build
build: status clis executor-image controller-image manifests/install.yaml manifests/namespace-install.yaml manifests/quick-start-postgres.yaml manifests/quick-start-mysql.yaml
Expand Down Expand Up @@ -203,16 +204,15 @@ codegen:
# Generate code
./hack/generate-proto.sh
./hack/update-codegen.sh
./hack/update-openapigen.sh
go run ./hack/gen-openapi-spec/main.go $(MANIFESTS_VERSION) > ./api/openapi-spec/swagger.json
make api/argo-server/swagger.json
make api/openapi-spec/swagger.json
find . -path '*/mocks/*' -type f -not -path '*/vendor/*' -exec ./hack/update-mocks.sh {} ';'

.PHONY: manifests
manifests: status manifests/install.yaml manifests/namespace-install.yaml manifests/quick-start-mysql.yaml manifests/quick-start-postgres.yaml manifests/quick-start-no-db.yaml test/e2e/manifests/postgres.yaml test/e2e/manifests/mysql.yaml test/e2e/manifests/no-db.yaml

# we use a different file to ./VERSION to force updating manifests after a `make clean`
dist/MANIFESTS_VERSION:
mkdir -p dist
echo $(MANIFESTS_VERSION) > dist/MANIFESTS_VERSION

manifests/install.yaml: dist/MANIFESTS_VERSION $(MANIFESTS)
Expand Down Expand Up @@ -418,13 +418,13 @@ clean:
# Delete build files
rm -Rf dist ui/dist

# sdks
# swagger

$(HOME)/go/bin/swagger:
go get github.com/go-swagger/go-swagger/cmd/swagger

api/argo-server/swagger.json: $(HOME)/go/bin/swagger $(SWAGGER_FILES)
swagger mixin -c 412 pkg/apiclient/primary.swagger.json $(SWAGGER_FILES) | sed 's/VERSION/$(MANIFESTS_VERSION)/' > api/argo-server/swagger.json
api/openapi-spec/swagger.json: $(HOME)/go/bin/swagger $(SWAGGER_FILES) dist/MANIFESTS_VERSION hack/swaggify.sh
swagger mixin -c 412 $(SWAGGER_FILES) | sed 's/VERSION/$(MANIFESTS_VERSION)/' | ./hack/swaggify.sh > api/openapi-spec/swagger.json

# pre-push

Expand Down
5,589 changes: 0 additions & 5,589 deletions api/argo-server/swagger.json

This file was deleted.

6,493 changes: 5,068 additions & 1,425 deletions api/openapi-spec/swagger.json

Large diffs are not rendered by default.

Empty file removed assets/swagger.json
Empty file.
4 changes: 2 additions & 2 deletions docs/rest-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ Since version v2.5 Argo Workflows ships with a server that provide more features
The server can be configured with or without client auth (`server --auth-mode client`). When it is disabled, then clients must pass their Kubeconfig base 64 encoded in the HTTP `Authorization` header:

```
token=$(argo token)
curl -H "Authorization: Bearer $token" http://localhost:2746/api/v1/workflows/argo
token=$(argo auth token)
curl -H "Authorization: $token" http://localhost:2746/api/v1/workflows/argo
```

To view the API:
Expand Down
8 changes: 2 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,11 @@ require (
github.com/colinmarc/hdfs v1.1.4-0.20180805212432-9746310a4d31
github.com/docker/spdystream v0.0.0-20181023171402-6480d4af844c // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/emicklei/go-restful v2.11.1+incompatible // indirect
github.com/evanphx/json-patch v4.2.0+incompatible
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/ghodss/yaml v1.0.0
github.com/go-ini/ini v1.51.1 // indirect
github.com/go-openapi/jsonreference v0.19.3 // indirect
github.com/go-openapi/spec v0.19.5
github.com/go-openapi/swag v0.19.6 // indirect
github.com/go-sql-driver/mysql v1.4.1
github.com/gogo/protobuf v1.3.1
github.com/golang/protobuf v1.3.2
Expand All @@ -41,7 +37,6 @@ require (
github.com/klauspost/compress v1.9.7 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.2 // indirect
github.com/lib/pq v1.3.0 // indirect
github.com/mailru/easyjson v0.7.0 // indirect
github.com/mattn/go-colorable v0.1.4 // indirect
github.com/minio/minio-go v6.0.14+incompatible // indirect
github.com/mitchellh/go-ps v0.0.0-20190716172923-621e5597135b
Expand Down Expand Up @@ -86,7 +81,8 @@ require (
k8s.io/api v0.0.0-20191219150132-17cfeff5d095
k8s.io/apimachinery v0.16.7-beta.0
k8s.io/client-go v0.0.0-20191225075139-73fd2ddc9180
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a
k8s.io/code-generator v0.16.7-beta.0 // indirect
k8s.io/kube-openapi v0.0.0-20191107075043-30be4d16710a // indirect
k8s.io/utils v0.0.0-20191218082557-f07c713de883
sigs.k8s.io/yaml v1.1.0
upper.io/db.v3 v3.6.3+incompatible
Expand Down
39 changes: 25 additions & 14 deletions go.sum

Large diffs are not rendered by default.

64 changes: 0 additions & 64 deletions hack/gen-openapi-spec/main.go

This file was deleted.

2 changes: 1 addition & 1 deletion hack/generate-proto.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ for f in $(find pkg -name '*.proto'); do
-I ${GOPATH}/pkg/mod/github.com/grpc-ecosystem/grpc-gateway@v1.12.1/third_party/googleapis \
--gogofast_out=plugins=grpc:${GOPATH}/src \
--grpc-gateway_out=logtostderr=true:${GOPATH}/src \
--swagger_out=logtostderr=true:. \
--swagger_out=logtostderr=true,fqn_for_swagger_name=true:. \
$f
done
17 changes: 17 additions & 0 deletions hack/swaggify.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
set -eu -o pipefail

# order is important, "REPLACEME" -> "workflow"
cat \
| sed 's/github.com.argoproj.argo.pkg.apis.workflow.v1alpha1./io.argoproj.REPLACEME.v1alpha1./' \
| sed 's/workflow\./io.argoproj.REPLACEME.v1alpha1./' \
| sed 's/cronworkflow\./io.argoproj.REPLACEME.v1alpha1./' \
| sed 's/info\./io.argoproj.REPLACEME.v1alpha1./' \
| sed 's/workflowarchive\./io.argoproj.REPLACEME.v1alpha1./' \
| sed 's/workflowtemplate\./io.argoproj.REPLACEME.v1alpha1./' \
| sed 's/io.argoproj.REPLACEME.v1alpha1./io.argoproj.workflow.v1alpha1./' \
| sed 's/io.k8s.apimachinery.pkg.runtime./io.k8s.api.core.v1./' \
| sed 's/k8s.io.api.core.v1./io.k8s.api.core.v1./' \
| sed 's/k8s.io.apimachinery.pkg.api.resource./io.k8s.api.core.v1./' \
| sed 's/k8s.io.apimachinery.pkg.apis.meta.v1./io.k8s.api.core.v1./' \
| sed 's/k8s.io.apimachinery.pkg.util.intstr./io.k8s.api.core.v1./'
12 changes: 0 additions & 12 deletions hack/update-openapigen.sh

This file was deleted.

26 changes: 0 additions & 26 deletions hack/upload-asset.sh

This file was deleted.

35 changes: 35 additions & 0 deletions pkg/apiclient/_.primary.swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"swagger": "2.0",
"host": "localhost:2746",
"schemes": [
"http"
],
"info": {
"title": "Argo",
"version": "VERSION"
},
"securityDefinitions": {
"BearerToken": {
"description": "Bearer Token authentication",
"type": "apiKey",
"name": "authorization",
"in": "header"
},
"HTTPBasic": {
"description": "HTTP Basic authentication",
"type": "basic"
}
},
"paths": {},
"definitions": {
"io.k8s.apimachinery.pkg.runtime.Object": {
"title": "This is a hack do deal with this problem: https://github.com/kubernetes/kube-openapi/issues/174"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func (a argoKubeWorkflowTemplateServiceClient) UpdateWorkflowTemplate(ctx contex
return a.delegate.UpdateWorkflowTemplate(ctx, req)
}

func (a argoKubeWorkflowTemplateServiceClient) DeleteWorkflowTemplate(ctx context.Context, req *workflowtemplatepkg.WorkflowTemplateDeleteRequest, _ ...grpc.CallOption) (*workflowtemplatepkg.WorkflowDeleteResponse, error) {
func (a argoKubeWorkflowTemplateServiceClient) DeleteWorkflowTemplate(ctx context.Context, req *workflowtemplatepkg.WorkflowTemplateDeleteRequest, _ ...grpc.CallOption) (*workflowtemplatepkg.WorkflowTemplateDeleteResponse, error) {
return a.delegate.DeleteWorkflowTemplate(ctx, req)
}

Expand Down
Loading

0 comments on commit b594716

Please sign in to comment.