Skip to content

Commit

Permalink
feat: reworking protobuf files
Browse files Browse the repository at this point in the history
Signed-off-by: AlexsJones <[email protected]>
  • Loading branch information
AlexsJones committed Aug 5, 2024
1 parent f2ddb11 commit 744d6bb
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 72 deletions.
17 changes: 0 additions & 17 deletions protobuf/schema/v1/analyzer.proto

This file was deleted.

25 changes: 25 additions & 0 deletions protobuf/schema/v1/custom_analyzer.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";

package schema.v1;
// well know type by google, gRPC gateway uses HTTP annotation.
import "google/api/annotations.proto";

import "schema/v1/server_analyzer_service.proto";

option go_package = "schema/service/v1";

message RunRequest {}

message RunResponse {
schema.v1.Result result = 1;
}

service CustomAnalyzerService {

rpc Run (RunRequest) returns (RunResponse) {
option (google.api.http) = {
post: "/v1/run"
body: "*"
};
}
}
66 changes: 66 additions & 0 deletions protobuf/schema/v1/server_analyzer_service.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
syntax = "proto3";

package schema.v1;

// well know type by google, gRPC gateway uses HTTP annotation.
import "google/api/annotations.proto";

option go_package = "schema/service/v1";

message AnalyzeRequest {
string backend = 1;
string namespace = 2;
bool explain = 3;
bool anonymize = 4;
bool nocache = 5;
string language = 6;
int32 max_concurrency = 7;
string output = 8;
repeated string filters = 9;
string label_selector = 10;
}

message SensitiveData {
string unmasked = 1;
string masked = 2;
}

message ErrorDetail {
string text = 1;
repeated SensitiveData sensitive = 2;
}

message Result {
string kind = 1;
string name = 2;
repeated ErrorDetail error = 3;
string details = 4;
string parent_object = 5;
}

message AnalyzeResponse {
Error error = 1;
repeated string errors = 2;
string status = 3;
int32 problems = 4;
repeated Result results = 5;
}

message Error {
string message = 1;
int32 code = 2;
}


service ServerAnalyzerService {
rpc Analyze(AnalyzeRequest) returns (AnalyzeResponse) {
// option type is http
option (google.api.http) = {
// this is url, for RESTfull/JSON api and method
// this line means when a HTTP post request comes with "/v1/analyze" call this rpc method over this service
// the request body AnalyzeRequest can be passed in to parameterize the request
post: "/v1/analyze"
body: "*"
};
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,6 @@ import "google/api/annotations.proto";

option go_package = "schema/service/v1";

message AnalyzeRequest {
string backend = 1;
string namespace = 2;
bool explain = 3;
bool anonymize = 4;
bool nocache = 5;
string language = 6;
int32 max_concurrency = 7;
string output = 8;
repeated string filters = 9;
string label_selector = 10;
}

message SensitiveData {
string unmasked = 1;
string masked = 2;
}

message ErrorDetail {
string text = 1;
repeated SensitiveData sensitive = 2;
}

message Result {
string kind = 1;
string name = 2;
repeated ErrorDetail error = 3;
string details = 4;
string parent_object = 5;
}

message AnalyzeResponse {
Error error = 1;
repeated string errors = 2;
string status = 3;
int32 problems = 4;
repeated Result results = 5;
}

message Error {
string message = 1;
int32 code = 2;
}

message Analysis {
repeated AnalysisItem analysis = 1;
}
Expand Down Expand Up @@ -133,17 +89,14 @@ message ListIntegrationsResponse {
Trivy trivy = 1;
}

service ServerService {
rpc Analyze(AnalyzeRequest) returns (AnalyzeResponse) {
// option type is http
option (google.api.http) = {
// this is url, for RESTfull/JSON api and method
// this line means when a HTTP post request comes with "/v1/analyze" call this rpc method over this service
// the request body AnalyzeRequest can be passed in to parameterize the request
post: "/v1/analyze"
body: "*"
};
}
message ShutdownRequest {}

message ShutdownResponse {
string status = 1;
}

service ServerConfigService {

rpc AddConfig(AddConfigRequest) returns (AddConfigResponse) {}
rpc RemoveConfig(RemoveConfigRequest) returns (RemoveConfigResponse) {}
rpc ListIntegrations(ListIntegrationsRequest) returns (ListIntegrationsResponse) {
Expand All @@ -153,4 +106,14 @@ service ServerService {
get: "/v1/list"
};
}
// This command when run against the k8sgpt serve process will terminate it
// When that process is run in a Kubernetes pod it will restart it
rpc Shutdown(ShutdownRequest) returns (ShutdownResponse) {
// option type is http
option (google.api.http) = {
// this line means when a HTTP POST request comes with "/v1/shutdown" call this rpc method over this service
post: "/v1/shutdown"
body: "*"
};
}
}

0 comments on commit 744d6bb

Please sign in to comment.