feat(wfe-buildkit-protos): generate full BuildKit gRPC API (tonic 0.14)
New crate generating Rust gRPC stubs from the official BuildKit proto files (git submodule from moby/buildkit). Control service, LLB definitions, session protocols, and source policy. tonic 0.14 / prost 0.14.
This commit is contained in:
19
wfe-buildkit-protos/Cargo.toml
Normal file
19
wfe-buildkit-protos/Cargo.toml
Normal file
@@ -0,0 +1,19 @@
|
||||
[package]
|
||||
name = "wfe-buildkit-protos"
|
||||
version.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
repository.workspace = true
|
||||
homepage.workspace = true
|
||||
description = "Generated gRPC stubs for the full BuildKit API"
|
||||
|
||||
[dependencies]
|
||||
tonic = "0.14"
|
||||
tonic-prost = "0.14"
|
||||
prost = "0.14"
|
||||
prost-types = "0.14"
|
||||
|
||||
[build-dependencies]
|
||||
tonic-build = "0.14"
|
||||
tonic-prost-build = "0.14"
|
||||
prost-build = "0.14"
|
||||
58
wfe-buildkit-protos/build.rs
Normal file
58
wfe-buildkit-protos/build.rs
Normal file
@@ -0,0 +1,58 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let buildkit_root = PathBuf::from("vendor/buildkit");
|
||||
|
||||
// Use Go-style import paths so protoc sees each file only once
|
||||
let proto_dir = PathBuf::from("proto");
|
||||
let go_prefix = "github.com/moby/buildkit";
|
||||
|
||||
let proto_files: Vec<PathBuf> = vec![
|
||||
// Core control service (Solve, Status, ListWorkers, etc.)
|
||||
"api/services/control/control.proto",
|
||||
// Types
|
||||
"api/types/worker.proto",
|
||||
// Solver / LLB definitions
|
||||
"solver/pb/ops.proto",
|
||||
// Source policy
|
||||
"sourcepolicy/pb/policy.proto",
|
||||
// Session protocols
|
||||
"session/auth/auth.proto",
|
||||
"session/filesync/filesync.proto",
|
||||
"session/secrets/secrets.proto",
|
||||
"session/sshforward/ssh.proto",
|
||||
"session/upload/upload.proto",
|
||||
"session/exporter/exporter.proto",
|
||||
// Utilities
|
||||
"util/apicaps/pb/caps.proto",
|
||||
"util/stack/stack.proto",
|
||||
]
|
||||
.into_iter()
|
||||
.map(|p| proto_dir.join(go_prefix).join(p))
|
||||
.collect();
|
||||
|
||||
println!(
|
||||
"cargo:warning=Compiling {} buildkit proto files",
|
||||
proto_files.len()
|
||||
);
|
||||
|
||||
let mut prost_config = prost_build::Config::new();
|
||||
prost_config.include_file("mod.rs");
|
||||
|
||||
tonic_prost_build::configure()
|
||||
.build_server(false)
|
||||
.compile_with_config(
|
||||
prost_config,
|
||||
&proto_files,
|
||||
// Include paths for import resolution:
|
||||
// 1. The vendor dir inside buildkit (for Go-style github.com/... imports)
|
||||
// 2. The buildkit root itself (for relative imports)
|
||||
// 3. Our proto/ dir (for google/rpc/status.proto)
|
||||
&[
|
||||
// proto/ has symlinks that resolve Go-style github.com/... imports
|
||||
PathBuf::from("proto"),
|
||||
],
|
||||
)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
1
wfe-buildkit-protos/proto/github.com/moby/buildkit
Symbolic link
1
wfe-buildkit-protos/proto/github.com/moby/buildkit
Symbolic link
@@ -0,0 +1 @@
|
||||
/Users/sienna/Development/sunbeam/wfe/wfe-buildkit-protos/vendor/buildkit
|
||||
@@ -0,0 +1,7 @@
|
||||
// Stub for vtprotobuf extensions — not needed for Rust codegen
|
||||
syntax = "proto3";
|
||||
package vtproto;
|
||||
import "google/protobuf/descriptor.proto";
|
||||
extend google.protobuf.MessageOptions {
|
||||
bool mempool = 64101;
|
||||
}
|
||||
1
wfe-buildkit-protos/proto/github.com/tonistiigi/fsutil
Symbolic link
1
wfe-buildkit-protos/proto/github.com/tonistiigi/fsutil
Symbolic link
@@ -0,0 +1 @@
|
||||
/Users/sienna/Development/sunbeam/wfe/wfe-buildkit-protos/vendor/buildkit/vendor/github.com/tonistiigi/fsutil
|
||||
49
wfe-buildkit-protos/proto/google/rpc/status.proto
Normal file
49
wfe-buildkit-protos/proto/google/rpc/status.proto
Normal file
@@ -0,0 +1,49 @@
|
||||
// Copyright 2025 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
syntax = "proto3";
|
||||
|
||||
package google.rpc;
|
||||
|
||||
import "google/protobuf/any.proto";
|
||||
|
||||
option cc_enable_arenas = true;
|
||||
option go_package = "google.golang.org/genproto/googleapis/rpc/status;status";
|
||||
option java_multiple_files = true;
|
||||
option java_outer_classname = "StatusProto";
|
||||
option java_package = "com.google.rpc";
|
||||
option objc_class_prefix = "RPC";
|
||||
|
||||
// The `Status` type defines a logical error model that is suitable for
|
||||
// different programming environments, including REST APIs and RPC APIs. It is
|
||||
// used by [gRPC](https://github.com/grpc). Each `Status` message contains
|
||||
// three pieces of data: error code, error message, and error details.
|
||||
//
|
||||
// You can find out more about this error model and how to work with it in the
|
||||
// [API Design Guide](https://cloud.google.com/apis/design/errors).
|
||||
message Status {
|
||||
// The status code, which should be an enum value of
|
||||
// [google.rpc.Code][google.rpc.Code].
|
||||
int32 code = 1;
|
||||
|
||||
// A developer-facing error message, which should be in English. Any
|
||||
// user-facing error message should be localized and sent in the
|
||||
// [google.rpc.Status.details][google.rpc.Status.details] field, or localized
|
||||
// by the client.
|
||||
string message = 2;
|
||||
|
||||
// A list of messages that carry the error details. There is a common set of
|
||||
// message types for APIs to use.
|
||||
repeated google.protobuf.Any details = 3;
|
||||
}
|
||||
19
wfe-buildkit-protos/src/lib.rs
Normal file
19
wfe-buildkit-protos/src/lib.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
//! Generated gRPC stubs for the full BuildKit API.
|
||||
//!
|
||||
//! Built from the official BuildKit proto files at
|
||||
//! <https://github.com/moby/buildkit>.
|
||||
//!
|
||||
//! ```rust,ignore
|
||||
//! use wfe_buildkit_protos::moby::buildkit::v1::control_client::ControlClient;
|
||||
//! use wfe_buildkit_protos::moby::buildkit::v1::StatusResponse;
|
||||
//! ```
|
||||
|
||||
#![allow(clippy::all)]
|
||||
#![allow(warnings)]
|
||||
|
||||
include!(concat!(env!("OUT_DIR"), "/mod.rs"));
|
||||
|
||||
/// Re-export tonic and prost for downstream convenience.
|
||||
pub use prost;
|
||||
pub use prost_types;
|
||||
pub use tonic;
|
||||
1
wfe-buildkit-protos/vendor/buildkit
vendored
Submodule
1
wfe-buildkit-protos/vendor/buildkit
vendored
Submodule
Submodule wfe-buildkit-protos/vendor/buildkit added at 7ea9fa1c7c
Reference in New Issue
Block a user