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

Extensions Framework: Adds gRPC proto files and generated services #4695

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
11 changes: 11 additions & 0 deletions cli/azd/.vscode/cspell.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,31 @@
import: ../../../.vscode/cspell.global.yaml
words:
- azcloud
- azdext
- azurefd
- backoff
- Canonicalize
- chinacloudapi
- Codespace
- Codespaces
- devcontainers
- extendee
# CDN host name
- gfgac2cmf7b8cuay
- goversioninfo
- nosec
- oneof
- idxs
# Looks like the protogen has a spelling error for panics
- pancis
- protobuf
- protoc
- protoreflect
- protoimpl
- Retryable
- runcontext
- unmarshals
- unsetting
- usgovcloudapi
languageSettings:
- languageId: go
Expand Down
20 changes: 20 additions & 0 deletions cli/azd/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
PROTO_DIR=grpc/proto
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add notes to https://github.com/Azure/azure-dev/blob/main/cli/azd/CONTRIBUTING.md about how to run this file to generate files when needed

GEN_DIR=pkg/azdext
INCLUDE_DIR=grpc/include # Local directory containing the protobuf include files

.PHONY: all proto clean

all: proto

proto:
# Generate server-side code
mkdir -p $(GEN_DIR)
# Generate code for all .proto files into the same package
protoc --proto_path=$(INCLUDE_DIR) \
--proto_path=$(PROTO_DIR) \
--go_out=$(GEN_DIR) --go_opt=paths=source_relative \
--go-grpc_out=$(GEN_DIR) --go-grpc_opt=paths=source_relative \
$(PROTO_DIR)/*.proto

clean:
rm -rf $(GEN_DIR)
33 changes: 33 additions & 0 deletions cli/azd/grpc/proto/deployment.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
syntax = "proto3";

package azdext;

option go_package = "github.com/azure/azure-dev/cli/azd/pkg/azdext/gen;azdext";

import "models.proto";

service DeploymentService {
// Gets the current environment.
rpc GetDeployment(EmptyRequest) returns (GetDeploymentResponse);

rpc GetDeploymentContext(EmptyRequest) returns (GetDeploymentContextResponse);
}

message GetDeploymentResponse {
Deployment deployment = 1;
}

message GetDeploymentContextResponse {
azdext.AzureContext AzureContext = 1;
}

message Deployment {
string id = 1;
string location = 2;
string deploymentId = 3;
string name = 4;
string type = 5;
map<string, string> tags = 6;
map<string,string> outputs = 7;
repeated string resources = 8;
}
149 changes: 149 additions & 0 deletions cli/azd/grpc/proto/environment.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
syntax = "proto3";

package azdext;

option go_package = "github.com/azure/azure-dev/cli/azd/pkg/azdext/gen;azdext";

import "models.proto";

// EnvironmentService defines methods for managing environments and their key-value pairs.
service EnvironmentService {
// Gets the current environment.
rpc GetCurrent(EmptyRequest) returns (EnvironmentResponse);

rpc List(EmptyRequest) returns (EnvironmentListResponse);

// Get retrieves an environment by its name.
rpc Get (GetEnvironmentRequest) returns (EnvironmentResponse);

// Select sets the current environment to the specified environment.
rpc Select (SelectEnvironmentRequest) returns (EmptyResponse);

// GetValues retrieves all key-value pairs in the specified environment.
rpc GetValues (GetEnvironmentRequest) returns (KeyValueListResponse);

// GetValue retrieves the value of a specific key in the specified environment.
rpc GetValue (GetEnvRequest) returns (KeyValueResponse);

// SetValue sets the value of a key in the specified environment.
rpc SetValue (SetEnvRequest) returns (EmptyResponse);

// RPC for getting a config value by path
rpc GetConfig (GetConfigRequest) returns (GetConfigResponse);

// RPC for getting a config value as a string by path
rpc GetConfigString (GetConfigStringRequest) returns (GetConfigStringResponse);

// RPC for getting a config section by path
rpc GetConfigSection (GetConfigSectionRequest) returns (GetConfigSectionResponse);

// RPC for setting a config value at a given path
rpc SetConfig (SetConfigRequest) returns (EmptyResponse);

// RPC for unsetting a config value at a given path
rpc UnsetConfig (UnsetConfigRequest) returns (EmptyResponse);
}

// Request to retrieve an environment by name.
message GetEnvironmentRequest {
string name = 1; // Name of the environment.
}

message SelectEnvironmentRequest {
string name = 1; // Name of the environment.
}

// Request to retrieve a specific key-value pair.
message GetEnvRequest {
string env_name = 1; // Name of the environment.
string key = 2; // Key to retrieve.
}

// Request to set a key-value pair.
message SetEnvRequest {
string env_name = 1; // Name of the environment.
string key = 2; // Key to set.
string value = 3; // Value to set for the key.
}

// Response containing details of an environment.
message EnvironmentResponse {
Environment environment = 1; // Environment details.
}

message EnvironmentListResponse {
repeated EnvironmentDescription environments = 1; // List of environments.
}

// Response containing a list of key-value pairs.
message KeyValueListResponse {
repeated KeyValue key_values = 1; // List of key-value pairs.
}

// Response containing a single key-value pair.
message KeyValueResponse {
string key = 1; // Key name.
string value = 2; // Value associated with the key.
}

// Environment object definition.
message Environment {
string name = 1; // Name of the environment.
}

message EnvironmentDescription {
string name = 1; // Name of the environment.
bool local = 2; // Whether the environment is local.
bool remote = 3; // Whether the environment is remote.
bool default = 4; // Whether the environment is the default.
}

// Key-value pair definition.
message KeyValue {
string key = 1; // Key name.
string value = 2; // Value associated with the key.
}

// Request message for Get
message GetConfigRequest {
string path = 1;
}

// Response message for Get
message GetConfigResponse {
bytes value = 1;
bool found = 2;
}

// Request message for GetString
message GetConfigStringRequest {
string path = 1;
}

// Response message for GetString
message GetConfigStringResponse {
string value = 1;
bool found = 2;
}

// Request message for GetSection
message GetConfigSectionRequest {
string path = 1;
}

// Response message for GetSection
message GetConfigSectionResponse {
bytes section = 1;
bool found = 2;
}

// Request message for Set
message SetConfigRequest {
string path = 1;
bytes value = 2;
}

// Request message for Unset
message UnsetConfigRequest {
string path = 1;
}
59 changes: 59 additions & 0 deletions cli/azd/grpc/proto/models.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
syntax = "proto3";

package azdext;

option go_package = "github.com/azure/azure-dev/cli/azd/pkg/azdext/gen;azdext";

// Messages for requests and responses
message EmptyRequest {}

// EmptyResponse message for methods with no output.
message EmptyResponse {}

// Message representing a Subscription
message Subscription {
string id = 1;
string name = 2;
string tenantId = 3;
string userAccessTenant_id = 4;
bool isDefault = 5;
}

message ResourceGroup {
string id = 1;
string name = 2;
string location = 3;
}

message Location {
string name = 1;
string displayName = 2;
string regionalDisplayName = 3;
}

message AzureScope {
string tenantId = 1;
string subscriptionId = 2;
string location = 3;
string resourceGroup = 4;
}

message AzureContext {
AzureScope scope = 1;
repeated string resources = 2;
}

message Resource {
string id = 1;
string name = 2;
string type = 3;
string location = 4;
}

message ResourceExtended {
string id = 1;
string name = 2;
string type = 3;
string location = 4;
string kind = 5;
}
58 changes: 58 additions & 0 deletions cli/azd/grpc/proto/project.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
syntax = "proto3";

package azdext;

option go_package = "github.com/azure/azure-dev/cli/azd/pkg/azdext/gen;azdext";

import "models.proto";

// ProjectService defines methods for managing projects and their configurations.
service ProjectService {
// Gets the current project.
rpc Get(EmptyRequest) returns (GetProjectResponse);
}

// ProjectConfig message definition
message ProjectConfig {
string name = 1;
string resource_group_name = 2;
string path = 3;
ProjectMetadata metadata = 4;
map<string, ServiceConfig> services = 5;
InfraOptions infra = 6;
}

// GetProjectResponse message definition
message GetProjectResponse {
ProjectConfig project = 1;
}

// RequiredVersions message definition
message RequiredVersions {
string azd = 1;
}

// ProjectMetadata message definition
message ProjectMetadata {
string template = 1;
}

// ServiceConfig message definition
message ServiceConfig {
string name = 1;
string resource_group_name = 2;
string resource_name = 3;
string api_version = 4;
string relative_path = 5;
string host = 6;
string language = 7;
string output_path = 8;
string image = 9;
}

// InfraOptions message definition
message InfraOptions {
string provider = 1;
string path = 2;
string module = 3;
}
Loading
Loading