Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
aphralG committed Dec 19, 2024
1 parent 34d7f77 commit 6e22018
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 15 deletions.
26 changes: 17 additions & 9 deletions api/grpc/mpi/v1/command.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions api/grpc/mpi/v1/command.proto
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,17 @@ message ConfigUploadRequest {

// Perform an associated API action on an instance
message APIActionRequest {
// the identifier associated with the instance
string instance_id = 1;
// types of API actions possible
oneof action {
NGINXPlusAction nginx_plus_action = 2;
}
}

// Perform an action using the NGINX Plus API on an instance
message NGINXPlusAction {
// types of actions possible with NGINX Plus API
oneof action {
UpdateHTTPUpstreamServers update_http_upstream_servers = 2;
GetHTTPUpstreamServers get_http_upstream_servers = 3;
Expand All @@ -208,12 +211,15 @@ message NGINXPlusAction {

// Update HTTP Upstream Servers for an instance
message UpdateHTTPUpstreamServers {
// the name of the upstream to update
string http_upstream_name = 1;
// a list of upstream servers
repeated google.protobuf.Struct servers = 2;
}

// Get HTTP Upstream Servers for an instance
message GetHTTPUpstreamServers {
// the name of the upstream
string http_upstream_name = 1;
}

Expand Down
8 changes: 4 additions & 4 deletions docs/proto/protos.md
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ Perform an associated API action on an instance

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| instance_id | [string](#string) | | |
| instance_id | [string](#string) | | the identifier associated with the instance |
| nginx_plus_action | [NGINXPlusAction](#mpi-v1-NGINXPlusAction) | | |


Expand Down Expand Up @@ -790,7 +790,7 @@ Get HTTP Upstream Servers for an instance

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| http_upstream_name | [string](#string) | | |
| http_upstream_name | [string](#string) | | the name of the upstream |



Expand Down Expand Up @@ -1129,8 +1129,8 @@ Update HTTP Upstream Servers for an instance

| Field | Type | Label | Description |
| ----- | ---- | ----- | ----------- |
| http_upstream_name | [string](#string) | | |
| servers | [google.protobuf.Struct](#google-protobuf-Struct) | repeated | |
| http_upstream_name | [string](#string) | | the name of the upstream to update |
| servers | [google.protobuf.Struct](#google-protobuf-Struct) | repeated | a list of upstream servers |



Expand Down
2 changes: 2 additions & 0 deletions internal/resource/resource_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ func (r *Resource) handleNginxPlusActionRequest(ctx context.Context, action *mpi
"action, could not find instance with ID: %s", instanceID))

r.messagePipe.Process(ctx, &bus.Message{Topic: bus.DataPlaneResponseTopic, Data: resp})

return
}

if instance.GetInstanceMeta().GetInstanceType() != mpi.InstanceMeta_INSTANCE_TYPE_NGINX_PLUS {
Expand Down
4 changes: 2 additions & 2 deletions internal/resource/resource_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,11 @@ func convertToUpstreamServer(upstreams []*structpb.Struct) []client.UpstreamServ
var servers []client.UpstreamServer
res, err := json.Marshal(upstreams)
if err != nil {
slog.Error("Failed to marshal upstreams", "error", err, "upstreams", upstreams)
slog.Error("Failed to marshal upstreams", "error", err, "servers", servers)
}
err = json.Unmarshal(res, &servers)
if err != nil {
slog.Error("Failed to unmarshal upstreams", "error", err, "upstreams", upstreams)
slog.Error("Failed to unmarshal upstreams", "error", err, "servers", servers)
}

return servers
Expand Down

0 comments on commit 6e22018

Please sign in to comment.