diff --git a/.gitmodules b/.gitmodules index 81bea48..bf4e727 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "wfe-containerd-protos/vendor/containerd"] path = wfe-containerd-protos/vendor/containerd url = https://github.com/containerd/containerd.git +[submodule "wfe-buildkit-protos/vendor/buildkit"] + path = wfe-buildkit-protos/vendor/buildkit + url = https://github.com/moby/buildkit.git diff --git a/Cargo.toml b/Cargo.toml index e29f488..a1f481c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace] -members = ["wfe-core", "wfe-sqlite", "wfe-postgres", "wfe-opensearch", "wfe-valkey", "wfe", "wfe-yaml", "wfe-buildkit", "wfe-containerd", "wfe-containerd-protos"] +members = ["wfe-core", "wfe-sqlite", "wfe-postgres", "wfe-opensearch", "wfe-valkey", "wfe", "wfe-yaml", "wfe-buildkit", "wfe-containerd", "wfe-containerd-protos", "wfe-buildkit-protos"] resolver = "2" [workspace.package] diff --git a/wfe-buildkit-protos/Cargo.toml b/wfe-buildkit-protos/Cargo.toml new file mode 100644 index 0000000..6d72f52 --- /dev/null +++ b/wfe-buildkit-protos/Cargo.toml @@ -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" diff --git a/wfe-buildkit-protos/build.rs b/wfe-buildkit-protos/build.rs new file mode 100644 index 0000000..5360ecb --- /dev/null +++ b/wfe-buildkit-protos/build.rs @@ -0,0 +1,58 @@ +use std::path::PathBuf; + +fn main() -> Result<(), Box> { + 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 = 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(()) +} diff --git a/wfe-buildkit-protos/proto/github.com/moby/buildkit b/wfe-buildkit-protos/proto/github.com/moby/buildkit new file mode 120000 index 0000000..ec10f85 --- /dev/null +++ b/wfe-buildkit-protos/proto/github.com/moby/buildkit @@ -0,0 +1 @@ +/Users/sienna/Development/sunbeam/wfe/wfe-buildkit-protos/vendor/buildkit \ No newline at end of file diff --git a/wfe-buildkit-protos/proto/github.com/planetscale/vtprotobuf/vtproto/ext.proto b/wfe-buildkit-protos/proto/github.com/planetscale/vtprotobuf/vtproto/ext.proto new file mode 100644 index 0000000..c49fbbd --- /dev/null +++ b/wfe-buildkit-protos/proto/github.com/planetscale/vtprotobuf/vtproto/ext.proto @@ -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; +} diff --git a/wfe-buildkit-protos/proto/github.com/tonistiigi/fsutil b/wfe-buildkit-protos/proto/github.com/tonistiigi/fsutil new file mode 120000 index 0000000..68ba7b6 --- /dev/null +++ b/wfe-buildkit-protos/proto/github.com/tonistiigi/fsutil @@ -0,0 +1 @@ +/Users/sienna/Development/sunbeam/wfe/wfe-buildkit-protos/vendor/buildkit/vendor/github.com/tonistiigi/fsutil \ No newline at end of file diff --git a/wfe-buildkit-protos/proto/google/rpc/status.proto b/wfe-buildkit-protos/proto/google/rpc/status.proto new file mode 100644 index 0000000..dc14c94 --- /dev/null +++ b/wfe-buildkit-protos/proto/google/rpc/status.proto @@ -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; +} diff --git a/wfe-buildkit-protos/src/lib.rs b/wfe-buildkit-protos/src/lib.rs new file mode 100644 index 0000000..3e4e188 --- /dev/null +++ b/wfe-buildkit-protos/src/lib.rs @@ -0,0 +1,19 @@ +//! Generated gRPC stubs for the full BuildKit API. +//! +//! Built from the official BuildKit proto files at +//! . +//! +//! ```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; diff --git a/wfe-buildkit-protos/vendor/buildkit b/wfe-buildkit-protos/vendor/buildkit new file mode 160000 index 0000000..7ea9fa1 --- /dev/null +++ b/wfe-buildkit-protos/vendor/buildkit @@ -0,0 +1 @@ +Subproject commit 7ea9fa1c7cd9eacf8551661793191f2aac09863d