Skip to content

Commit

Permalink
[public-api] Add and enforce application-level error status
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel committed Mar 11, 2022
1 parent d955fc6 commit 46f5ab6
Show file tree
Hide file tree
Showing 28 changed files with 1,925 additions and 939 deletions.
9 changes: 9 additions & 0 deletions components/public-api/BUILD.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
scripts:
- name: lint
deps:
- components/public-api/hack/protoc-gen-gplint:app
script: |
protoc \
-I /usr/lib/protoc/include -I. \
--gplint_out=. \
gitpod/v1/*.proto
2 changes: 2 additions & 0 deletions components/public-api/buf.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ breaking:
lint:
use:
- DEFAULT
ignore:
- google
3 changes: 3 additions & 0 deletions components/public-api/generate.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash



if [ -n "$DEBUG" ]; then
set -x
fi
Expand All @@ -16,6 +18,7 @@ COMPONENTS_DIR="$ROOT_DIR"/components
source "$ROOT_DIR"/scripts/protoc-generator.sh

lint
leeway run .:lint

install_dependencies
go_protoc "$COMPONENTS_DIR" "gitpod/v1"
Expand Down
4 changes: 3 additions & 1 deletion components/public-api/gitpod/v1/prebuilds.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ syntax = "proto3";

package gitpod.v1;

import "google/rpc/status.proto";

option go_package = "github.com/gitpod-io/gitpod/public-api/v1";

// import "gitpod/v1/pagination.proto";
Expand All @@ -19,7 +21,7 @@ message GetRunningPrebuildRequest {
}

message GetRunningPrebuildResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

string prebuild_id = 2;
}
Expand Down
30 changes: 18 additions & 12 deletions components/public-api/gitpod/v1/workspaces.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ option go_package = "github.com/gitpod-io/gitpod/public-api/v1";

import "google/protobuf/timestamp.proto";
import "google/protobuf/field_mask.proto";
import "google/rpc/status.proto";
import "gitpod/v1/pagination.proto";

service WorkspacesService {
Expand Down Expand Up @@ -52,22 +53,25 @@ message ListWorkspacesRequest {
google.protobuf.FieldMask field_mask = 2;
}
message ListWorkspacesResponse {
// Status status = 1;
string next_page_token = 2;

message WorkspaceAndInstance {
Workspace result = 1;
WorkspaceInstance last_active_instances = 2;
}

repeated WorkspaceAndInstance result = 1;
google.rpc.Status response_status = 1;

string next_page_token = 2;

repeated WorkspaceAndInstance result = 3;
}

message GetWorkspaceRequest {
string workspace_id = 1;
}
message GetWorkspaceResponse {
Workspace result = 1;
google.rpc.Status response_status = 1;

Workspace result = 2;
}

message CreateAndStartWorkspaceRequest {
Expand All @@ -86,7 +90,7 @@ message CreateAndStartWorkspaceRequest {
StartWorkspaceSpec start_spec = 5;
}
message CreateAndStartWorkspaceResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

string workspace_id = 2;
}
Expand All @@ -98,7 +102,7 @@ message StartWorkspaceRequest {
StartWorkspaceSpec spec = 3;
}
message StartWorkspaceResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

string instance_id = 2;
string workspace_url = 3;
Expand All @@ -108,7 +112,7 @@ message GetActiveWorkspaceInstanceRequest {
string workspace_id = 1;
}
message GetActiveWorkspaceInstanceResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

WorkspaceInstance instance = 2;
}
Expand All @@ -117,7 +121,7 @@ message GetWorkspaceInstanceOwnerTokenRequest {
string instance_id = 1;
}
message GetWorkspaceInstanceOwnerTokenResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

string owner_token = 2;
}
Expand All @@ -126,7 +130,7 @@ message ListenToWorkspaceInstanceRequest {
string instance_id = 1;
}
message ListenToWorkspaceInstanceResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

WorkspaceInstanceStatus instance_status = 2;
}
Expand All @@ -135,7 +139,7 @@ message ListenToImageBuildLogsRequest {
string instance_id = 1;
}
message ListenToImageBuildLogsResponse {
// Status status = 1;
google.rpc.Status response_status = 1;

string line = 2;
}
Expand All @@ -145,7 +149,9 @@ message StopWorkspaceRequest {

string workspace_id = 2;
}
message StopWorkspaceResponse {}
message StopWorkspaceResponse {
google.rpc.Status response_status = 1;
}

////////////////////////////////
// Shared messages come here
Expand Down
37 changes: 1 addition & 36 deletions components/public-api/go/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,17 @@ module github.com/gitpod-io/gitpod/public-api
go 1.17

require (
github.com/gitpod-io/gitpod/common-go v0.0.0-00010101000000-000000000000
github.com/gitpod-io/gitpod/content-service/api v0.0.0-00010101000000-000000000000
github.com/go-ozzo/ozzo-validation v3.6.0+incompatible
github.com/golang/mock v1.6.0
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154
google.golang.org/grpc v1.39.1
google.golang.org/protobuf v1.27.1
k8s.io/api v0.23.4
k8s.io/apimachinery v0.23.4
)

require (
github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/go-logr/logr v1.2.0 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/gofuzz v1.1.0 // indirect
github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.2 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.32.1 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
golang.org/x/net v0.0.0-20211209124913-491a49abca63 // indirect
golang.org/x/sys v0.0.0-20220114195835-da31bd327af9 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e // indirect
google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/klog/v2 v2.30.0 // indirect
k8s.io/utils v0.0.0-20211116205334-6203023598ed // indirect
sigs.k8s.io/json v0.0.0-20211020170558-c049b76a60c6 // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
sigs.k8s.io/yaml v1.2.0 // indirect
)

replace github.com/gitpod-io/gitpod/common-go => ../../common-go // leeway
Expand Down
Loading

0 comments on commit 46f5ab6

Please sign in to comment.